mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Ladislav Michl <oss-lists@triops.cz>
To: ptxdist@pengutronix.de
Subject: [ptxdist] [RFC] u-boot: Build in default envinronment from file
Date: Mon, 1 Jun 2026 15:42:49 +0200	[thread overview]
Message-ID: <ah2MWYyOJMJrrkcm@lenoch> (raw)

Incorporating default envinroment from external file makes changes to it
much easier compared to creating patch for u-boot creating config file
with CONFIG_EXTRA_ENV_SETTINGS macro.
This however requires xxd tool, so question is where to get it from?
1. leave to user, similar as HOST_SYSTEM_BC is made
2. add HOST_XXD, make it depend on HOST_VIM to reuse archive and compile
   just xxd
3. patch u-boot to not use xxd

Except for the last case we would need something like 
select HOST_XXD if U_BOOT_DEFAULT_ENV
in the Kconfig.

Also, do we want envinronment file name configurable?

Thanks for the suggestions,
	ladis

---
 platforms/u-boot.in |  9 +++++++++
 rules/u-boot.make   | 23 +++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/platforms/u-boot.in b/platforms/u-boot.in
index d263135ca..c1abe3930 100644
--- a/platforms/u-boot.in
+++ b/platforms/u-boot.in
@@ -73,6 +73,15 @@ config U_BOOT_CONFIGFILE_KCONFIG
 	help
 	  This entry specifies the .config file used to compile U-Boot.
 
+config U_BOOT_DEFAULT_ENV
+	prompt "compile in default environment from file"
+	bool
+	help
+	  Text file uboot-defaultenv.txt in the platform config directory
+	  describing the builtin default environment.
+	  The file should have lines in the form var=value, one per line.
+	  Blank lines and lines starting with a # are ignored.
+
 endif
 
 if U_BOOT_CONFIGSYSTEM_LEGACY
diff --git a/rules/u-boot.make b/rules/u-boot.make
index d3ea65cf2..1966ba9b6 100644
--- a/rules/u-boot.make
+++ b/rules/u-boot.make
@@ -39,6 +39,11 @@ endif
 U_BOOT_INJECT_PATH	:= ${PTXDIST_SYSROOT_TARGET}/usr/lib/firmware
 U_BOOT_INJECT_OOT	:= $(call ptx/ifdef, PTXCONF_U_BOOT_BUILD_OOT,YES,NO)
 
+ifdef PTXCONF_U_BOOT_DEFAULT_ENV
+U_BOOT_DEFAULT_ENV_TXT	:= $(call ptx/in-platformconfigdir, uboot-defaultenv.txt)
+$(call ptx/cfghash-file, U_BOOT, $(U_BOOT_DEFAULT_ENV_TXT))
+endif
+
 ifdef PTXCONF_U_BOOT_BOOT_SCRIPT
 U_BOOT_BOOT_SCRIPT_TXT := $(call ptx/in-platformconfigdir, uboot.scr)
 U_BOOT_BOOT_SCRIPT_BIN := $(call remove_quotes, \
@@ -119,6 +124,24 @@ endif
 
 $(STATEDIR)/u-boot.compile:
 	@$(call targetinfo)
+ifdef PTXCONF_U_BOOT_DEFAULT_ENV
+	@rm -rf $(U_BOOT_BUILD_DIR)/.ptxdist-defaultenv
+	@ln -s $(U_BOOT_DEFAULT_ENV_TXT) $(U_BOOT_BUILD_DIR)/.ptxdist-defaultenv
+#	# pre-2025.10
+	@sed -i -e 's,^.*CONFIG_USE_DEFAULT_ENV_FILE.*$$,CONFIG_USE_DEFAULT_ENV_FILE=y,g' \
+		$(U_BOOT_BUILD_DIR)/.config
+	@sed -i -e '/\\<CONFIG_DEFAULT_ENV_FILE\\>/d' \
+		$(U_BOOT_BUILD_DIR)/.config
+	@sed -i -e '/CONFIG_USE_DEFAULT_ENV_FILE=y/a CONFIG_DEFAULT_ENV_FILE=".ptxdist-defaultenv"' \
+		$(U_BOOT_BUILD_DIR)/.config
+#	# 2025.10 and later
+	@sed -i -e 's,^.*CONFIG_ENV_USE_DEFAULT_ENV_TEXT_FILE.*$$,CONFIG_ENV_USE_DEFAULT_ENV_TEXT_FILE=y,g' \
+		$(U_BOOT_BUILD_DIR)/.config
+	@sed -i -e '/\\<CONFIG_ENV_DEFAULT_ENV_TEXT_FILE\\>/d' \
+		$(U_BOOT_BUILD_DIR)/.config
+	@sed -i -e '/CONFIG_ENV_USE_DEFAULT_ENV_TEXT_FILE=y/a CONFIG_ENV_DEFAULT_ENV_TEXT_FILE=".ptxdist-defaultenv"' \
+		$(U_BOOT_BUILD_DIR)/.config
+endif
 	@$(call world/compile, U_BOOT)
 ifdef PTXCONF_U_BOOT_VERIFY_SIGNATURE
 	@mv $(U_BOOT_BUILD_DIR)/u-boot.dtb $(U_BOOT_BUILD_DIR)/u-boot-pubkey.dtb
-- 
2.47.3




             reply	other threads:[~2026-06-01 13:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01 13:42 Ladislav Michl [this message]
2026-06-05 14:34 ` Michael Olbrich
2026-06-05 15:13   ` Ladislav Michl
2026-06-05 15:46     ` Michael Olbrich
2026-06-05 15:52       ` Ladislav Michl

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=ah2MWYyOJMJrrkcm@lenoch \
    --to=oss-lists@triops.cz \
    --cc=ptxdist@pengutronix.de \
    /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