From 5fc9ba0246ab807f5aa4112564c565615d97619d Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Mon, 9 Mar 2015 15:13:49 +0100 Subject: [PATCH] bootcycle: add resetcycle cmd - reset the bootcycle counter to 0 --- u-boot/common/cmd_bootcycle.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/u-boot/common/cmd_bootcycle.c b/u-boot/common/cmd_bootcycle.c index 09feba682a..1860f4bcd0 100644 --- a/u-boot/common/cmd_bootcycle.c +++ b/u-boot/common/cmd_bootcycle.c @@ -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 */