mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH] startup: attempt poweroff if no shell and nothing to do
Date: Mon,  5 Jan 2026 09:21:14 +0100	[thread overview]
Message-ID: <20260105082128.3248033-1-a.fatoum@barebox.org> (raw)

For testing noshell configuration in virtual machines and sandbox,
it's useful if the process would just exit instead of hanging
indefinitely.

This is usually handled with panic(), which can be customized to
poweroff or reset, but in this case a panic with CONFIG_PANIC_RESET=y
would just lead to a reboot loop.

Instead, let's explicitly poweroff in that case. For platforms that
don't support powering off, the function will hang as before, but for
others, it will not waste as much energy.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 Documentation/migration-guides/migration-master.rst | 9 +++++++++
 common/startup.c                                    | 5 +++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/Documentation/migration-guides/migration-master.rst b/Documentation/migration-guides/migration-master.rst
index ebf69e3c6bb1..e258f656cae3 100644
--- a/Documentation/migration-guides/migration-master.rst
+++ b/Documentation/migration-guides/migration-master.rst
@@ -35,3 +35,12 @@ ARM i.MX6 RIoTboard
 
 The barebox update handler has been changed to write barebox to the
 eMMC boot partitions rather than the user data area.
+
+CONFIG_SHELL_NONE
+-----------------
+
+If there's nothing to do for a shell-less barebox, it will now attempt
+to poweroff the system instead of busy-looping indefinitely.
+This changes behavior for systems that rely on a watchdog to reset
+a hanging barebox in this situation. If this breaks anything for you,
+please reach out.
diff --git a/common/startup.c b/common/startup.c
index 81a3ae1513c2..05ed75de29a4 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -20,6 +20,7 @@
 #include <shell.h>
 #include <init.h>
 #include <command.h>
+#include <poweroff.h>
 #include <malloc.h>
 #include <debug_ll.h>
 #include <fs.h>
@@ -440,8 +441,8 @@ void __noreturn start_barebox(void)
 		barebox_main();
 
 	if (IS_ENABLED(CONFIG_SHELL_NONE)) {
-		pr_err("Nothing left to do\n");
-		hang();
+		pr_crit("Nothing left to do\n");
+		poweroff_machine(0);
 	} else {
 		while (1)
 			run_shell();
-- 
2.47.3




             reply	other threads:[~2026-01-05  8:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-05  8:21 Ahmad Fatoum [this message]
2026-01-06  7:43 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260105082128.3248033-1-a.fatoum@barebox.org \
    --to=a.fatoum@barebox.org \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox