mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2024-11-22 08:10:37 +02:00
usbboot: fix hand.fw_args.cpu_id have wrong value when there is no 'boot' in commands
This commit is contained in:
parent
b8420d20e1
commit
1d7a2f3f56
@ -97,11 +97,44 @@ out:
|
||||
return res;
|
||||
}
|
||||
|
||||
int get_ingenic_cpu()
|
||||
{
|
||||
int status;
|
||||
|
||||
status = usb_get_ingenic_cpu(&ingenic_dev);
|
||||
|
||||
switch (status) {
|
||||
case JZ4740V1:
|
||||
hand.fw_args.cpu_id = 0x4740;
|
||||
break;
|
||||
case JZ4750V1:
|
||||
hand.fw_args.cpu_id = 0x4750;
|
||||
break;
|
||||
case JZ4760V1:
|
||||
hand.fw_args.cpu_id = 0x4760;
|
||||
break;
|
||||
case BOOT4740:
|
||||
hand.fw_args.cpu_id = 0x4740;
|
||||
break;
|
||||
case BOOT4750:
|
||||
hand.fw_args.cpu_id = 0x4750;
|
||||
break;
|
||||
case BOOT4760:
|
||||
hand.fw_args.cpu_id = 0x4760;
|
||||
break;
|
||||
default:
|
||||
hand.fw_args.cpu_id = 0;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/* after upload stage2. must init device */
|
||||
void init_cfg()
|
||||
{
|
||||
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
|
||||
printf(" XBurst CPU not booted yet, boot it first!\n");
|
||||
int cpu = get_ingenic_cpu();
|
||||
if (cpu != BOOT4740 && cpu != BOOT4750 && cpu != BOOT4760) {
|
||||
printf(" Device unboot! Boot it first!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -124,39 +157,9 @@ xout:
|
||||
}
|
||||
|
||||
int boot(char *stage1_path, char *stage2_path){
|
||||
int status;
|
||||
int status = get_ingenic_cpu();
|
||||
|
||||
status = usb_get_ingenic_cpu(&ingenic_dev);
|
||||
switch (status) {
|
||||
case JZ4740V1:
|
||||
status = 0;
|
||||
hand.fw_args.cpu_id = 0x4740;
|
||||
break;
|
||||
case JZ4750V1:
|
||||
status = 0;
|
||||
hand.fw_args.cpu_id = 0x4750;
|
||||
break;
|
||||
case JZ4760V1:
|
||||
status = 0;
|
||||
hand.fw_args.cpu_id = 0x4760;
|
||||
break;
|
||||
case BOOT4740:
|
||||
status = 1;
|
||||
hand.fw_args.cpu_id = 0x4740;
|
||||
break;
|
||||
case BOOT4750:
|
||||
status = 1;
|
||||
hand.fw_args.cpu_id = 0x4750;
|
||||
break;
|
||||
case BOOT4760:
|
||||
status = 1;
|
||||
hand.fw_args.cpu_id = 0x4760;
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (status) {
|
||||
if (status == BOOT4740 || status == BOOT4750 || status == BOOT4760) {
|
||||
printf(" Already booted.\n");
|
||||
return 1;
|
||||
} else {
|
||||
@ -181,8 +184,10 @@ int boot(char *stage1_path, char *stage2_path){
|
||||
|
||||
printf(" Booted successfully!\n");
|
||||
}
|
||||
|
||||
usleep(100);
|
||||
init_cfg();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -214,7 +219,8 @@ int error_check(unsigned char *org,unsigned char * obj,unsigned int size)
|
||||
|
||||
int nand_markbad(struct nand_in *nand_in)
|
||||
{
|
||||
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
|
||||
int cpu = get_ingenic_cpu();
|
||||
if (cpu != BOOT4740 && cpu != BOOT4750 && cpu != BOOT4760) {
|
||||
printf(" Device unboot! Boot it first!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -242,7 +248,7 @@ int nand_program_check(struct nand_in *nand_in, unsigned int *start_page)
|
||||
goto err;
|
||||
}
|
||||
|
||||
int cpu = usb_get_ingenic_cpu(&ingenic_dev);
|
||||
int cpu = get_ingenic_cpu();
|
||||
if (cpu != BOOT4740 && cpu != BOOT4750 && cpu != BOOT4760) {
|
||||
printf(" Device unboot! Boot it first!\n");
|
||||
goto err;
|
||||
@ -353,7 +359,8 @@ int nand_erase(struct nand_in *nand_in)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
|
||||
int cpu = get_ingenic_cpu();
|
||||
if (cpu != BOOT4740 && cpu != BOOT4750 && cpu != BOOT4760) {
|
||||
printf(" Device unboot! Boot it first!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -590,7 +597,8 @@ int nand_query(void)
|
||||
if (i >= nand_in.max_chip)
|
||||
return -1;
|
||||
|
||||
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
|
||||
int cpu = get_ingenic_cpu();
|
||||
if (cpu != BOOT4740 && cpu != BOOT4750 && cpu != BOOT4760) {
|
||||
printf(" Device unboot! Boot it first!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -651,7 +659,8 @@ int nand_read(int mode)
|
||||
printf(" Page number overflow!\n");
|
||||
return -1;
|
||||
}
|
||||
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
|
||||
int cpu = get_ingenic_cpu();
|
||||
if (cpu != BOOT4740 && cpu != BOOT4750 && cpu != BOOT4760) {
|
||||
printf(" Device unboot! Boot it first!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -711,8 +720,8 @@ 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) {
|
||||
tmp = get_ingenic_cpu();
|
||||
if (tmp == BOOT4740 || tmp == BOOT4750 || tmp == BOOT4760) {
|
||||
printf(" This command only run under UNBOOT state!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -759,8 +768,8 @@ int debug_gpio(int obj, unsigned char ops, unsigned char pin)
|
||||
{
|
||||
unsigned int tmp;
|
||||
|
||||
tmp = usb_get_ingenic_cpu(&ingenic_dev);
|
||||
if (tmp > 2) {
|
||||
tmp = get_ingenic_cpu();
|
||||
if (tmp == BOOT4740 || tmp == BOOT4750 || tmp == BOOT4760) {
|
||||
printf(" This command only run under UNBOOT state!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -823,7 +832,8 @@ int debug_go(void)
|
||||
|
||||
int sdram_load(struct sdram_in *sdram_in)
|
||||
{
|
||||
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
|
||||
int cpu = get_ingenic_cpu();
|
||||
if (cpu != BOOT4740 && cpu != BOOT4750 && cpu != BOOT4760) {
|
||||
printf(" Device unboot! Boot it first!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -917,7 +927,8 @@ out:
|
||||
|
||||
int device_reset(int ops)
|
||||
{
|
||||
if (usb_get_ingenic_cpu(&ingenic_dev) < 3) {
|
||||
int cpu = get_ingenic_cpu();
|
||||
if (cpu != BOOT4740 && cpu != BOOT4750 && cpu != BOOT4760) {
|
||||
printf(" Device unboot! Boot it first!\n");
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user