toradex: imx: enable BOOTCOUNT feature
authorIgor Opaniuk <igor.opaniuk@toradex.com>
Tue, 16 Jun 2020 19:20:08 +0000 (22:20 +0300)
committerStefano Babic <sbabic@denx.de>
Mon, 22 Jun 2020 15:42:44 +0000 (17:42 +0200)
This introduces automatic boot counter that increases after every
reset.After a power-on reset, it will be initialized with 1,
and each reboot will increment the value by 1. By default it's
disabled if bootlimit isn't set.

To enable this feature you have set bootcount limit ("bootlimit"),
alternate boot action ("altbootcmd") that will be performed if
the new value of bootcount exceeds the value of bootlimit, and
"upgrade_available" to let U-Boot automatically increase and save
the counter value after every reset:

> setenv bootlimit 5
> setenv upgrade_available 1
> setenv altbootcmd "bootm ..."

In case the bootlimit exceeds, the message will be shown and
albootcmd executed:
Warning: Bootlimit (5) exceeded. Using altbootcmd.

To reset bootcount run:
> bootcount reset

Print current value:
> bootcount print

Signed-off-by: Igor Opaniuk <igor.opaniuk@toradex.com>
configs/apalis_imx6_defconfig
configs/colibri-imx6ull_defconfig
configs/colibri_imx6_defconfig
configs/colibri_imx7_defconfig
configs/colibri_imx7_emmc_defconfig

index 6b0f0e463896271ced3edad7fb82452158f8f9c1..65162a26f669dac72b886e9de52029ae98a3a78f 100644 (file)
@@ -53,6 +53,7 @@ CONFIG_CMD_USB_SDP=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_CMD_NFS is not set
 CONFIG_CMD_BMP=y
+CONFIG_CMD_BOOTCOUNT=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_PMIC=y
@@ -65,6 +66,8 @@ CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_IP_DEFRAG=y
 CONFIG_TFTP_BLOCKSIZE=4096
 CONFIG_DWC_AHSATA=y
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_ENV=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
 CONFIG_SUPPORT_EMMC_BOOT=y
index 74a67a020009b33060544f6abbb1ac481e8edcd7..ce145cd24f7413e46e6461ce549282c94f27ab61 100644 (file)
@@ -40,6 +40,7 @@ CONFIG_CMD_USB=y
 CONFIG_CMD_USB_SDP=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_BMP=y
+CONFIG_CMD_BOOTCOUNT=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_MTDPARTS=y
@@ -54,6 +55,8 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_IP_DEFRAG=y
 CONFIG_TFTP_BLOCKSIZE=16352
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_ENV=y
 CONFIG_DFU_NAND=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MXC=y
index 44a3ff859c2d60b885ebb82cccdfd751c8e52cf6..ca33327c6b1cf9f3f16f512ede7e52b2a240cfc4 100644 (file)
@@ -52,6 +52,7 @@ CONFIG_CMD_USB_SDP=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_CMD_NFS is not set
 CONFIG_CMD_BMP=y
+CONFIG_CMD_BOOTCOUNT=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_UUID=y
@@ -64,6 +65,8 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_IP_DEFRAG=y
 CONFIG_TFTP_BLOCKSIZE=16352
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_ENV=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
 CONFIG_SUPPORT_EMMC_BOOT=y
index 7596478ee3699aaa1583d4c4f1ea703a0f321c2b..89ee6e5a07fc6ef9ad6571b999d524f84f377f58 100644 (file)
@@ -40,6 +40,7 @@ CONFIG_CMD_USB=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_BOOTP_PXE is not set
 CONFIG_CMD_BMP=y
+CONFIG_CMD_BOOTCOUNT=y
 CONFIG_CMD_CACHE=y
 # CONFIG_CMD_HASH is not set
 CONFIG_CMD_MTDPARTS=y
@@ -54,6 +55,8 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_IP_DEFRAG=y
 CONFIG_TFTP_BLOCKSIZE=16352
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_ENV=y
 CONFIG_FSL_CAAM=y
 CONFIG_DFU_NAND=y
 CONFIG_DM_I2C=y
index c23ff97daa1faf8f02d2a51fb6c013cd0ba0c110..13a3aae9a753d527afaf23848eb7abc487cde14c 100644 (file)
@@ -38,6 +38,7 @@ CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_BMP=y
+CONFIG_CMD_BOOTCOUNT=y
 CONFIG_CMD_CACHE=y
 # CONFIG_CMD_HASH is not set
 # CONFIG_ISO_PARTITION is not set
@@ -48,6 +49,8 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_IP_DEFRAG=y
 CONFIG_TFTP_BLOCKSIZE=16352
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_ENV=y
 CONFIG_FSL_CAAM=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x82000000