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 <[email protected]> --- 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
