From: Eduard Strehlau <edu...@lionizers.com>

Add an altbootcmd script, which is convenient way to integrate with
swupdate and perform a roll back of the previous working version in the
case of update failure.

Signed-off-by: Eduard Strehlau <edu...@lionizers.com>
Signed-off-by: Fabio Estevam <feste...@denx.de>
---
Changes since v1:
- None

 configs/smegw01_defconfig | 2 +-
 include/configs/smegw01.h | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/configs/smegw01_defconfig b/configs/smegw01_defconfig
index 5d9d419463..418151a6de 100644
--- a/configs/smegw01_defconfig
+++ b/configs/smegw01_defconfig
@@ -18,7 +18,7 @@ CONFIG_SYS_MEMTEST_END=0xa0000000
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="if run loadimage; then run mmcboot; fi; "
+CONFIG_BOOTCOMMAND="if test \"${ustate}\" = 1; then setenv upgrade_available 
1; saveenv; fi; if run loadimage; then run mmcboot; fi; "
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_MAXARGS=32
 CONFIG_SYS_PBSIZE=532
diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index a356f095a6..6ee4acc70d 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -33,6 +33,7 @@
        "mmcargs=setenv bootargs console=${console},${baudrate} " \
                "root=/dev/mmcblk0p${mmcpart} rootwait rw " \
                __stringify(EXTRA_BOOTPARAMS) "\0" \
+       "bootlimit=3\0" \
        "loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} boot/${image}\0" \
        "loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr} boot/${fdtfile}\0" \
        "mmcboot=echo Booting from mmc ...; " \
@@ -40,6 +41,13 @@
                "if run loadfdt; then " \
                        "bootz ${loadaddr} - ${fdt_addr}; " \
                "fi;\0" \
+       "altbootcmd=echo Performing rollback...; " \
+               "if test \"${mmcpart}\" = 1; then " \
+                       "setenv mmcpart 2; " \
+               "else " \
+                       "setenv mmcpart 1; " \
+               "fi; setenv bootcount 0; setenv upgrade_available; setenv 
ustate 3; saveenv; " \
+               "run bootcmd;\0"
 
 /* Physical Memory Map */
 #define PHYS_SDRAM                     MMDC0_ARB_BASE_ADDR
-- 
2.38.1

Reply via email to