mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] startup: add new AUTOBOOT_HALT state
@ 2024-10-21 17:55 Ahmad Fatoum
  2024-10-22  6:18 ` Marco Felsch
  0 siblings, 1 reply; 3+ messages in thread
From: Ahmad Fatoum @ 2024-10-21 17:55 UTC (permalink / raw)
  To: barebox; +Cc: bst, Ahmad Fatoum

To make the barebox shell more convenient to use, barebox executes some
actions only when dropping to an interactive shell:

  - If dropping due to global.autoboot=abort, all watchdogs are
    automatically quiesced
  - In every case, network interfaces are brought up, so link
    negotiation happens in parallel to waiting for user input

This is useful for development and debugging, but bad for automatic
tests as the system behaves differently when automatic test aborts
barebox to set e.g. a boot argument and when barebox is left to boot
uninterrupted.

For use in such scenarios, let's introduce a new AUTOBOOT_HALT state.
This will not do any automatic interactive magic and can be entered by
either setting nv.autoboot=halt or by aborting the boot with ctrl+d.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Thoughts?

Alternatively, we could make only aborting the boot via e.g. enter
enable the network interfaces.
---
 common/startup.c  | 11 ++++++++---
 include/barebox.h |  3 +++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/common/startup.c b/common/startup.c
index 47b70a7756cb..5d0ac116b98c 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -28,6 +28,7 @@
 #include <linux/stat.h>
 #include <envfs.h>
 #include <magicvar.h>
+#include <readkey.h>
 #include <linux/reboot-mode.h>
 #include <asm/sections.h>
 #include <uncompress.h>
@@ -103,6 +104,7 @@ static int global_autoboot_timeout = 3;
 static const char * const global_autoboot_states[] = {
 	[AUTOBOOT_COUNTDOWN] = "countdown",
 	[AUTOBOOT_ABORT] = "abort",
+	[AUTOBOOT_HALT] = "halt",
 	[AUTOBOOT_MENU] = "menu",
 	[AUTOBOOT_BOOT] = "boot",
 };
@@ -176,7 +178,8 @@ enum autoboot_state do_autoboot_countdown(void)
 		return autoboot_state;
 
 	if (!console_get_first_active() &&
-	    global_autoboot_state != AUTOBOOT_ABORT) {
+	    global_autoboot_state != AUTOBOOT_ABORT &&
+	    global_autoboot_state != AUTOBOOT_HALT) {
 		printf("\nNon-interactive console, booting system\n");
 		return autoboot_state = AUTOBOOT_BOOT;
 	}
@@ -215,6 +218,8 @@ enum autoboot_state do_autoboot_countdown(void)
 		autoboot_state = AUTOBOOT_BOOT;
 	else if (menu_exists && outkey == 'm')
 		autoboot_state = AUTOBOOT_MENU;
+	else if (outkey == CTL_CH('d'))
+		autoboot_state = AUTOBOOT_HALT;
 	else
 		autoboot_state = AUTOBOOT_ABORT;
 
@@ -310,7 +315,7 @@ static int run_init(void)
 	if (autoboot == AUTOBOOT_BOOT)
 		run_command("boot");
 
-	if (IS_ENABLED(CONFIG_NET))
+	if (IS_ENABLED(CONFIG_NET) && autoboot != AUTOBOOT_HALT)
 		eth_open_all();
 
 	if (autoboot == AUTOBOOT_MENU)
@@ -400,7 +405,7 @@ void shutdown_barebox(void)
 }
 
 BAREBOX_MAGICVAR(global.autoboot,
-                 "Autoboot state. Possible values: countdown (default), abort, menu, boot");
+                 "Autoboot state. Possible values: countdown (default), abort, halt, menu, boot");
 BAREBOX_MAGICVAR(global.autoboot_abort_key,
                  "Which key allows to interrupt autoboot. Possible values: any, ctrl-c");
 BAREBOX_MAGICVAR(global.autoboot_timeout,
diff --git a/include/barebox.h b/include/barebox.h
index 45e95f187462..b3d34b7b739b 100644
--- a/include/barebox.h
+++ b/include/barebox.h
@@ -22,6 +22,8 @@ extern int (*barebox_main)(void);
  * enum autoboot_state - autoboot action after init
  * @AUTOBOOT_COUNTDOWN: Count down to automatic boot action
  * @AUTOBOOT_ABORT: Abort boot and drop to barebox shell
+ * @AUTOBOOT_HALT: Halt boot and drop to barebox shell, _without_ running
+ *                 any interactive hooks (e.g. bringing up network)
  * AUTOBOOT_MENU: Show main menu directly
  * @AUTOBOOT_BOOT: Boot right away without an interruptible countdown
  * @AUTOBOOT_UNKNOWN: Boot right away without an interruptible countdown
@@ -32,6 +34,7 @@ extern int (*barebox_main)(void);
 enum autoboot_state {
 	AUTOBOOT_COUNTDOWN,
 	AUTOBOOT_ABORT,
+	AUTOBOOT_HALT,
 	AUTOBOOT_MENU,
 	AUTOBOOT_BOOT,
 	AUTOBOOT_UNKNOWN,
-- 
2.39.5




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-22  6:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-21 17:55 [PATCH] startup: add new AUTOBOOT_HALT state Ahmad Fatoum
2024-10-22  6:18 ` Marco Felsch
2024-10-22  6:19   ` Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox