Introduce a new config option: RETRY_BOOTCMD. When enabled this causes
hush shell to re-run "bootcmd" when the auto-boot counter times out.

Signed-off-by: Caleb Connolly <caleb.conno...@linaro.org>
---
 boot/Kconfig               | 7 +++++++
 common/cli_hush.c          | 6 ++++--
 common/cli_hush_upstream.c | 6 ++++--
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index 
c09a98c3233ceb1c68024a193d7dafdce6b83903..4db13dcb9a51940c358f754d9ff91e88bebd96b1
 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -1711,8 +1711,15 @@ config RESET_TO_RETRY
        help
          After the countdown timed out, the board will be reset to restart
          again.
 
+config RETRY_BOOTCMD
+       bool "Run bootcmd on retry"
+       depends on BOOT_RETRY && HUSH_PARSER && !RESET_TO_RETRY
+       help
+         If this option is enabled, the "bootcmd" will be run after the
+         countdown times out.
+
 endmenu
 
 menu "Image support"
 
diff --git a/common/cli_hush.c b/common/cli_hush.c
index 
a6a8edce1f43cf4f28fdfc0d8da9b6e180c23cd4..bb134cce18dad8dddb54d7b038ca105853fc3eda
 100644
--- a/common/cli_hush.c
+++ b/common/cli_hush.c
@@ -1027,10 +1027,12 @@ static void get_user_input(struct in_str *i)
        if (n == -2) {
          puts("\nTimeout waiting for command\n");
 #  ifdef CONFIG_RESET_TO_RETRY
          do_reset(NULL, 0, 0, NULL);
-#  else
-#      error "This currently only works with CONFIG_RESET_TO_RETRY enabled"
+#  elif IS_ENABLED(CONFIG_RETRY_BOOTCMD)
+       strcpy(console_buffer, "run bootcmd\n");
+# else
+#      error "This only works with CONFIG_RESET_TO_RETRY or 
CONFIG_BOOT_RETRY_COMMAND enabled"
 #  endif
        }
 #endif
        if (n == -1 ) {
diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
index 
ab5aa5f9b36a91e09f8fcfcbb8b31afa0892e6bc..748ef60ac90b8af8052631c7ad3a6aed2629140b
 100644
--- a/common/cli_hush_upstream.c
+++ b/common/cli_hush_upstream.c
@@ -2906,10 +2906,12 @@ static void get_user_input(struct in_str *i)
        if (n == -2) {
                puts("\nTimeout waiting for command\n");
 #  ifdef CONFIG_RESET_TO_RETRY
                do_reset(NULL, 0, 0, NULL);
-#  else
-#      error "This currently only works with CONFIG_RESET_TO_RETRY enabled"
+#  elif IS_ENABLED(CONFIG_RETRY_BOOTCMD)
+       strcpy(console_buffer, "run bootcmd\n");
+# else
+#      error "This only works with CONFIG_RESET_TO_RETRY or 
CONFIG_BOOT_RETRY_COMMAND enabled"
 #  endif
        }
 # endif
        if (n == -1 ) {

-- 
2.48.1

Reply via email to