cli_hush: support running bootcmd on boot retry
authorCaleb Connolly <caleb.connolly@linaro.org>
Mon, 31 Mar 2025 12:23:19 +0000 (14:23 +0200)
committerCaleb Connolly <caleb.connolly@linaro.org>
Fri, 11 Apr 2025 13:28:14 +0000 (15:28 +0200)
Introduce a new config option: RETRY_BOOTCMD. When enabled this causes
hush shell to re-run "bootcmd" when the auto-boot counter times out.

Tested-by: Danila Tikhonov <danila@jiaxyga.com> # google-sunfish
Tested-by: Jens Reidel <adrian@mainlining.org> # xiaomi-davinci
Link: https://lore.kernel.org/r/20250331-qcom-phones-v4-2-f52e57d3b8c6@linaro.org
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
boot/Kconfig
common/cli_hush.c
common/cli_hush_upstream.c

index f101200..fb37d91 100644 (file)
@@ -1704,6 +1704,13 @@ config RESET_TO_RETRY
          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"
index 9f437ae..7bd6943 100644 (file)
@@ -1028,8 +1028,10 @@ static void get_user_input(struct in_str *i)
          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
index ab5aa5f..748ef60 100644 (file)
@@ -2907,8 +2907,10 @@ static void get_user_input(struct in_str *i)
                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