/* ************************************************************************************************************ * * function * * name : * * parmeters : * * return : * * note : * * ************************************************************************************************************ */ void sunxi_usb_main_loop(int delaytime) { int ret; if(sunxi_usb_init(delaytime)) { printf("usb init fail\n"); sunxi_usb_exit(); return ; } printf("usb init ok\n"); while(1) { ret = sunxi_udev_active->state_loop(&sunxi_ubuf); if(ret) { break; } if(ctrlc()) { break; } } printf("exit usb\n"); sunxi_usb_exit(); sunxi_update_subsequent_processing(ret); return ; }
/* ************************************************************************************************************ * * function * * name : * * parmeters : * * return : * * note : * * ************************************************************************************************************ */ static void __continue(void) { char response[32]; memset(response, 0, 32); strcpy(response,"OKAY"); __sunxi_fastboot_send_status(response, strlen(response)); sunxi_usb_exit(); if(uboot_spare_head.boot_data.storage_type) { setenv("bootcmd", "run setargs_mmc boot_normal"); } else { setenv("bootcmd", "run setargs_nand boot_normal"); } do_bootd(NULL, 0, 1, NULL); return; }
/* ************************************************************************************************************ * * function * * name : * * parmeters : * * return : * * note : * * ************************************************************************************************************ */ int do_burn_from_boot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { struct timer_list timer_t; int ret; if(gd->vbus_status == SUNXI_VBUS_NOT_EXIST) { printf("out of usb burn from boot without usb\n"); return 0; } tick_printf("usb burn from boot\n"); if(sunxi_usb_dev_register(4) < 0) { printf("usb burn fail: not support burn private data\n"); return -1; } sunxi_usb_burn_from_boot_overtime = 0; if(sunxi_usb_init(0)) { printf("%s usb init fail\n", __func__); sunxi_usb_exit(); return 0; } timer_t.data = (unsigned long)&timer_t; timer_t.expires = 800; timer_t.function = probe_usb_overtime; init_timer(&timer_t); tick_printf("usb prepare ok\n"); add_timer(&timer_t); while(1) { if(sunxi_usb_burn_from_boot_init) //当usb sof中断触发,跳出循环 { printf("usb sof ok\n"); del_timer(&timer_t); break; } if(sunxi_usb_burn_from_boot_overtime) //当定时时间到,还没有中断,跳出循环 { tick_printf("overtime\n"); del_timer(&timer_t); sunxi_usb_exit(); tick_printf("%s usb : no usb exist\n", __func__); return 0; } } sunxi_usb_burn_from_boot_overtime = 0; tick_printf("usb probe ok\n"); //开始等待加载驱动,这里不需要延时 sunxi_usb_burn_from_boot_overtime = 0; tick_printf("usb setup ok\n"); timer_t.expires = 3000; add_timer(&timer_t); while(1) { ret = sunxi_usb_extern_loop(); //执行usb主循环 if(ret) //当执行结果非0,表示到了最后一个步骤,需要往后执行 { break; } if(sunxi_usb_burn_from_boot_handshake) //当握手成功,停止检查定时器 { del_timer(&timer_t); } if(sunxi_usb_burn_from_boot_overtime) //当定时时间到,还没有握手成功,跳出循环 { del_timer(&timer_t); sunxi_usb_exit(); tick_printf("%s usb : have no handshake\n", __func__); return 0; } if(ctrlc()) { del_timer(&timer_t); ret = SUNXI_UPDATE_NEXT_ACTION_NORMAL; break; } if(sunxi_key_read()>0) { del_timer(&timer_t); ret = SUNXI_UPDATE_NEXT_ACTION_NORMAL; break; } } tick_printf("exit usb burn from boot\n"); sunxi_usb_exit(); sunxi_update_subsequent_processing(ret); return 0; }