1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2024-12-29 21:17:22 +02:00

fic then input '\n' there is a error message

This commit is contained in:
xiangfu 2009-06-26 03:38:32 +00:00
parent 4827a1b2c8
commit de31ff5403
3 changed files with 154 additions and 6 deletions

View File

@ -702,3 +702,97 @@ int nand_read(int mode)
return 1;
}
int debug_memory(int obj, unsigned int start, unsigned int size)
{
unsigned int buffer[8],tmp;
tmp = usb_get_ingenic_cpu(&ingenic_dev);
if (tmp > 2) {
printf("\n This command only run under UNBOOT state!");
return -1;
}
switch (tmp) {
case 1:
tmp = 0;
hand.fw_args.cpu_id = 0x4740;
break;
case 2:
tmp = 0;
hand.fw_args.cpu_id = 0x4750;
break;
}
hand.fw_args.debug_ops = 1;/* tell device it's memory debug */
hand.fw_args.start = start;
if (size == 0)
hand.fw_args.size = total_size;
else
hand.fw_args.size = size;
printf("\n Now test memory from %x to %x: ",
start, start + hand.fw_args.size);
if (load_file(&ingenic_dev, STAGE1_FILE_PATH) < 1)
return -1;
if (usb_ingenic_upload(&ingenic_dev, 1) < 1)
return -1;
usleep(100);
usb_read_data_from_ingenic(&ingenic_dev, buffer, 8);
if (buffer[0] != 0)
printf("\n Test memory fail! Last error address is %x !",
buffer[0]);
else
printf("\n Test memory pass!");
return 1;
}
int debug_gpio(int obj, unsigned char ops, unsigned char pin)
{
unsigned int tmp;
tmp = usb_get_ingenic_cpu(&ingenic_dev);
if (tmp > 2) {
printf("\n This command only run under UNBOOT state!");
return -1;
}
switch (tmp) {
case 1:
tmp = 0;
hand.fw_args.cpu_id = 0x4740;
if (pin > 124) {
printf("\n Jz4740 has 124 GPIO pin in all!");
return -1;
}
break;
case 2:
tmp = 0;
hand.fw_args.cpu_id = 0x4750;
if (pin > 178) {
printf("\n Jz4750 has 178 GPIO pin in all!");
return -1;
}
break;
}
hand.fw_args.debug_ops = ops;/* tell device it's memory debug */
hand.fw_args.pin_num = pin;
if (ops == 2)
printf("\n GPIO %d set!",pin);
else
printf("\n GPIO %d clear!",pin);
if (load_file(&ingenic_dev, STAGE1_FILE_PATH) < 1)
return -1;
if (usb_ingenic_upload(&ingenic_dev, 1) < 1)
return -1;
return 0;
}

View File

@ -18,8 +18,10 @@
extern struct nand_in nand_in;
int com_argc;
char com_argv[MAX_ARGC][MAX_COMMAND_LENGTH];
const char HEX_NUM[17]={'0','1','2','3','4','5','6','7','8','9',
'a','b','c','d','e','f',' '};
static const char COMMAND[][30]=
static const char COMMAND[][COMMAND_NUM]=
{
"",
"query",
@ -81,6 +83,23 @@ static int handle_help(void)
return 1;
}
unsigned int hex2dec(char *s)
{
int i,L=(int)strlen(s),j;
unsigned int temp=0;
if (L>8) L=8;
for (i = 0; i < L; i++) {
for (j = 0; j < 16; j++)
if (s[i] == HEX_NUM[j])
break;
if (j == 16)
return 0;
temp = temp * 16 + j;
}
return temp;
}
static int handle_version(void)
{
printf("\n USB Boot Software current version: %s", INFLASH_VERSION);
@ -143,6 +162,35 @@ int handle_nmark(void)
return 1;
}
int handle_memtest(void)
{
unsigned int start, size;
if (com_argc != 2 && com_argc != 4)
{
printf("\n Usage:");
printf(" memtest (1) [2] [3] ");
printf("\n 1:device index number"
"\n 2:SDRAM start address"
"\n 3:test size ");
return -1;
}
if (com_argc == 4) {
if (com_argv[2][0]=='0'&&com_argv[2][1]=='x')
start=hex2dec(&com_argv[2][2]);
else start=atol(com_argv[2]);
if (com_argv[3][0]=='0'&&com_argv[3][1]=='x')
size = hex2dec(&com_argv[3][2]);
else size = atol(com_argv[3]);
} else {
start = 0;
size = 0;
}
debug_memory(atoi(com_argv[1]), start, size);
return 1;
}
int command_interpret(char * com_buf)
{
char *buf = com_buf;
@ -150,6 +198,10 @@ int command_interpret(char * com_buf)
L = (int)strlen(buf);
buf[L]=' ';
if (buf[0] == '\n')
return 0;
for (k = 0; k <= L; k++) {
if (*buf == ' ' || *buf == '\n') {
while ( *(++buf) == ' ' );
@ -180,10 +232,9 @@ int command_handle(char *buf)
{
int cmd = command_interpret(buf); /* get the command index */
if (!cmd)
return -1;
switch (cmd) {
case 0:
break;
case 6:
nand_query();
break;
@ -218,6 +269,9 @@ int command_handle(char *buf)
case 26:
handle_nmark();
break;
case 29:
handle_memtest();
break;
default:
printf("\n command not support or input error!");
break;

View File

@ -95,9 +95,9 @@ int main(int argc, char **argv)
}
while (1) {
printf("\ninflash :> ");
printf("inflash :> ");
cptr = fgets(com_buf, 256, stdin);
if (cptr == NULL)
if (cptr == NULL)
continue;
if (command_handle(com_buf) == -1 )