summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2020-09-28 16:45:09 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-09-29 10:25:02 +0200
commit071eecf8c040782515512777b02573c79a3e9899 (patch)
tree7705ce2c9ae0fb4696ac10281ed2b8c15165ada5 /common
parentb28bcba8662cf0e60d35ef30c8d284f320fc9b1c (diff)
downloadbarebox-071eecf8c040782515512777b02573c79a3e9899.tar.gz
barebox-071eecf8c040782515512777b02573c79a3e9899.tar.xz
defaultenv: provide defaults for generic reboot modes
While reboot mode magic identifiers can be very board specific, we can settle on common names to allow some generic reboot mode handling: - loader -> drop to bootloader shell on next boot - bootloader -> enable fastboot on next boot - recovery -> display barebox boot menu Boot modes loader and bootloader are admittedly a bit ambiguous, but this nomenclature was chosen, because it's already in use on Android and Rockchip systems. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig5
-rw-r--r--common/startup.c16
2 files changed, 21 insertions, 0 deletions
diff --git a/common/Kconfig b/common/Kconfig
index 1a5bb53182..9419977276 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -906,6 +906,11 @@ config DEFAULT_ENVIRONMENT_GENERIC_NEW_DFU
depends on USB_GADGET_DFU
default y
+config DEFAULT_ENVIRONMENT_GENERIC_NEW_REBOOT_MODE
+ bool "Generic reboot-mode handlers in the environment"
+ depends on DEFAULT_ENVIRONMENT_GENERIC_NEW
+ depends on REBOOT_MODE
+
config DEFAULT_ENVIRONMENT_PATH
string
depends on DEFAULT_ENVIRONMENT
diff --git a/common/startup.c b/common/startup.c
index ea7ce6b8da..f3e5765d5d 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -38,6 +38,7 @@
#include <linux/stat.h>
#include <envfs.h>
#include <magicvar.h>
+#include <linux/reboot-mode.h>
#include <asm/sections.h>
#include <uncompress.h>
#include <globalvar.h>
@@ -310,6 +311,7 @@ static int run_init(void)
DIR *dir;
struct dirent *d;
const char *initdir = "/env/init";
+ const char *bmode;
bool env_bin_init_exists;
enum autoboot_state autoboot;
struct stat s;
@@ -350,6 +352,20 @@ static int run_init(void)
closedir(dir);
}
+ /* source matching script in /env/bmode/ */
+ bmode = reboot_mode_get();
+ if (bmode) {
+ char *scr, *path;
+
+ scr = xasprintf("source /env/bmode/%s", bmode);
+ path = &scr[strlen("source ")];
+ if (stat(path, &s) == 0) {
+ pr_info("Invoking '%s'...\n", path);
+ run_command(scr);
+ }
+ free(scr);
+ }
+
autoboot = do_autoboot_countdown();
console_ctrlc_allow();