1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2024-11-01 10:22:48 +02:00

cleanup output, fix not exit when error

This commit is contained in:
Xiangfu Liu 2009-09-30 23:47:29 -04:00 committed by xiangfu
parent 3e030a84f8
commit 5fd478b936
6 changed files with 80 additions and 80 deletions

View File

@ -222,12 +222,14 @@ int nand_program_check(struct nand_in *nand_in,
unsigned int *start_page)
{
unsigned int i, page_num, cur_page = -1;
unsigned int start_addr;
unsigned short temp;
int status = -1;
printf(" Writing NAND page %d len %d...\n", nand_in->start, nand_in->length);
if (nand_in->length > (unsigned int)MAX_TRANSFER_SIZE) {
printf(" Buffer size too long!\n");
return -1;
goto err;
}
#ifdef CONFIG_NAND_OUT
@ -237,15 +239,17 @@ int nand_program_check(struct nand_in *nand_in,
(nand_out->status)[i] = 0; /* set all status to fail */
#endif
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
int cpu = usb_get_ingenic_cpu(&ingenic_dev);
if (cpu != BOOT4740 && cpu != BOOT4750) {
printf(" Device unboot! Boot it first!\n");
return -1;
goto err;
}
ingenic_dev.file_buff = nand_in->buf;
ingenic_dev.file_len = nand_in->length;
usb_send_data_to_ingenic(&ingenic_dev);
for (i = 0; i < nand_in->max_chip; i++) {
if ((nand_in->cs_map)[i]==0)
if ((nand_in->cs_map)[i] == 0)
continue;
if (nand_in->option == NO_OOB) {
page_num = nand_in->length / hand.nand_ps;
@ -259,50 +263,47 @@ int nand_program_check(struct nand_in *nand_in,
}
temp = ((nand_in->option << 12) & 0xf000) +
((i<<4) & 0xff0) + NAND_PROGRAM;
usb_send_data_address_to_ingenic(&ingenic_dev, nand_in->start);
usb_send_data_length_to_ingenic(&ingenic_dev, page_num);
usb_ingenic_nand_ops(&ingenic_dev, temp);
if (usb_send_data_address_to_ingenic(&ingenic_dev, nand_in->start) != 1)
goto err;
if (usb_send_data_length_to_ingenic(&ingenic_dev, page_num) != 1)
goto err;
if (usb_ingenic_nand_ops(&ingenic_dev, temp) != 1)
goto err;
if (usb_read_data_from_ingenic(&ingenic_dev, ret, 8) != 1)
goto err;
usb_read_data_from_ingenic(&ingenic_dev, ret, 8);
printf(" Finish! (len %d start_page %d page_num %d)\n",
nand_in->length, nand_in->start, page_num);
usb_send_data_address_to_ingenic(&ingenic_dev, nand_in->start);
/* Read back to check! */
usb_send_data_address_to_ingenic(&ingenic_dev, nand_in->start);
usb_send_data_length_to_ingenic(&ingenic_dev, page_num);
switch (nand_in->option) {
case OOB_ECC:
temp = ((OOB_ECC << 12) & 0xf000) +
((i << 4) & 0xff0) + NAND_READ;
usb_ingenic_nand_ops(&ingenic_dev, temp);
printf(" Checking %d bytes...", nand_in->length);
usb_read_data_from_ingenic(&ingenic_dev, check_buf,
page_num * (hand.nand_ps + hand.nand_os));
usb_read_data_from_ingenic(&ingenic_dev, ret, 8);
start_addr = page_num * (hand.nand_ps + hand.nand_os);
break;
case OOB_NO_ECC: /* do not support data verify */
temp = ((OOB_NO_ECC << 12) & 0xf000) +
((i << 4) & 0xff0) + NAND_READ;
usb_ingenic_nand_ops(&ingenic_dev, temp);
printf(" Checking %d bytes...", nand_in->length);
usb_read_data_from_ingenic(&ingenic_dev, check_buf,
page_num * (hand.nand_ps + hand.nand_os));
usb_read_data_from_ingenic(&ingenic_dev, ret, 8);
start_addr = page_num * (hand.nand_ps + hand.nand_os);
break;
case NO_OOB:
temp = ((NO_OOB << 12) & 0xf000) +
((i << 4) & 0xff0) + NAND_READ;
usb_ingenic_nand_ops(&ingenic_dev, temp);
printf(" Checking %d bytes...", nand_in->length);
usb_read_data_from_ingenic(&ingenic_dev, check_buf,
page_num * hand.nand_ps);
usb_read_data_from_ingenic(&ingenic_dev, ret, 8);
start_addr = page_num * hand.nand_ps;
break;
default:
;
}
printf(" Checking %d bytes...", nand_in->length);
usb_ingenic_nand_ops(&ingenic_dev, temp);
usb_read_data_from_ingenic(&ingenic_dev, check_buf, start_addr);
usb_read_data_from_ingenic(&ingenic_dev, ret, 8);
cur_page = (ret[3] << 24) | (ret[2] << 16) | (ret[1] << 8) |
(ret[0] << 0);
@ -329,11 +330,14 @@ int nand_program_check(struct nand_in *nand_in,
nand_markbad(&bad);
}
printf(" End at Page: %d\n",cur_page);
printf(" End at Page: %d\n", cur_page);
}
*start_page = cur_page;
return 0;
status = 1;
err:
return status;
}
int nand_erase(struct nand_in *nand_in)
@ -551,6 +555,7 @@ int init_nand_in(void)
int nand_prog(void)
{
int status = -1;
char *image_file;
char *help = " Usage: nprog (1) (2) (3) (4) (5)\n"
" (1)\tstart page number\n"
@ -595,7 +600,9 @@ int nand_prog(void)
printf(" %d", (nand_out.status)[i]);
#endif
return 1;
status = 1;
err:
return status;
}
int nand_query(void)

View File

@ -166,12 +166,12 @@ int usb_get_ingenic_cpu(struct ingenic_dev *ingenic_dev)
ingenic_dev->cpu_info_buff[8] = '\0';
printf(" CPU data: %s\n", ingenic_dev->cpu_info_buff);
if (!strcmp(ingenic_dev->cpu_info_buff,"JZ4740V1")) return 1;
if (!strcmp(ingenic_dev->cpu_info_buff,"JZ4750V1")) return 2;
if (!strcmp(ingenic_dev->cpu_info_buff,"Boot4740")) return 3;
if (!strcmp(ingenic_dev->cpu_info_buff,"Boot4750")) return 4;
if (!strcmp(ingenic_dev->cpu_info_buff,"JZ4740V1")) return JZ4740V1;
if (!strcmp(ingenic_dev->cpu_info_buff,"JZ4750V1")) return JZ4750V1;
if (!strcmp(ingenic_dev->cpu_info_buff,"Boot4740")) return BOOT4740;
if (!strcmp(ingenic_dev->cpu_info_buff,"Boot4750")) return BOOT4750;
return 0;
return -1;
}
int usb_ingenic_flush_cache(struct ingenic_dev *ingenic_dev)

View File

@ -37,6 +37,11 @@
#define VR_CONFIGRATION 0x09
#define VR_GET_NUM 0x0a
#define JZ4740V1 1
#define JZ4750V1 2
#define BOOT4740 3
#define BOOT4750 4
#define STAGE_ADDR_MSB(addr) ((addr) >> 16)
#define STAGE_ADDR_LSB(addr) ((addr) & 0xffff)
@ -73,4 +78,3 @@ int usb_ingenic_nand_ops(struct ingenic_dev *ingenic_dev, int ops);
int usb_read_data_from_ingenic(struct ingenic_dev *ingenic_dev,unsigned char *buff, unsigned int len);
#endif /* __INGENIC_USB_H__ */

View File

@ -83,13 +83,6 @@ void config_hand()
Hand.nand_eccpos=hand_p->nand_eccpos;
Hand.nand_bbpos=hand_p->nand_bbpos;
Hand.nand_bbpage=hand_p->nand_bbpage;
// memcpy( &Hand.fw_args, (unsigned char *)(start_addr + 0x8), 32 );
// serial_putc(Hand.nand_eccpos + 48);
// serial_putc(Hand.nand_bbpos + 48);
// serial_putc(Hand.nand_bbpage + 48);
/* dprintf("\n Hand : bw %d rc %d ps %d ppb %d erase %d pn %d os %d", */
/* Hand.nand_bw,Hand.nand_rc,Hand.nand_ps,Hand.nand_ppb,Hand.nand_force_erase,Hand.nand_pn,Hand.nand_os); */
serial_put_hex(Hand.fw_args.cpu_id);
serial_put_hex(Hand.fw_args.ext_clk);
#endif
@ -98,11 +91,12 @@ void config_hand()
int GET_CUP_INFO_Handle()
{
char temp1[8]="Boot4740",temp2[8]="Boot4750";
dprintf("\n GET_CPU_INFO!");
if ( Hand.fw_args.cpu_id == 0x4740 )
HW_SendPKT(0,temp1,8);
dprintf("\n GET_CPU_INFO:\t");
serial_put_hex(Hand.fw_args.cpu_id);
if (Hand.fw_args.cpu_id == 0x4740)
HW_SendPKT(0, temp1, 8);
else
HW_SendPKT(0,temp2,8);
HW_SendPKT(0, temp2, 8);
udc_state = IDLE;
return ERR_OK;
}
@ -111,7 +105,7 @@ int SET_DATA_ADDERSS_Handle(u8 *buf)
{
USB_DeviceRequest *dreq = (USB_DeviceRequest *)buf;
start_addr=(((u32)dreq->wValue)<<16)+(u32)dreq->wIndex;
dprintf("\n SET ADDRESS:");
dprintf("\n SET ADDRESS:\t");
serial_put_hex(start_addr);
return ERR_OK;
}
@ -120,7 +114,7 @@ int SET_DATA_LENGTH_Handle(u8 *buf)
{
USB_DeviceRequest *dreq = (USB_DeviceRequest *)buf;
ops_length=(((u32)dreq->wValue)<<16)+(u32)dreq->wIndex;
dprintf("\n DATA_LENGTH :");
dprintf("\n DATA_LENGTH:\t");
serial_put_hex(ops_length);
return ERR_OK;
}
@ -219,20 +213,18 @@ int NAND_OPS_Handle(u8 *buf)
}
break;
case NAND_ERASE:
dprintf("\n Request : NAND_ERASE!");
dprintf("\n Request : NAND_ERASE");
ret_dat = nand_erase(ops_length,start_addr,
Hand.nand_force_erase);
handshake_PKT[0] = (u16) ret_dat;
handshake_PKT[1] = (u16) (ret_dat>>16);
HW_SendPKT(1,handshake_PKT,sizeof(handshake_PKT));
udc_state = IDLE;
dprintf("\n Request : NAND_ERASE_FINISH!");
dprintf(" ... finished.");
break;
case NAND_READ:
dprintf("\n Request : NAND_READ!");
// dprintf("\n Option : %x",option);
switch (option)
{
switch (option) {
case OOB_ECC:
ret_dat = nand_read(Bulk_in_buf,start_addr,ops_length,OOB_ECC);
handshake_PKT[0] = (u16) ret_dat;
@ -255,21 +247,20 @@ int NAND_OPS_Handle(u8 *buf)
udc_state = BULK_IN;
break;
}
dprintf("\n Request : NAND_READ_FUNISH!");
dprintf(" ... finished.");
break;
case NAND_PROGRAM:
dprintf("\n Request : NAND_PROGRAM!");
// dprintf("\n Option : %x",option);
ret_dat = nand_program((void *)Bulk_out_buf,
start_addr,ops_length,option);
dprintf("\n NAND_PROGRAM finish!");
handshake_PKT[0] = (u16) ret_dat;
handshake_PKT[1] = (u16) (ret_dat>>16);
HW_SendPKT(1,handshake_PKT,sizeof(handshake_PKT));
udc_state = IDLE;
dprintf(" ... finished.");
break;
case NAND_READ_TO_RAM:
dprintf("\n Request : NAND_READNAND!");
dprintf("\n Request : NAND_READ_TO_RAM!");
nand_read((u8 *)ram_addr,start_addr,ops_length,NO_OOB);
__dcache_writeback_all();
handshake_PKT[3]=(u16)ERR_OK;
@ -293,7 +284,7 @@ int SDRAM_OPS_Handle(u8 *buf)
switch ((dreq->wValue)&0xf)
{
case SDRAM_LOAD:
// dprintf("\n Request : SDRAM_LOAD!");
//dprintf("\n Request : SDRAM_LOAD!");
ret_dat = (u32)memcpy((u8 *)start_addr,Bulk_out_buf,ops_length);
handshake_PKT[0] = (u16) ret_dat;
handshake_PKT[1] = (u16) (ret_dat>>16);
@ -312,15 +303,9 @@ void Borad_Init()
{
case 0x4740:
//Init nand flash
nand_init_4740(Hand.nand_bw,Hand.nand_rc,Hand.nand_ps,Hand.nand_ppb,
Hand.nand_bbpage,Hand.nand_bbpos,Hand.nand_force_erase,Hand.nand_eccpos);
dprintf("\nnand_ps, nand_ppb, nand_bbpage, nand_bbpos, nand_eccpos\n");
serial_put_hex(Hand.nand_ps);
serial_put_hex(Hand.nand_ppb);
serial_put_hex(Hand.nand_bbpage);
serial_put_hex(Hand.nand_bbpos);
serial_put_hex(Hand.nand_eccpos);
nand_init_4740(Hand.nand_bw, Hand.nand_rc, Hand.nand_ps,
Hand.nand_ppb, Hand.nand_bbpage, Hand.nand_bbpos,
Hand.nand_force_erase, Hand.nand_eccpos);
nand_program = nand_program_4740;
nand_erase = nand_erase_4740;
@ -355,21 +340,23 @@ void Borad_Init()
int CONFIGRATION_Handle(u8 *buf)
{
dprintf("\n Configuration:\t");
USB_DeviceRequest *dreq = (USB_DeviceRequest *)buf;
switch ((dreq->wValue)&0xf)
{
switch ((dreq->wValue)&0xf) {
case DS_flash_info:
dprintf("\n configration :DS_flash_info_t!");
dprintf("DS_flash_info_t!");
config_flash_info();
break;
case DS_hand:
dprintf("\n configration :DS_hand_t!");
dprintf("DS_hand_t!");
config_hand();
break;
default:;
default:
;
}
Borad_Init();
return ERR_OK;
}

View File

@ -57,11 +57,11 @@ void c_main(void)
if ( fw_args->use_uart > 3 ) fw_args->use_uart = 0;
UART_BASE = 0xB0030000 + fw_args->use_uart * 0x1000;
serial_puts("Start address is :");
serial_puts("\n Stage2 start address is :\t");
serial_put_hex(start_addr);
serial_puts("Address offset is:");
serial_puts("\n Address offset is:\t");
serial_put_hex(offset);
serial_puts("GOT correct to :");
serial_puts("\n GOT correct to :\t");
serial_put_hex(got_start);
usb_main();

View File

@ -89,9 +89,9 @@ void serial_init(void)
void serial_put_hex(unsigned int d)
{
unsigned char c[12];
unsigned char c[9];
char i;
for(i = 0; i < 8;i++)
for(i = 0; i < 8; i++)
{
c[i] = (d >> ((7 - i) * 4)) & 0xf;
if(c[i] < 10)
@ -99,7 +99,9 @@ void serial_put_hex(unsigned int d)
else
c[i] += (0x41 - 10);
}
c[8] = '\n';
c[9] = 0;
c[8] = 0;
serial_puts("0x");
serial_puts(c);
}