Exemple #1
0
int do_usbd_dnw ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{

	if (argv[0][0] == 'u') {
		DNW = 0;
	}
	else {
		DNW = 1;
		s3c_got_header = 0;
	}

	switch (argc) {
	case 1 :
		s3c_usbd_dn_addr = USBD_DOWN_ADDR;	/* Default Address */
		break;
	case 2 :
		s3c_usbd_dn_addr = simple_strtoul(argv[1], NULL, 16);
		break;
	default:
		printf ("Usage:\n%s\n", cmdtp->usage);
		return 1;
	}

	s3c_receive_done = 0;

	s3c_usbctl_init();
	s3c_usbc_activate();

	PRINTF("Download address 0x%08x\n", s3c_usbd_dn_addr);
	printf("Now, Waiting for DNW to transmit data\n");

	while (1) {
		if (S3C_USBD_DETECT_IRQ()) {
			s3c_udc_int_hndlr();
			S3C_USBD_CLEAR_IRQ();
		}

		if (s3c_receive_done)
			break;

		if (serial_tstc()) {
			serial_getc();
			break;
		}
	}

	/* when operation is done, usbd must be stopped */
	s3c_usb_stop();

	return 0;
}
Exemple #2
0
int RealARMGetDataFromUSB (unsigned max_len, unsigned char **data_ptr, unsigned *received_len)
{
	s3c_usbd_dn_addr = USBD_DOWN_ADDR;	/* Default Address */
	s3c_receive_done = 0;

	//memset( (unsigned char *)USBD_DOWN_ADDR, 0xFF, max_len);

	s3c_usbctl_init();
	s3c_usbc_activate();

	printf("Download address 0x%08x\n", s3c_usbd_dn_addr);

	while (1) {
		if (S3C_USBD_DETECT_IRQ()) {
			s3c_udc_int_hndlr();
			S3C_USBD_CLEAR_IRQ();
		}

		if (s3c_receive_done)
			break;
	}
	s3c_usb_stop();

	*received_len = UsbDownloadFileSize;
	*data_ptr = (unsigned char *)USBD_DOWN_ADDR;

	if (UsbDownloadFileSize > max_len) {
		printf("DNW download Data size is too big\n");
		return -1;
	}
	if (!UsbDownloadChecksumOK) {
		printf("DNW download Data Error\n");
		return -2;
	}
	{
		int PadLen = 128 * 1024 - UsbDownloadFileSize % (128 * 1024);
		PadLen %= 128 * 1024;
		if (PadLen != 0 && PadLen + UsbDownloadFileSize <= max_len) {
			memset((unsigned char *)USBD_DOWN_ADDR + UsbDownloadFileSize, 0xFF, PadLen);
		}
	}

	return 0;
}
otg_dev_t android_usbd_download()
{
	otg_dev_t	nOtg;

	s3c_usbd_dn_addr = ANDROID_DOWNLOAD_ADDRESS;
	s3c_receive_done = 0;

	s3c_usbctl_init();
	s3c_usbc_activate();

	printf("Now, Waiting for Android image downloading.\n");
	printf("Press the 'USB Port => Download' button.\n");

	while (1) {
		if (S3C_USBD_DETECT_IRQ()) {
			s3c_udc_int_hndlr();
			S3C_USBD_CLEAR_IRQ();
		}

		if (s3c_receive_done)
			break;

		if (serial_tstc()) {
			serial_getc();
			break;
		}
	}
	
	nOtg.dn_addr 		= s3c_usbd_dn_addr;
	nOtg.dn_filesize 	= s3c_usbd_dn_cnt >> 18;
	s3c_usbd_dn_cnt 	= (nOtg.dn_filesize << 18) + 0x40000;
	nOtg.dn_filesize 	= s3c_usbd_dn_cnt;
	
	/* when operation is done, usbd must be stopped */
	s3c_usb_stop();

	return nOtg;
}
int  fboot_usb_int_hndlr(void)
{
	return s3c_udc_int_hndlr();
}