bootcycle: add resetcycle cmd - reset the bootcycle counter to 0

This commit is contained in:
Alexander Couzens 2015-03-09 15:13:49 +01:00
parent 6ea75b8c9c
commit 5fc9ba0246
1 changed files with 13 additions and 2 deletions

View File

@ -58,7 +58,7 @@ static int valid_boot_cycle(struct sram_boot_cycle *sram)
return 1;
}
static void init_boot_cycle(struct sram_boot_cycle *sram)
static void reset_boot_cycle(struct sram_boot_cycle *sram)
{
sram->magic = BOOT_CYCLE_MAGIC;
sram->version = BOOT_CYCLE_VERSION;
@ -69,7 +69,7 @@ static void init_boot_cycle(struct sram_boot_cycle *sram)
void increase_boot_cycle(struct sram_boot_cycle *sram)
{
if (!valid_boot_cycle(sram))
init_boot_cycle(sram);
reset_boot_cycle(sram);
sram->counter++;
sram->crc = (uint32_t) crc32(0xdeadbeef, (void *)sram, sizeof(*sram) - 4);
@ -80,6 +80,11 @@ int do_inccycle(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) {
return CMD_RET_SUCCESS;
}
int do_resetcycle(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) {
reset_boot_cycle((void *) SRAM_BOOT_CYCLE);
return CMD_RET_SUCCESS;
}
/* report failure when we need to go to rescue */
int do_checkcycle(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
@ -123,4 +128,10 @@ U_BOOT_CMD(
NULL
);
U_BOOT_CMD(
resetcycle, 1, 0, do_resetcycle,
"resetcycle - reset boot cycle counter to 0\n",
NULL
);
#endif /* CFG_CMD_BOOTCYCLE */