mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2024-12-22 23:31:10 +02:00
[usbboot] fix if there is space at the end of command casue error
This commit is contained in:
parent
3272119164
commit
c1873f1c5e
@ -568,7 +568,7 @@ int nand_prog(void)
|
||||
" \t-e:\twith oob and ecc\n";
|
||||
|
||||
if (com_argc != 6) {
|
||||
printf(" not enough argument.\n");
|
||||
printf(" arguments count error.\n");
|
||||
printf("%s", help);
|
||||
return 0;
|
||||
}
|
||||
@ -578,6 +578,7 @@ int nand_prog(void)
|
||||
nand_in.start = atoi(com_argv[1]);
|
||||
image_file = com_argv[2];
|
||||
nand_in.dev = atoi(com_argv[3]);
|
||||
|
||||
(nand_in.cs_map)[atoi(com_argv[4])] = 1;
|
||||
if (!strcmp(com_argv[5], "-e"))
|
||||
nand_in.option = OOB_ECC;
|
||||
|
@ -223,39 +223,22 @@ int handle_load(void)
|
||||
|
||||
int command_interpret(char * com_buf)
|
||||
{
|
||||
char *buf = com_buf;
|
||||
int k, L, i = 0, j = 0;
|
||||
|
||||
L = (int)strlen(buf);
|
||||
buf[L]=' ';
|
||||
|
||||
if (buf[0] == '\n')
|
||||
if(com_buf[0] == '\n')
|
||||
return 0;
|
||||
|
||||
for (k = 0; k <= L; k++) {
|
||||
if (*buf == ' ' || *buf == '\n') {
|
||||
while ( *(++buf) == ' ' );
|
||||
com_argv[i][j] = '\0';
|
||||
i++;
|
||||
if (i > MAX_ARGC)
|
||||
return COMMAND_NUM + 1;
|
||||
j = 0;
|
||||
continue;
|
||||
} else {
|
||||
com_argv[i][j] = *buf;
|
||||
j++;
|
||||
if (j > MAX_COMMAND_LENGTH)
|
||||
return COMMAND_NUM + 1;
|
||||
}
|
||||
buf++;
|
||||
}
|
||||
com_argc = 0;
|
||||
char *p = strtok(com_buf, "\n ");
|
||||
strcpy(com_argv[com_argc++], p);
|
||||
|
||||
com_argc = i;
|
||||
while(p = strtok(NULL, "\n "))
|
||||
strcpy(com_argv[com_argc++], p);
|
||||
|
||||
for (i = 1; i <= COMMAND_NUM; i++)
|
||||
if (!strcmp(COMMAND[i], com_argv[0]))
|
||||
return i;
|
||||
return COMMAND_NUM + 1;
|
||||
int loop = 0;
|
||||
for (loop = 1; loop <= COMMAND_NUM; loop++)
|
||||
if (!strcmp(COMMAND[loop], com_argv[0]))
|
||||
return loop;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int command_handle(char *buf)
|
||||
@ -317,6 +300,7 @@ int command_handle(char *buf)
|
||||
case 29:
|
||||
handle_memtest();
|
||||
break;
|
||||
case -1:
|
||||
default:
|
||||
printf(" command not support or input error!\n");
|
||||
break;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright(C) 2009 Qi Hardware Inc.,
|
||||
* Authors: Xiangfu Liu <xiangfu@qi-hardware.com>
|
||||
* Authors: Xiangfu Liu <xiangfu@sharism.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -37,9 +37,10 @@ static void help(void)
|
||||
" -h --help\t\t\tPrint this help message\n"
|
||||
" -v --version\t\t\tPrint the version number\n"
|
||||
" -c --command\t\t\tDirect run the commands, split by ';'\n"
|
||||
" -f --configure\t\t\tconfigure file path\n"
|
||||
" \t\t\tNOTICE: the max commands count is 10!\n"
|
||||
" -f --configure\t\tconfigure file path\n"
|
||||
" <run without options to enter commands via usbboot prompt>\n\n"
|
||||
"Report bugs to <xiangfu@qi-hardware.com>.\n"
|
||||
"Report bugs to <xiangfu@sharism.cc>.\n"
|
||||
);
|
||||
}
|
||||
|
||||
@ -107,17 +108,14 @@ int main(int argc, char **argv)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (command) { /* direct run command */
|
||||
char *delim=";";
|
||||
char *p;
|
||||
p = strtok(cmdpt, delim);
|
||||
strcpy(com_buf, p);
|
||||
printf(" Execute command: %s \n",com_buf);
|
||||
command_handle(com_buf);
|
||||
char *p[10];
|
||||
int i, loop = 0;
|
||||
p[loop++] = strtok(cmdpt, ";");
|
||||
while(p[loop++] = strtok(NULL, ";"));
|
||||
|
||||
while((p = strtok(NULL,delim))) {
|
||||
strcpy(com_buf, p);
|
||||
printf(" Execute command: %s \n",com_buf);
|
||||
command_handle(com_buf);
|
||||
for(i = 0; i < loop - 1 && i < 10; i++) {
|
||||
printf(" Execute command: %s \n",p[i]);
|
||||
command_handle(p[i]);
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user