learning uboot auto switch to stanbdy system in qca4531 cpu
design:
when uboot load kerne failed,we can switch to stanbdy system;
when boot fail, we can let uboot env bootKenrelFailCount++, then save to uboot_env partiton.
watchdog timeout will trigger cpu reset, when bootKernelFailCount bigger than a fixed number
we can realize switch to stanbdy system
reference code:
void bootKernelFailProcess(){
char buf[100]=0;
char *s;
int bootKernelFailCount =0;
s=getenv("bootKernelFailCount");
bootKernelFailCount =++atoi(s);
sprintf(buf,"setenv bootKernelFailCount %d", bootKernelFailCount);
run_command(buf,0);
run_command("saveenv",0);
}
void changeBootslotFunction(){
char buf[100]=0;
int bootslot=0;
s=getenv("bootslot");
bootslot=atoi(s)^1;
sprintf(buf,"setenv bootslot %d",bootslot);
run_command(buf,0);
run_command("saveenv",0);
}
void bootKernelFailCountDetect(){
if( atoi(getenv("bootKernelfailCount ")) > 2 ){
run_command("setenv bootKernelFailCount 0",0);
changeBootslotFunction();
}
}