if((!start) || (!part_sectors))
{
uint addr_in_hex;
int ret;
printf("sunxi fastboot download FAIL: partition %s does not exist\n", name);
printf("probe it as a dram address\n");
ret = strict_strtoul((const char *)name, 16, (long unsigned int*)&addr_in_hex);
if(ret)
{
printf("sunxi fatboot download FAIL: it is not a dram address\n");
sprintf(response, "FAILdownload: partition %s does not exist", name);
__sunxi_fastboot_send_status(response, strlen(response));
return -1;
}
else
{
printf("ready to move data to 0x%x, bytes 0x%x\n", addr_in_hex, trans_data.try_to_recv);
memcpy((void *)addr_in_hex, addr, trans_data.try_to_recv);
}
}
else
{
int format;
printf("ready to download bytes 0x%x\n", trans_data.try_to_recv);
format = unsparse_probe(addr, trans_data.try_to_recv, start);
if (0 == trans_data.try_to_recv)
{
/* bad user input */
sprintf(response, "FAILdownload: data size is 0");
}
else if (trans_data.try_to_recv > SUNXI_USB_FASTBOOT_BUFFER_MAX)
{
sprintf(response, "FAILdownload: data > buffer");
}
else
{
/* The default case, the transfer fits
completely in the interface buffer */
sprintf(response, "DATA%08x", trans_data.try_to_recv);
printf("download response: %s\n", response);
printf("start addr %s\n", start);
/* Execution should jump to kernel so send the response
now and wait a bit. */
sprintf(response, "OKAY");
//
fastboot_tx_status(response, strlen(response));
__msdelay (1000); /* 1 sec */
if (ntohl(hdr->ih_magic) == IH_MAGIC) {
/* Looks like a kernel.. */
printf ("Booting kernel..\n");
/*
* Check if the user sent a bootargs down.
* If not, do not override what is already there
*/
if (strlen ((char *) &fb_hdr->cmdline[0])) {
printf("Image has cmdline:");
printf("%s\n", &fb_hdr->cmdline[0]);
setenv ("bootargs", (char *) &fb_hdr->cmdline[0]);
}
do_bootm (NULL, 0, 2, bootm);
} else {
/* Raw image, maybe another uboot */
printf ("Booting raw image..\n");
static void sunxi_fastboot_usb_rx_dma_isr(void *p_arg)
{
printf("dma int for usb rx occur\n");
//通知主循环,可以写入数据
sunxi_usb_fastboot_write_enable = 1;
}
static void sunxi_fastboot_usb_tx_dma_isr(void *p_arg)
{
printf("dma int for usb tx occur\n");
}
static int sunxi_fastboot_standard_req_op(uint cmd, struct usb_device_request *req, uchar *buffer)
{
int ret = SUNXI_USB_REQ_OP_ERR;
//printf("standard req cmd = %x\n", cmd);
switch( cmd ){
case USB_REQ_GET_STATUS:
ret = __usb_get_status(req, buffer);
break;
//case USB_REQ_CLEAR_FEATURE:
//case USB_REQ_SET_FEATURE:
case USB_REQ_SET_ADDRESS:
ret = __usb_set_address(req);
break;
case USB_REQ_GET_DESCRIPTOR:
//case USB_REQ_SET_DESCRIPTOR:
case USB_REQ_GET_CONFIGURATION:
ret = __usb_get_descriptor(req, buffer);
break;
case USB_REQ_SET_CONFIGURATION:
ret = __usb_set_configuration(req);
break;
//case USB_REQ_GET_INTERFACE:
case USB_REQ_SET_INTERFACE:
ret = __usb_set_interface(req);
break;
//case USB_REQ_SYNCH_FRAME:
default:
tick_printf("sunxi fastboot error: standard req is not supported\n");
ret = SUNXI_USB_REQ_DEVICE_NOT_SUPPORTED;
break;
}
return ret;
}