bootcycle: add argument value to cmd `inccycle`
value define how much the counter should increased
This commit is contained in:
parent
b59bb608cd
commit
e38d63e12d
|
@ -66,17 +66,28 @@ static void reset_boot_cycle(struct sram_boot_cycle *sram)
|
||||||
sram->crc = (uint32_t) crc32(0xdeadbeef, (void *)sram, sizeof(*sram) - 4);
|
sram->crc = (uint32_t) crc32(0xdeadbeef, (void *)sram, sizeof(*sram) - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void increase_boot_cycle(struct sram_boot_cycle *sram)
|
void increase_boot_cycle(struct sram_boot_cycle *sram, uint32_t value)
|
||||||
{
|
{
|
||||||
if (!valid_boot_cycle(sram))
|
if (!valid_boot_cycle(sram))
|
||||||
reset_boot_cycle(sram);
|
reset_boot_cycle(sram);
|
||||||
|
|
||||||
sram->counter++;
|
sram->counter += value;
|
||||||
sram->crc = (uint32_t) crc32(0xdeadbeef, (void *)sram, sizeof(*sram) - 4);
|
sram->crc = (uint32_t) crc32(0xdeadbeef, (void *)sram, sizeof(*sram) - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
int do_inccycle(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) {
|
int do_inccycle(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) {
|
||||||
increase_boot_cycle((void *) SRAM_BOOT_CYCLE);
|
uint32_t value = 1;
|
||||||
|
|
||||||
|
if (argc == 2) {
|
||||||
|
int given_value = (int)simple_strtol(argv[1], NULL, 10);
|
||||||
|
if (given_value > 0) {
|
||||||
|
value = given_value;
|
||||||
|
} else {
|
||||||
|
printf("Ignoring invalid argument %s\n", argv[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
increase_boot_cycle((void *) SRAM_BOOT_CYCLE, value);
|
||||||
return CMD_RET_SUCCESS;
|
return CMD_RET_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +134,7 @@ U_BOOT_CMD(
|
||||||
);
|
);
|
||||||
|
|
||||||
U_BOOT_CMD(
|
U_BOOT_CMD(
|
||||||
inccycle, 1, 0, do_inccycle,
|
inccycle, 2, 0, do_inccycle,
|
||||||
"inccycle - increase boot cycle counter\n",
|
"inccycle - increase boot cycle counter\n",
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue