From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Fri, 05 Jun 2026 17:52:48 +0200 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wVWqm-002fBM-2C for lore@lore.pengutronix.de; Fri, 05 Jun 2026 17:52:48 +0200 Received: from [127.0.0.1] (helo=metis.whiteo.stw.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1wVWqm-0006MT-I9; Fri, 05 Jun 2026 17:52:48 +0200 Received: from h2.cmg2.smtp.forpsi.com ([81.2.195.189]) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1wVWqf-0006ML-Q7 for ptxdist@pengutronix.de; Fri, 05 Jun 2026 17:52:42 +0200 Received: from lenoch ([91.218.190.200]) by cmgsmtp with ESMTPSA id VWqewpu0lPXKbVWqfwxI6q; Fri, 05 Jun 2026 17:52:41 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=triops.cz; s=f2019; t=1780674761; bh=gIL/83gn/R3LqejFS23Vdatu8xYL4laouhkuP5Ef/IY=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type; b=MG0JZwoXey1NSO9Pu09Yse+0a7/9O7yEEcL89MgDHUmbhh3JgNbttxHjOPFRiTXiL gF2g5/jLjt36i+//ZHeGJmFCaiKc24ODFDaj0ZF5wWIU6NfmpeWDqxSuDNLzdlypUf PiD8SFG4/Fbyo6Fl5HtiIzAZIzqd0ZXwhQkFgtgv20pmM6eFyZtkRX7Jnk554iQXn1 oaxvhjvirtoKU08sNrM1LhM8HRHuj9H0FjTdRfcguonCYVeYRETPFJItodZMHraOUB rKMEg+y/U0McorkeWcu8PRxA4EJu38Catxjnf3/7/d+WH0CH8PFCchPD/VL07Op2Sp u4jA33ZRd+nUg== Date: Fri, 5 Jun 2026 17:52:39 +0200 From: Ladislav Michl To: ptxdist@pengutronix.de Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-CMAE-Envelope: MS4xfGFRWQP9vT1xgX+jgQuomshtKmL4FTIfAX8t+cZM7fg0qHxZhD/tgri492acJFXYoJSFcCXmMmMgKunfbwaye9qXxZ5fx37J22xIGoRTgQwLFpbEyZ6u fr/WqutD3djTyUJDhcgIP+BeUsWW/BN631iRPaOkq8dKmVkqh2pDGUYb+zeqH3U9Q7WhCjfr7LvZ2Q== X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.whiteo.stw.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-2.3 required=4.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [ptxdist] [RFC] u-boot: Build in default envinronment from file X-BeenThere: ptxdist@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Sender: "ptxdist" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: ptxdist-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false On Fri, Jun 05, 2026 at 05:46:49PM +0200, Michael Olbrich wrote: > On Fri, Jun 05, 2026 at 05:13:29PM +0200, Ladislav Michl wrote: > > On Fri, Jun 05, 2026 at 04:34:04PM +0200, Michael Olbrich wrote: > > > On Mon, Jun 01, 2026 at 03:42:49PM +0200, Ladislav Michl wrote: > > > > 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 > > > > > > I think we can go with this one. > > > > > > > 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? > > > > > > No, there is no good reason for something like that. > > > > > > > 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 > > > > > > Did you test this with PTXCONF_U_BOOT_BUILD_OOT enabled? > > > > In fact I tested only OOT build... > > > > > > + @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 '/\\/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 '/\\/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 > > > > > > I'd like to avoid patching the config like that. I know we do it in barebox > > > as well, but: > > > > Indeed, barebox was my inspiration. > > > > > 1. it's an absolute path that cannot be in the config > > > 2. only the variable with the path, not enabling it as well > > > 3. legacy, so changing it will break things. > > > > > > Please just check here, that the correct options are set and describe what > > > needs to be done in the menu help. > > > > Just to be clear: are you suggesting to propose a filename user will > > set in u-boot config and the only thing ptxdist does then is to provide > > a symling of that name? So I can delete all those nice sed regular > > expressions... ;-) What is the suggested default environment name then? > > What I mean is: Keep everything but the 'sed' stuff and replace that with > some 'grep .. || ptxd_bailout "some error message"' to ensure, that the > file is actually used. That just reverses the problem: u-boot can change yet another time, so testing with grep will work, while envinronment is not used. All at the expense making it less comfortable for the poor developer. > Michael > > > > Michael > > > > > > > +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 > > > > > > > > > > > > > > > > > > -- > > > Pengutronix e.K. | | > > > Steuerwalder Str. 21 | http://www.pengutronix.de/ | > > > 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | > > > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | > > > > > > -- > Pengutronix e.K. | | > Steuerwalder Str. 21 | http://www.pengutronix.de/ | > 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |