diff --git a/usbboot/src/cmd.c b/usbboot/src/cmd.c index 7c726f8..2d653cf 100644 --- a/usbboot/src/cmd.c +++ b/usbboot/src/cmd.c @@ -33,6 +33,7 @@ extern int com_argc; extern char com_argv[MAX_ARGC][MAX_COMMAND_LENGTH]; +extern char * stage1; struct ingenic_dev ingenic_dev; struct hand hand; @@ -788,7 +789,7 @@ int debug_memory(int obj, unsigned int start, unsigned int size) printf(" Now test memory from 0x%x to 0x%x: \n", start, start + hand.fw_args.size); - if (load_file(&ingenic_dev, STAGE1_FILE_PATH) < 1) + if (load_file(&ingenic_dev, stage1) < 1) return -1; if (usb_ingenic_upload(&ingenic_dev, 1) < 1) return -1; @@ -841,7 +842,7 @@ int debug_gpio(int obj, unsigned char ops, unsigned char pin) else printf(" GPIO %d clear!\n",pin); - if (load_file(&ingenic_dev, STAGE1_FILE_PATH) < 1) + if (load_file(&ingenic_dev, stage1) < 1) return -1; if (usb_ingenic_upload(&ingenic_dev, 1) < 1) return -1; diff --git a/usbboot/src/command_line.c b/usbboot/src/command_line.c index 7d0d997..4285193 100644 --- a/usbboot/src/command_line.c +++ b/usbboot/src/command_line.c @@ -30,6 +30,8 @@ extern unsigned char code_buf[4 * 512 * 1024]; int com_argc; char com_argv[MAX_ARGC][MAX_COMMAND_LENGTH]; +char * stage1; +char * stage2; static const char COMMAND[][COMMAND_NUM]= { @@ -289,7 +291,7 @@ int command_handle(char *buf) handle_gpio(3); break; case 20: - boot(STAGE1_FILE_PATH, STAGE2_FILE_PATH); + boot(stage1, stage2); break; case 26: handle_nmark(); diff --git a/usbboot/src/ingenic_usb.h b/usbboot/src/ingenic_usb.h index 547cbde..ec71b3d 100644 --- a/usbboot/src/ingenic_usb.h +++ b/usbboot/src/ingenic_usb.h @@ -55,9 +55,6 @@ #define PRODUCT_ID_4750 0x4750 #define PRODUCT_ID_4760 0x4760 -#define STAGE1_FILE_PATH (DATADIR "xburst_stage1.bin") -#define STAGE2_FILE_PATH (DATADIR "xburst_stage2.bin") - #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) struct ingenic_dev { diff --git a/usbboot/src/main.c b/usbboot/src/main.c index a2d7ead..5d58ef8 100644 --- a/usbboot/src/main.c +++ b/usbboot/src/main.c @@ -27,9 +27,13 @@ #include "ingenic_cfg.h" #define CONFIG_FILE_PATH (CFGDIR "usbboot.cfg") +#define STAGE1_FILE_PATH (DATADIR "xburst_stage1.bin") +#define STAGE2_FILE_PATH (DATADIR "xburst_stage2.bin") extern struct ingenic_dev ingenic_dev; extern struct hand hand; +extern char * stage1; +extern char * stage2; static void help(void) { @@ -39,6 +43,8 @@ static void help(void) " -c --command\t\t\tDirect run the commands, split by ';'\n" " \t\t\tNOTICE: the max commands count is 10!\n" " -f --configure\t\tconfigure file path\n" + " -1 --stage1\t\tstage1 file path\n" + " -2 --stage2\t\tstage2 file path\n" " \n\n" "Report bugs to .\n" ); @@ -54,6 +60,8 @@ static struct option opts[] = { { "version", 0, 0, 'v' }, { "command", 1, 0, 'c' }, { "configure", 1, 0, 'f' }, + { "stage1", 1, 0, '1' }, + { "stage2", 1, 0, '2' }, { 0, 0, 0, 0 } }; @@ -64,14 +72,17 @@ int main(int argc, char **argv) char com_buf[256] = {0}; char *cmdpt; char *cfgpath = CONFIG_FILE_PATH; + stage1 = STAGE1_FILE_PATH; + stage2 = STAGE2_FILE_PATH; printf("usbboot - Ingenic XBurst USB Boot Utility\n" "(c) 2009 Ingenic Semiconductor Inc., Qi Hardware Inc., Xiangfu Liu, Marek Lindner\n" "This program is Free Software and comes with ABSOLUTELY NO WARRANTY.\n\n"); + while(1) { int c, option_index = 0; - c = getopt_long(argc, argv, "hvc:f:", opts, + c = getopt_long(argc, argv, "hvc:f:1:2:", opts, &option_index); if (c == -1) break; @@ -90,6 +101,12 @@ int main(int argc, char **argv) case 'f': cfgpath = optarg; break; + case '1': + stage1 = optarg; + break; + case '2': + stage2 = optarg; + break; default: help(); exit(2);