mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2024-11-26 03:16:15 +02:00
accept-several-commond-once.patch
Signed-off-by: Xiangfu Liu <xiangfu.z@gmail.com>
This commit is contained in:
parent
bc5213da8f
commit
3d58da65ea
@ -90,7 +90,7 @@ out:
|
|||||||
void init_cfg()
|
void init_cfg()
|
||||||
{
|
{
|
||||||
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
|
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
|
||||||
printf("\n XBurst CPU not booted yet, boot it first!\n");
|
printf(" XBurst CPU not booted yet, boot it first!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,14 +191,14 @@ int error_check(unsigned char *org,unsigned char * obj,unsigned int size)
|
|||||||
int nand_markbad(struct nand_in *nand_in)
|
int nand_markbad(struct nand_in *nand_in)
|
||||||
{
|
{
|
||||||
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
|
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
|
||||||
printf("\n Device unboot! Boot it first!");
|
printf(" Device unboot! Boot it first!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
printf("\n mark bad block : %d ",nand_in->start);
|
printf(" mark bad block : %d\n",nand_in->start);
|
||||||
usb_send_data_address_to_ingenic(&ingenic_dev, nand_in->start);
|
usb_send_data_address_to_ingenic(&ingenic_dev, nand_in->start);
|
||||||
usb_ingenic_nand_ops(&ingenic_dev, NAND_MARK_BAD);
|
usb_ingenic_nand_ops(&ingenic_dev, NAND_MARK_BAD);
|
||||||
usb_read_data_from_ingenic(&ingenic_dev, ret, 8);
|
usb_read_data_from_ingenic(&ingenic_dev, ret, 8);
|
||||||
printf("\n Mark bad block at %d ",((ret[3] << 24) |
|
printf(" Mark bad block at %d\n",((ret[3] << 24) |
|
||||||
(ret[2] << 16) |
|
(ret[2] << 16) |
|
||||||
(ret[1] << 8) |
|
(ret[1] << 8) |
|
||||||
(ret[0] << 0)) / hand.nand_ppb);
|
(ret[0] << 0)) / hand.nand_ppb);
|
||||||
@ -212,9 +212,9 @@ int nand_program_check(struct nand_in *nand_in,
|
|||||||
unsigned int i, page_num, cur_page = -1;
|
unsigned int i, page_num, cur_page = -1;
|
||||||
unsigned short temp;
|
unsigned short temp;
|
||||||
|
|
||||||
printf("\n Writing NAND page %d len %d...", nand_in->start, nand_in->length);
|
printf(" Writing NAND page %d len %d...\n", nand_in->start, nand_in->length);
|
||||||
if (nand_in->length > (unsigned int)MAX_TRANSFER_SIZE) {
|
if (nand_in->length > (unsigned int)MAX_TRANSFER_SIZE) {
|
||||||
printf("\n Buffer size too long!");
|
printf(" Buffer size too long!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ int nand_program_check(struct nand_in *nand_in,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
|
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
|
||||||
printf("\n Device unboot! Boot it first!");
|
printf(" Device unboot! Boot it first!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ingenic_dev.file_buff = nand_in->buf;
|
ingenic_dev.file_buff = nand_in->buf;
|
||||||
@ -329,23 +329,23 @@ int nand_erase(struct nand_in *nand_in)
|
|||||||
start_blk = nand_in->start;
|
start_blk = nand_in->start;
|
||||||
blk_num = nand_in->length;
|
blk_num = nand_in->length;
|
||||||
if (start_blk > (unsigned int)NAND_MAX_BLK_NUM) {
|
if (start_blk > (unsigned int)NAND_MAX_BLK_NUM) {
|
||||||
printf("\n Start block number overflow!");
|
printf(" Start block number overflow!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (blk_num > (unsigned int)NAND_MAX_BLK_NUM) {
|
if (blk_num > (unsigned int)NAND_MAX_BLK_NUM) {
|
||||||
printf("\n Length block number overflow!");
|
printf(" Length block number overflow!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
|
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
|
||||||
printf("\n Device unboot! Boot it first!");
|
printf(" Device unboot! Boot it first!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nand_in->max_chip; i++) {
|
for (i = 0; i < nand_in->max_chip; i++) {
|
||||||
if ((nand_in->cs_map)[i]==0)
|
if ((nand_in->cs_map)[i]==0)
|
||||||
continue;
|
continue;
|
||||||
printf("\n Erasing No.%d device No.%d flash (start_blk %u blk_num %u)......",
|
printf(" Erasing No.%d device No.%d flash (start_blk %u blk_num %u)......\n",
|
||||||
nand_in->dev, i, start_blk, blk_num);
|
nand_in->dev, i, start_blk, blk_num);
|
||||||
|
|
||||||
usb_send_data_address_to_ingenic(&ingenic_dev, start_blk);
|
usb_send_data_address_to_ingenic(&ingenic_dev, start_blk);
|
||||||
@ -361,14 +361,14 @@ int nand_erase(struct nand_in *nand_in)
|
|||||||
(ret[2] << 16) |
|
(ret[2] << 16) |
|
||||||
(ret[1] << 8) |
|
(ret[1] << 8) |
|
||||||
(ret[0] << 0)) / hand.nand_ppb;
|
(ret[0] << 0)) / hand.nand_ppb;
|
||||||
printf("\n Return: %02x %02x %02x %02x %02x %02x %02x %02x (position %d)", ret[0], ret[1], ret[2], ret[3], ret[4], ret[5], ret[6], ret[7], end_block);
|
printf(" Return: %02x %02x %02x %02x %02x %02x %02x %02x (position %d)\n", ret[0], ret[1], ret[2], ret[3], ret[4], ret[5], ret[6], ret[7], end_block);
|
||||||
if (!hand.nand_force_erase) {
|
if (!hand.nand_force_erase) {
|
||||||
/* not force erase, show bad block infomation */
|
/* not force erase, show bad block infomation */
|
||||||
printf("\n There are marked bad blocks: %d ",
|
printf(" There are marked bad blocks: %d\n",
|
||||||
end_block - start_blk - blk_num );
|
end_block - start_blk - blk_num );
|
||||||
} else {
|
} else {
|
||||||
/* force erase, no bad block infomation can show */
|
/* force erase, no bad block infomation can show */
|
||||||
printf("\n Force erase, no bad block infomation!" );
|
printf(" Force erase, no bad block infomation!\n" );
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -407,7 +407,7 @@ int nand_program_file(struct nand_in *nand_in,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n Programing No.%d device, flen %d, start page %d...",nand_in->dev, flen, nand_in->start);
|
printf(" Programing No.%d device, flen %d, start page %d...\n",nand_in->dev, flen, nand_in->start);
|
||||||
n_in.start = nand_in->start / hand.nand_ppb;
|
n_in.start = nand_in->start / hand.nand_ppb;
|
||||||
if (nand_in->option == NO_OOB) {
|
if (nand_in->option == NO_OOB) {
|
||||||
if (flen % (hand.nand_ppb * hand.nand_ps) == 0)
|
if (flen % (hand.nand_ppb * hand.nand_ps) == 0)
|
||||||
@ -423,7 +423,7 @@ int nand_program_file(struct nand_in *nand_in,
|
|||||||
((hand.nand_ps + hand.nand_os) * hand.nand_ppb)
|
((hand.nand_ps + hand.nand_os) * hand.nand_ppb)
|
||||||
+ 1;
|
+ 1;
|
||||||
}
|
}
|
||||||
/* printf("\n length %d flen %d ", n_in.length, flen); */
|
/* printf(" length %d flen %d\n", n_in.length, flen); */
|
||||||
n_in.cs_map = nand_in->cs_map;
|
n_in.cs_map = nand_in->cs_map;
|
||||||
n_in.dev = nand_in->dev;
|
n_in.dev = nand_in->dev;
|
||||||
n_in.max_chip = nand_in->max_chip;
|
n_in.max_chip = nand_in->max_chip;
|
||||||
@ -435,9 +435,9 @@ int nand_program_file(struct nand_in *nand_in,
|
|||||||
transfer_size = (hand.nand_ppb * (hand.nand_ps + hand.nand_os));
|
transfer_size = (hand.nand_ppb * (hand.nand_ps + hand.nand_os));
|
||||||
m = flen / transfer_size;
|
m = flen / transfer_size;
|
||||||
j = flen % transfer_size;
|
j = flen % transfer_size;
|
||||||
printf("\n Size to send %d, transfer_size %d", flen, transfer_size);
|
printf(" Size to send %d, transfer_size %d\n", flen, transfer_size);
|
||||||
printf("\n Image type : %s", IMAGE_TYPE[nand_in->option]);
|
printf(" Image type : %s\n", IMAGE_TYPE[nand_in->option]);
|
||||||
printf("\n It will cause %d times buffer transfer.", j == 0 ? m : m + 1);
|
printf(" It will cause %d times buffer transfer.\n", j == 0 ? m : m + 1);
|
||||||
|
|
||||||
#ifdef CONFIG_NAND_OUT
|
#ifdef CONFIG_NAND_OUT
|
||||||
for (i = 0; i < nand_in->max_chip; i++)
|
for (i = 0; i < nand_in->max_chip; i++)
|
||||||
@ -465,7 +465,7 @@ int nand_program_file(struct nand_in *nand_in,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (start_page - nand_in->start > hand.nand_ppb)
|
if (start_page - nand_in->start > hand.nand_ppb)
|
||||||
printf("\n Skip a old bad block !");
|
printf(" Skip a old bad block !\n");
|
||||||
nand_in->start = start_page;
|
nand_in->start = start_page;
|
||||||
|
|
||||||
#ifdef CONFIG_NAND_OUT
|
#ifdef CONFIG_NAND_OUT
|
||||||
@ -515,7 +515,7 @@ int nand_program_file_planes(struct nand_in *nand_in,
|
|||||||
struct nand_out *nand_out,
|
struct nand_out *nand_out,
|
||||||
char *fname)
|
char *fname)
|
||||||
{
|
{
|
||||||
printf(" \n not implement yet !");
|
printf(" not implement yet !\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,18 +534,18 @@ int init_nand_in(void)
|
|||||||
int nand_prog(void)
|
int nand_prog(void)
|
||||||
{
|
{
|
||||||
char *image_file;
|
char *image_file;
|
||||||
char *help = "\n Usage: nprog (1) (2) (3) (4) (5)"
|
char *help = " Usage: nprog (1) (2) (3) (4) (5)\n"
|
||||||
"\n (1)\tstart page number"
|
" (1)\tstart page number\n"
|
||||||
"\n (2)\timage file name"
|
" (2)\timage file name\n"
|
||||||
"\n (3)\tdevice index number"
|
" (3)\tdevice index number\n"
|
||||||
"\n (4)\tflash index number"
|
" (4)\tflash index number\n"
|
||||||
"\n (5) image type must be:"
|
" (5) image type must be:\n"
|
||||||
"\n \t-n:\tno oob"
|
" \t-n:\tno oob\n"
|
||||||
"\n \t-o:\twith oob no ecc"
|
" \t-o:\twith oob no ecc\n"
|
||||||
"\n \t-e:\twith oob and ecc";
|
" \t-e:\twith oob and ecc\n";
|
||||||
|
|
||||||
if (com_argc != 6) {
|
if (com_argc != 6) {
|
||||||
printf("\n not enough argument.");
|
printf(" not enough argument.\n");
|
||||||
printf("%s", help);
|
printf("%s", help);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -571,7 +571,7 @@ int nand_prog(void)
|
|||||||
nand_program_file(&nand_in, &nand_out, image_file);
|
nand_program_file(&nand_in, &nand_out, image_file);
|
||||||
|
|
||||||
#ifdef CONFIG_NAND_OUT
|
#ifdef CONFIG_NAND_OUT
|
||||||
printf("\n Flash check result:");
|
printf(" Flash check result:\n");
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
printf(" %d", (nand_out.status)[i]);
|
printf(" %d", (nand_out.status)[i]);
|
||||||
@ -586,10 +586,10 @@ int nand_query(void)
|
|||||||
unsigned char csn;
|
unsigned char csn;
|
||||||
|
|
||||||
if (com_argc < 3) {
|
if (com_argc < 3) {
|
||||||
printf("\n Usage:");
|
printf(" Usage:\n");
|
||||||
printf(" nquery (1) (2) ");
|
printf(" nquery (1) (2) ");
|
||||||
printf("\n (1):device index number"
|
printf(" (1):device index number\n"
|
||||||
"\n (2):flash index number");
|
" (2):flash index number\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
init_nand_in();
|
init_nand_in();
|
||||||
@ -605,24 +605,24 @@ int nand_query(void)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
|
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
|
||||||
printf("\n Device unboot! Boot it first!");
|
printf(" Device unboot! Boot it first!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
csn = i;
|
csn = i;
|
||||||
printf("\n ID of No.%d device No.%d flash: ", nand_in.dev, csn);
|
printf(" ID of No.%d device No.%d flash: \n", nand_in.dev, csn);
|
||||||
|
|
||||||
unsigned short ops = ((csn << 4) & 0xff0) + NAND_QUERY;
|
unsigned short ops = ((csn << 4) & 0xff0) + NAND_QUERY;
|
||||||
usb_ingenic_nand_ops(&ingenic_dev, ops);
|
usb_ingenic_nand_ops(&ingenic_dev, ops);
|
||||||
usb_read_data_from_ingenic(&ingenic_dev, ret, 8);
|
usb_read_data_from_ingenic(&ingenic_dev, ret, 8);
|
||||||
printf("\n Vendor ID :0x%x ",(unsigned char)ret[0]);
|
printf(" Vendor ID :0x%x \n",(unsigned char)ret[0]);
|
||||||
printf("\n Product ID :0x%x ",(unsigned char)ret[1]);
|
printf(" Product ID :0x%x \n",(unsigned char)ret[1]);
|
||||||
printf("\n Chip ID :0x%x ",(unsigned char)ret[2]);
|
printf(" Chip ID :0x%x \n",(unsigned char)ret[2]);
|
||||||
printf("\n Page ID :0x%x ",(unsigned char)ret[3]);
|
printf(" Page ID :0x%x \n",(unsigned char)ret[3]);
|
||||||
printf("\n Plane ID :0x%x ",(unsigned char)ret[4]);
|
printf(" Plane ID :0x%x \n",(unsigned char)ret[4]);
|
||||||
|
|
||||||
usb_read_data_from_ingenic(&ingenic_dev, ret, 8);
|
usb_read_data_from_ingenic(&ingenic_dev, ret, 8);
|
||||||
printf("\n Operation status: Success!");
|
printf(" Operation status: Success!\n");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -635,18 +635,18 @@ int nand_read(int mode)
|
|||||||
unsigned short temp = 0;
|
unsigned short temp = 0;
|
||||||
|
|
||||||
if (com_argc < 5) {
|
if (com_argc < 5) {
|
||||||
printf("\n Usage:");
|
printf(" Usage:\n");
|
||||||
printf(" nread (1) (2) (3) (4) ");
|
printf(" nread (1) (2) (3) (4) ");
|
||||||
printf("\n 1:start page number"
|
printf(" 1:start page number\n"
|
||||||
"\n 2:length in byte"
|
" 2:length in byte\n"
|
||||||
"\n 3:device index number"
|
" 3:device index number\n"
|
||||||
"\n 4:flash index number ");
|
" 4:flash index number \n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
init_nand_in();
|
init_nand_in();
|
||||||
|
|
||||||
if (atoi(com_argv[4]) >= MAX_DEV_NUM) {
|
if (atoi(com_argv[4]) >= MAX_DEV_NUM) {
|
||||||
printf("\n Flash index number overflow!");
|
printf(" Flash index number overflow!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
(nand_in.cs_map)[atoi(com_argv[4])] = 1;
|
(nand_in.cs_map)[atoi(com_argv[4])] = 1;
|
||||||
@ -658,11 +658,11 @@ int nand_read(int mode)
|
|||||||
length = nand_in.length;
|
length = nand_in.length;
|
||||||
|
|
||||||
if (start_addr > NAND_MAX_PAGE_NUM || length > NAND_MAX_PAGE_NUM ) {
|
if (start_addr > NAND_MAX_PAGE_NUM || length > NAND_MAX_PAGE_NUM ) {
|
||||||
printf("\n Page number overflow!");
|
printf(" Page number overflow!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
|
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
|
||||||
printf("\n Device unboot! Boot it first!");
|
printf(" Device unboot! Boot it first!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for (i = 0; i < nand_in.max_chip; i++)
|
for (i = 0; i < nand_in.max_chip; i++)
|
||||||
@ -670,7 +670,7 @@ int nand_read(int mode)
|
|||||||
break;
|
break;
|
||||||
if (i >= nand_in.max_chip) return 1;
|
if (i >= nand_in.max_chip) return 1;
|
||||||
csn = i;
|
csn = i;
|
||||||
printf("\n Reading from No.%d device No.%d flash....",nand_in.dev,csn);
|
printf(" Reading from No.%d device No.%d flash....\n",nand_in.dev,csn);
|
||||||
|
|
||||||
page_num = length / hand.nand_ps +1;
|
page_num = length / hand.nand_ps +1;
|
||||||
|
|
||||||
@ -688,7 +688,7 @@ int nand_read(int mode)
|
|||||||
temp = ((NO_OOB<<12) & 0xf000) + ((csn<<4) & 0xff0) + NAND_READ_RAW;
|
temp = ((NO_OOB<<12) & 0xf000) + ((csn<<4) & 0xff0) + NAND_READ_RAW;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("\n unknow mode!");
|
printf(" unknow mode!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -698,12 +698,12 @@ int nand_read(int mode)
|
|||||||
|
|
||||||
for (j=0;j<length;j++)
|
for (j=0;j<length;j++)
|
||||||
{
|
{
|
||||||
if (j % 16 == 0) printf("\n 0x%08x :",j);
|
if (j % 16 == 0) printf(" 0x%08x :\n",j);
|
||||||
printf("%02x ",(nand_in.buf)[j]);
|
printf("%02x ",(nand_in.buf)[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
usb_read_data_from_ingenic(&ingenic_dev, ret, 8);
|
usb_read_data_from_ingenic(&ingenic_dev, ret, 8);
|
||||||
printf("\n Operation end position : %d ",
|
printf(" Operation end position : %d \n",
|
||||||
(ret[3]<<24)|(ret[2]<<16)|(ret[1]<<8)|(ret[0]<<0));
|
(ret[3]<<24)|(ret[2]<<16)|(ret[1]<<8)|(ret[0]<<0));
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -715,7 +715,7 @@ int debug_memory(int obj, unsigned int start, unsigned int size)
|
|||||||
|
|
||||||
tmp = usb_get_ingenic_cpu(&ingenic_dev);
|
tmp = usb_get_ingenic_cpu(&ingenic_dev);
|
||||||
if (tmp > 2) {
|
if (tmp > 2) {
|
||||||
printf("\n This command only run under UNBOOT state!");
|
printf(" This command only run under UNBOOT state!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -738,7 +738,7 @@ int debug_memory(int obj, unsigned int start, unsigned int size)
|
|||||||
else
|
else
|
||||||
hand.fw_args.size = size;
|
hand.fw_args.size = size;
|
||||||
|
|
||||||
printf("\n Now test memory from %x to %x: ",
|
printf(" Now test memory from %x to %x: \n",
|
||||||
start, start + hand.fw_args.size);
|
start, start + hand.fw_args.size);
|
||||||
|
|
||||||
if (load_file(&ingenic_dev, STAGE1_FILE_PATH) < 1)
|
if (load_file(&ingenic_dev, STAGE1_FILE_PATH) < 1)
|
||||||
@ -749,10 +749,10 @@ int debug_memory(int obj, unsigned int start, unsigned int size)
|
|||||||
usleep(100);
|
usleep(100);
|
||||||
usb_read_data_from_ingenic(&ingenic_dev, buffer, 8);
|
usb_read_data_from_ingenic(&ingenic_dev, buffer, 8);
|
||||||
if (buffer[0] != 0)
|
if (buffer[0] != 0)
|
||||||
printf("\n Test memory fail! Last error address is %x !",
|
printf(" Test memory fail! Last error address is %x !\n",
|
||||||
buffer[0]);
|
buffer[0]);
|
||||||
else
|
else
|
||||||
printf("\n Test memory pass!");
|
printf(" Test memory pass!\n");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -763,7 +763,7 @@ int debug_gpio(int obj, unsigned char ops, unsigned char pin)
|
|||||||
|
|
||||||
tmp = usb_get_ingenic_cpu(&ingenic_dev);
|
tmp = usb_get_ingenic_cpu(&ingenic_dev);
|
||||||
if (tmp > 2) {
|
if (tmp > 2) {
|
||||||
printf("\n This command only run under UNBOOT state!");
|
printf(" This command only run under UNBOOT state!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -772,7 +772,7 @@ int debug_gpio(int obj, unsigned char ops, unsigned char pin)
|
|||||||
tmp = 0;
|
tmp = 0;
|
||||||
hand.fw_args.cpu_id = 0x4740;
|
hand.fw_args.cpu_id = 0x4740;
|
||||||
if (pin > 124) {
|
if (pin > 124) {
|
||||||
printf("\n Jz4740 has 124 GPIO pin in all!");
|
printf(" Jz4740 has 124 GPIO pin in all!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -780,7 +780,7 @@ int debug_gpio(int obj, unsigned char ops, unsigned char pin)
|
|||||||
tmp = 0;
|
tmp = 0;
|
||||||
hand.fw_args.cpu_id = 0x4750;
|
hand.fw_args.cpu_id = 0x4750;
|
||||||
if (pin > 178) {
|
if (pin > 178) {
|
||||||
printf("\n Jz4750 has 178 GPIO pin in all!");
|
printf(" Jz4750 has 178 GPIO pin in all!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -790,9 +790,9 @@ int debug_gpio(int obj, unsigned char ops, unsigned char pin)
|
|||||||
hand.fw_args.pin_num = pin;
|
hand.fw_args.pin_num = pin;
|
||||||
|
|
||||||
if (ops == 2)
|
if (ops == 2)
|
||||||
printf("\n GPIO %d set!",pin);
|
printf(" GPIO %d set!\n",pin);
|
||||||
else
|
else
|
||||||
printf("\n GPIO %d clear!",pin);
|
printf(" GPIO %d clear!\n",pin);
|
||||||
|
|
||||||
if (load_file(&ingenic_dev, STAGE1_FILE_PATH) < 1)
|
if (load_file(&ingenic_dev, STAGE1_FILE_PATH) < 1)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -58,28 +58,28 @@ static const char COMMAND[][COMMAND_NUM]=
|
|||||||
|
|
||||||
static int handle_help(void)
|
static int handle_help(void)
|
||||||
{
|
{
|
||||||
printf("\n command support in current version:"
|
printf(" command support in current version:\n"
|
||||||
"\n help print this help;"
|
" help print this help;\n"
|
||||||
"\n boot boot device and make it in stage2;"
|
" boot boot device and make it in stage2;\n"
|
||||||
"\n list show current device number can connect;"
|
" list show current device number can connect;\n"
|
||||||
"\n fconfig set USB Boot config file;"
|
" fconfig set USB Boot config file;\n"
|
||||||
"\n nquery query NAND flash info;"
|
" nquery query NAND flash info;\n"
|
||||||
"\n nread read NAND flash data with checking bad block and ECC;"
|
" nread read NAND flash data with checking bad block and ECC;\n"
|
||||||
"\n nreadraw read NAND flash data without checking bad block and ECC;"
|
" nreadraw read NAND flash data without checking bad block and ECC;\n"
|
||||||
"\n nreadoob read NAND flash oob without checking bad block and ECC;"
|
" nreadoob read NAND flash oob without checking bad block and ECC;\n"
|
||||||
"\n nerase erase NAND flash;"
|
" nerase erase NAND flash;\n"
|
||||||
"\n nprog program NAND flash with data and ECC;"
|
" nprog program NAND flash with data and ECC;\n"
|
||||||
"\n nmark mark a bad block in NAND flash;"
|
" nmark mark a bad block in NAND flash;\n"
|
||||||
"\n go execute program in SDRAM;"
|
" go execute program in SDRAM;\n"
|
||||||
"\n version show current USB Boot software version;"
|
" version show current USB Boot software version;\n"
|
||||||
"\n exit quit from telnet session;"
|
" exit quit from telnet session;\n"
|
||||||
"\n readnand read data from nand flash and store to SDRAM;"
|
" readnand read data from nand flash and store to SDRAM;\n"
|
||||||
"\n load load file data to SDRAM;"
|
" load load file data to SDRAM;\n"
|
||||||
"\n run run command script in file;"
|
" run run command script in file;\n"
|
||||||
"\n memtest do SDRAM test;"
|
" memtest do SDRAM test;\n"
|
||||||
"\n gpios let one GPIO to high level;"
|
" gpios let one GPIO to high level;\n"
|
||||||
"\n gpioc let one GPIO to low level;");
|
" gpioc let one GPIO to low level;\n");
|
||||||
/* printf("\n nmake read all data from nand flash and store to file(experimental);"); */
|
/* printf(" nmake read all data from nand flash and store to file(experimental);\n"); */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ unsigned int hex2dec(char *s)
|
|||||||
|
|
||||||
static int handle_version(void)
|
static int handle_version(void)
|
||||||
{
|
{
|
||||||
printf("\n USB Boot Software current version: %s", INFLASH_VERSION);
|
printf(" USB Boot Software current version: %s\n", INFLASH_VERSION);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,12 +110,12 @@ static int handle_version(void)
|
|||||||
int handle_nerase(void)
|
int handle_nerase(void)
|
||||||
{
|
{
|
||||||
if (com_argc < 5) {
|
if (com_argc < 5) {
|
||||||
printf("\n Usage:");
|
printf(" Usage:\n");
|
||||||
printf(" nerase (1) (2) (3) (4) ");
|
printf(" nerase (1) (2) (3) (4) ");
|
||||||
printf("\n 1:start block number"
|
printf(" 1:start block number\n"
|
||||||
"\n 2:block length"
|
" 2:block length\n"
|
||||||
"\n 3:device index number"
|
" 3:device index number\n"
|
||||||
"\n 4:flash chip index number");
|
" 4:flash chip index number\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ int handle_nerase(void)
|
|||||||
nand_in.length = atoi(com_argv[2]);
|
nand_in.length = atoi(com_argv[2]);
|
||||||
nand_in.dev = atoi(com_argv[3]);
|
nand_in.dev = atoi(com_argv[3]);
|
||||||
if (atoi(com_argv[4]) >= MAX_DEV_NUM) {
|
if (atoi(com_argv[4]) >= MAX_DEV_NUM) {
|
||||||
printf("\n Flash index number overflow!");
|
printf(" Flash index number overflow!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
(nand_in.cs_map)[atoi(com_argv[4])] = 1;
|
(nand_in.cs_map)[atoi(com_argv[4])] = 1;
|
||||||
@ -140,11 +140,11 @@ int handle_nmark(void)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (com_argc < 4) {
|
if (com_argc < 4) {
|
||||||
printf("\n Usage:");
|
printf(" Usage:\n");
|
||||||
printf(" nerase (1) (2) (3) ");
|
printf(" nerase (1) (2) (3) ");
|
||||||
printf("\n 1:bad block number"
|
printf(" 1:bad block number\n"
|
||||||
"\n 2:device index number"
|
" 2:device index number\n"
|
||||||
"\n 3:flash chip index number");
|
" 3:flash chip index number\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
init_nand_in();
|
init_nand_in();
|
||||||
@ -153,7 +153,7 @@ int handle_nmark(void)
|
|||||||
nand_in.dev = atoi(com_argv[2]);
|
nand_in.dev = atoi(com_argv[2]);
|
||||||
|
|
||||||
if (atoi(com_argv[3])>=MAX_DEV_NUM) {
|
if (atoi(com_argv[3])>=MAX_DEV_NUM) {
|
||||||
printf("\n Flash index number overflow!");
|
printf(" Flash index number overflow!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
(nand_in.cs_map)[atoi(com_argv[3])] = 1;
|
(nand_in.cs_map)[atoi(com_argv[3])] = 1;
|
||||||
@ -167,11 +167,11 @@ int handle_memtest(void)
|
|||||||
unsigned int start, size;
|
unsigned int start, size;
|
||||||
if (com_argc != 2 && com_argc != 4)
|
if (com_argc != 2 && com_argc != 4)
|
||||||
{
|
{
|
||||||
printf("\n Usage:");
|
printf(" Usage:\n");
|
||||||
printf(" memtest (1) [2] [3] ");
|
printf(" memtest (1) [2] [3] ");
|
||||||
printf("\n 1:device index number"
|
printf(" 1:device index number\n"
|
||||||
"\n 2:SDRAM start address"
|
" 2:SDRAM start address\n"
|
||||||
"\n 3:test size");
|
" 3:test size\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,10 +194,10 @@ int handle_memtest(void)
|
|||||||
int handle_gpio(int mode)
|
int handle_gpio(int mode)
|
||||||
{
|
{
|
||||||
if (com_argc < 3) {
|
if (com_argc < 3) {
|
||||||
printf("\n Usage:"
|
printf(" Usage:\n"
|
||||||
" gpios (1) (2) "
|
" gpios (1) (2) "
|
||||||
"\n 1:GPIO pin number"
|
" 1:GPIO pin number\n"
|
||||||
"\n 2:device index number");
|
" 2:device index number\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +274,7 @@ int command_handle(char *buf)
|
|||||||
handle_version();
|
handle_version();
|
||||||
break;
|
break;
|
||||||
case 16: /* exit */
|
case 16: /* exit */
|
||||||
printf("\n exiting inflash software\n");
|
printf(" exiting inflash software\n");
|
||||||
return -1; /* return -1 to break the main.c while
|
return -1; /* return -1 to break the main.c while
|
||||||
* then run usb_ingenic_cleanup*/
|
* then run usb_ingenic_cleanup*/
|
||||||
case 18:
|
case 18:
|
||||||
@ -293,7 +293,7 @@ int command_handle(char *buf)
|
|||||||
handle_memtest();
|
handle_memtest();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("\n command not support or input error!\n");
|
printf(" command not support or input error!\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,56 +52,56 @@ int check_dump_cfg(struct hand *hand)
|
|||||||
printf("Now checking whether all configure args valid:");
|
printf("Now checking whether all configure args valid:");
|
||||||
/* check PLL */
|
/* check PLL */
|
||||||
if (hand->fw_args.ext_clk > 27 || hand->fw_args.ext_clk < 12) {
|
if (hand->fw_args.ext_clk > 27 || hand->fw_args.ext_clk < 12) {
|
||||||
printf("\n EXTCLK setting invalid!");
|
printf(" EXTCLK setting invalid!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (hand->fw_args.phm_div > 32 || hand->fw_args.ext_clk < 2) {
|
if (hand->fw_args.phm_div > 32 || hand->fw_args.ext_clk < 2) {
|
||||||
printf("\n PHMDIV setting invalid!");
|
printf(" PHMDIV setting invalid!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ((hand->fw_args.cpu_speed * hand->fw_args.ext_clk ) % 12 != 0) {
|
if ((hand->fw_args.cpu_speed * hand->fw_args.ext_clk ) % 12 != 0) {
|
||||||
printf("\n CPUSPEED setting invalid!");
|
printf(" CPUSPEED setting invalid!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check SDRAM */
|
/* check SDRAM */
|
||||||
if (hand->fw_args.bus_width > 1 ) {
|
if (hand->fw_args.bus_width > 1 ) {
|
||||||
printf("\n SDRAMWIDTH setting invalid!");
|
printf(" SDRAMWIDTH setting invalid!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (hand->fw_args.bank_num > 1 ) {
|
if (hand->fw_args.bank_num > 1 ) {
|
||||||
printf("\n BANKNUM setting invalid!");
|
printf(" BANKNUM setting invalid!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (hand->fw_args.row_addr > 13 && hand->fw_args.row_addr < 11 ) {
|
if (hand->fw_args.row_addr > 13 && hand->fw_args.row_addr < 11 ) {
|
||||||
printf("\n ROWADDR setting invalid!");
|
printf(" ROWADDR setting invalid!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (hand->fw_args.col_addr > 13 && hand->fw_args.col_addr < 11 ) {
|
if (hand->fw_args.col_addr > 13 && hand->fw_args.col_addr < 11 ) {
|
||||||
printf("\n COLADDR setting invalid!");
|
printf(" COLADDR setting invalid!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check NAND */
|
/* check NAND */
|
||||||
if ( hand->nand_ps < 2048 && hand->nand_os > 16 ) {
|
if ( hand->nand_ps < 2048 && hand->nand_os > 16 ) {
|
||||||
printf("\n PAGESIZE or OOBSIZE setting invalid!");
|
printf(" PAGESIZE or OOBSIZE setting invalid!\n");
|
||||||
printf("\n PAGESIZE is %d,\t OOBSIZE is %d",
|
printf(" PAGESIZE is %d,\t OOBSIZE is %d\n",
|
||||||
hand->nand_ps, hand->nand_os);
|
hand->nand_ps, hand->nand_os);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ( hand->nand_ps < 2048 && hand->nand_ppb > 32 ) {
|
if ( hand->nand_ps < 2048 && hand->nand_ppb > 32 ) {
|
||||||
printf("\n PAGESIZE or PAGEPERBLOCK setting invalid!");
|
printf(" PAGESIZE or PAGEPERBLOCK setting invalid!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( hand->nand_ps > 512 && hand->nand_os <= 16 ) {
|
if ( hand->nand_ps > 512 && hand->nand_os <= 16 ) {
|
||||||
printf("\n PAGESIZE or OOBSIZE setting invalid!");
|
printf(" PAGESIZE or OOBSIZE setting invalid!\n");
|
||||||
printf("\n PAGESIZE is %d,\t OOBSIZE is %d",
|
printf(" PAGESIZE is %d,\t OOBSIZE is %d\n",
|
||||||
hand->nand_ps, hand->nand_os);
|
hand->nand_ps, hand->nand_os);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ( hand->nand_ps > 512 && hand->nand_ppb < 64 ) {
|
if ( hand->nand_ps > 512 && hand->nand_ppb < 64 ) {
|
||||||
printf("\n PAGESIZE or PAGEPERBLOCK setting invalid!");
|
printf(" PAGESIZE or PAGEPERBLOCK setting invalid!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
printf(" YES\n");
|
printf(" YES\n");
|
||||||
|
@ -48,6 +48,7 @@ int main(int argc, char **argv)
|
|||||||
int command = 0;
|
int command = 0;
|
||||||
char *cptr;
|
char *cptr;
|
||||||
char com_buf[256] = {0};
|
char com_buf[256] = {0};
|
||||||
|
char *cmdpt;
|
||||||
|
|
||||||
printf("inflash - Ingenic XBurst USB Boot Utility\n"
|
printf("inflash - Ingenic XBurst USB Boot Utility\n"
|
||||||
"(c) 2009 Ingenic Semiconductor Inc., Qi Hardware Inc., Xiangfu Liu, Marek Lindner\n"
|
"(c) 2009 Ingenic Semiconductor Inc., Qi Hardware Inc., Xiangfu Liu, Marek Lindner\n"
|
||||||
@ -69,7 +70,7 @@ int main(int argc, char **argv)
|
|||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
case 'c':
|
case 'c':
|
||||||
command = 1;
|
command = 1;
|
||||||
strcpy(com_buf, optarg);
|
cmdpt = optarg;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
help();
|
help();
|
||||||
@ -89,13 +90,23 @@ int main(int argc, char **argv)
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
if (command) { /* direct run command */
|
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);
|
command_handle(com_buf);
|
||||||
printf("\n");
|
|
||||||
|
while((p = strtok(NULL,delim))) {
|
||||||
|
strcpy(com_buf, p);
|
||||||
|
printf(" Execute command: %s \n",com_buf);
|
||||||
|
command_handle(com_buf);
|
||||||
|
}
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
printf("\ninflash :> ");
|
printf("inflash :> ");
|
||||||
cptr = fgets(com_buf, 256, stdin);
|
cptr = fgets(com_buf, 256, stdin);
|
||||||
if (cptr == NULL)
|
if (cptr == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user