[PATCH 11/12] defaultenv: add barebox_modules_env target
Ahmad Fatoum
a.fatoum at barebox.org
Thu Jan 15 03:54:37 PST 2026
We want a single file with all modules to make it easier to load them
inside emulation. Add a very simple environment target to facilitate
this.
There may be room for improvement as enabling CONFIG_MODULES_ENVIRONMENT
triggers the rebuild every time, but for experimental feature that's
not enabled by default, it should be acceptable for now.
Co-developed-by: Claude <noreply at claude.ai>
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
Makefile | 14 ++++++++++++++
common/Kconfig | 14 ++++++++++++++
defaultenv/.gitignore | 1 +
3 files changed, 29 insertions(+)
diff --git a/Makefile b/Makefile
index b6023dc4ff2c..9c70aa0f49a3 100644
--- a/Makefile
+++ b/Makefile
@@ -1341,6 +1341,20 @@ else
depmod_opts := -b $(INSTALL_MOD_PATH) -r
endif
+# Target to build modules environment
+MODULES_ENV_DIR := $(objtree)/.tmp_barebox_modules_env
+CLEAN_DIRS += $(MODULES_ENV_DIR)
+
+barebox_modules_env: modules FORCE
+ $(Q)rm -rf $(MODULES_ENV_DIR)
+ $(Q)$(MAKE) -f $(srctree)/Makefile modules_install MODLIB=$(MODULES_ENV_DIR)
+ $(Q)$(objtree)/scripts/bareboxenv -s $(MODULES_ENV_DIR)/barebox $@
+ $(Q)mv barebox_modules_env $(objtree)/defaultenv/
+
+ifdef CONFIG_MODULES_ENVIRONMENT
+all: barebox_modules_env
+endif
+
else # CONFIG_MODULES
# Modules not configured
diff --git a/common/Kconfig b/common/Kconfig
index d4d9d930a996..50c26695b2b5 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -356,6 +356,20 @@ config MODULES
As modules can't be signed, loading external modules is not
recommended for secure systems.
+config MODULES_ENVIRONMENT
+ bool "Build environment with all modules"
+ depends on MODULES
+ help
+ This option creates a separate environment file (barebox_modules_env)
+ containing all built modules in stripped form. This environment is
+ not built into barebox but can be flashed separately and mounted
+ at runtime to load modules.
+
+ The modules are taken from the barebox/ directory inside $MODLIB
+ after running modules_install and have been stripped.
+
+ If unsure, say n here.
+
config KALLSYMS
depends on HAS_KALLSYMS
bool "kallsyms"
diff --git a/defaultenv/.gitignore b/defaultenv/.gitignore
index d14aa0f494b5..7847b5ce19d6 100644
--- a/defaultenv/.gitignore
+++ b/defaultenv/.gitignore
@@ -2,4 +2,5 @@
barebox_default_env*
barebox_zero_env
+barebox_modules_env
defaultenv-2-ikconfig/
--
2.47.3
More information about the barebox
mailing list