Skip to content

Commit 23cf007

Browse files
author
Catherine Garabedian
authored
Improving error behavior
Improving error behavior
2 parents c062eec + e792f3a commit 23cf007

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

common/autoboot.c

+12
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,18 @@ void autoboot_command(const char *s)
359359
#if defined(CONFIG_AUTOBOOT_KEYED) && !defined(CONFIG_AUTOBOOT_KEYED_CTRLC)
360360
disable_ctrlc(prev); /* restore Control C checking */
361361
#endif
362+
363+
/*
364+
* We failed to run commands for some reason.
365+
* There are two conceivable reasons:
366+
* - Someone coded bad boot commands
367+
* - The envar section of RAM got hit with an SEU
368+
*
369+
* We want to try to handle the latter by just doing a system reset so
370+
* that RAM gets reloaded
371+
*/
372+
373+
do_reset(cmdtp, flag, argc, argv);
362374
}
363375

364376
#ifdef CONFIG_MENUKEY

common/bootm.c

+15-8
Original file line numberDiff line numberDiff line change
@@ -612,11 +612,21 @@ int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
612612

613613
#ifdef CONFIG_UPDATE_KUBOS
614614
/* Check the boot counter. If it's too high, we need to try and recover */
615-
if(bootcount_load() > 2)
615+
unsigned long bootcount = bootcount_load();
616+
if(bootcount > 2)
616617
{
617-
ret = BOOTM_ERR_OTHER;
618-
printf("ERROR: Failed to boot too many times, triggering recovery\n");
619-
goto err;
618+
/*
619+
* If the bootlimit has been reached, then we're trying to execute the
620+
* alternate boot logic. It's entirely possible that we're still using
621+
* a `bootm` command to load an alternate OS, so don't automatically
622+
* fall into the recovery logic
623+
*/
624+
unsigned long bootlimit = getenv_ulong("bootlimit", 10, 0);
625+
if(bootcount <= bootlimit) {
626+
ret = BOOTM_ERR_OTHER;
627+
printf("ERROR: Failed to boot too many times, triggering recovery\n");
628+
goto err;
629+
}
620630
}
621631
#endif
622632

@@ -789,10 +799,7 @@ int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
789799
* can track the failure and run the altbootcmd instead, if it's available.
790800
*/
791801
printf("Boot failed. No rollback could be completed\n");
792-
if (getenv_yesno("recovery_available"))
793-
{
794-
do_reset(cmdtp, flag, argc, argv);
795-
}
802+
do_reset(cmdtp, flag, argc, argv);
796803

797804
#endif
798805

include/configs/kubos-common.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#define KUBOS_UPDATE_FILE "kubos_updatefile"
4545

4646
#define KUBOS_UPDATE_ARGS \
47-
"altbootcmd=setenv recovery_available 0; setenv bootcmd; saveenv\0" \
47+
"altbootcmd=run bootcmd\0" \
4848
"recovery_available=1\0" \
4949
"bootlimit=3\0" \
5050
KUBOS_CURR_VERSION "=" KUBOS_BASE "\0" \

0 commit comments

Comments
 (0)