boot_cycle_counter: add argument `threshold` to checkcycle

Allow to overwrite the default threshold via commandline argument.
e.g. `checkcycle 6` will fail when 6 reboots happened
This commit is contained in:
Alexander Couzens 2015-03-03 14:27:49 +01:00
parent 781503ce81
commit 3e2a5a1b67
1 changed files with 13 additions and 2 deletions

View File

@ -82,6 +82,17 @@ int do_inccycle(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) {
/* report failure when we need to go to rescue */
int do_checkcycle(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
uint32_t threshold = MAX_REBOOTS;
if (argc == 2) {
int given_threshold = (int)simple_strtol(argv[1], NULL, 10);
if (given_threshold > 0) {
threshold = given_threshold;
} else {
printf("Ignoring invalid argument %s\n", argv[1]);
}
}
struct sram_boot_cycle *sram = (void *) SRAM_BOOT_CYCLE;
/* when called we should ever have a valid boot cycle entry
* if it's invalid we have most likely a broken bootloader or hw? */
@ -100,8 +111,8 @@ int do_checkcycle(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
U_BOOT_CMD(
checkcycle, 1, 0, do_checkcycle,
"checkcycle - check if we need to boot rescue system\n",
checkcycle, 2, 0, do_checkcycle,
"checkcycle [max_reboots] - check if maximum reboots reached.\n",
NULL
);