[PATCH] common: add option for shipping KCONFIG_CONFIG as /env/data/config

Ahmad Fatoum ahmad at a3f.at
Sat Apr 10 11:45:05 BST 2021


Add a new option that enables access to the barebox configuration
file through /env/data/config. This can be useful in environments
where a fatter barebox can be tolerated (like on an EFI system
partition). It could also be used to conditionally skip tests
on disabled functionality in the future.

Signed-off-by: Ahmad Fatoum <ahmad at a3f.at>
---
 Makefile                | 2 ++
 common/Kconfig          | 7 +++++++
 defaultenv/Makefile     | 7 +++++++
 defaultenv/defaultenv.c | 2 ++
 scripts/Makefile.lib    | 3 +++
 5 files changed, 21 insertions(+)

diff --git a/Makefile b/Makefile
index a36608819da5..c13f3274c18c 100644
--- a/Makefile
+++ b/Makefile
@@ -358,6 +358,8 @@ endif
 
 KCONFIG_CONFIG	?= .config
 
+export KCONFIG_CONFIG
+
 # Default file for 'make defconfig'. This may be overridden by arch-Makefile.
 export KBUILD_DEFCONFIG := defconfig
 
diff --git a/common/Kconfig b/common/Kconfig
index 342817bbcbb4..2872c80dbf13 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -941,6 +941,13 @@ config DEFAULT_ENVIRONMENT_GENERIC_NEW_REBOOT_MODE
 	depends on DEFAULT_ENVIRONMENT_GENERIC_NEW
 	depends on REBOOT_MODE
 
+config DEFAULT_ENVIRONMENT_GENERIC_NEW_IKCONFIG
+	bool "Ship .config as /env/data/config"
+	help
+	  This option embeds the used barebox Kconfig .config file into the
+	  environment as /env/data/config. This will increases barebox image
+	  size. If unsure, say n here.
+
 config DEFAULT_ENVIRONMENT_PATH
 	string
 	depends on DEFAULT_ENVIRONMENT
diff --git a/defaultenv/Makefile b/defaultenv/Makefile
index 91293567c0d3..68790321187d 100644
--- a/defaultenv/Makefile
+++ b/defaultenv/Makefile
@@ -32,3 +32,10 @@ cmd_env_zero = ($(objtree)/scripts/bareboxenv -z $(CONFIG_DEFAULT_ENVIRONMENT_PA
 
 $(obj)/barebox_zero_env: FORCE
 	$(call if_changed,env_zero)
+
+bbenv-$(CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW_IKCONFIG) += defaultenv-2-ikconfig
+
+defaultenv/defaultenv-2-ikconfig.bbenv$(DEFAULT_COMPRESSION_SUFFIX): $(KCONFIG_CONFIG)
+	@mkdir -p defaultenv/defaultenv-2-ikconfig/data
+	@cp $(KCONFIG_CONFIG) defaultenv/defaultenv-2-ikconfig/data/config
+	$(call cmd,envgen,defaultenv/defaultenv-2-ikconfig)
diff --git a/defaultenv/defaultenv.c b/defaultenv/defaultenv.c
index d69446c8937a..055475eb4756 100644
--- a/defaultenv/defaultenv.c
+++ b/defaultenv/defaultenv.c
@@ -47,6 +47,8 @@ static void defaultenv_add_base(void)
 		defaultenv_append_directory(defaultenv_2_dfu);
 	if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW_REBOOT_MODE))
 		defaultenv_append_directory(defaultenv_2_reboot_mode);
+	if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW_IKCONFIG))
+		defaultenv_append_directory(defaultenv_2_ikconfig);
 	if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT_GENERIC))
 		defaultenv_append_directory(defaultenv_1);
 }
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 319ac19975ed..80d76b177c0a 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -365,6 +365,9 @@ cmd_env_S =							\
 $(obj)/%.bbenv$(DEFAULT_COMPRESSION_SUFFIX).S: $(src)/%.bbenv$(DEFAULT_COMPRESSION_SUFFIX) FORCE
 	$(call if_changed,env_S)
 
+quiet_cmd_envgen = ENVGEN  $@
+cmd_envgen=$(srctree)/scripts/genenv $(objtree) $(objtree) $@ $2
+
 quiet_cmd_env = ENV     $@
 cmd_env=$(srctree)/scripts/genenv $(srctree) $(objtree) $@ $<
 
-- 
2.30.0




More information about the barebox mailing list