Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v2] package/uboot-tools: use U-Boot host tool printinitialenv to extract environment
@ 2026-01-05 13:23 Heiko Thiery
  2026-01-05 13:42 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 5+ messages in thread
From: Heiko Thiery @ 2026-01-05 13:23 UTC (permalink / raw)
  To: buildroot; +Cc: Matt Weber, Michael Walle, Heiko Thiery, Thomas Petazzoni

If u-boot is compiled with the LTO option, it is no longer possible to
use the script 'get_default_envs.sh' for creating an initial U-boot
environment binary image. The problem was already observed and a solution
available upstream u-boot since the commit 486aef08de09 [1].

This was first available in release v2023.04.

Now if the the new tool 'printinitialenv' is available it is used. The
tool is build with u-boot that is a dependency of this package.

[1] https://source.denx.de/u-boot/custodians/u-boot-tegra/-/commit/486aef08de091ca35386f32fe961a201c3cfa9d4

Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
---
v2:
    - used hint from Arnout to check for availibity of the new tool

 boot/uboot/uboot.mk                | 4 ++++
 package/uboot-tools/uboot-tools.mk | 9 +++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk
index c92568a559..e613d015a9 100644
--- a/boot/uboot/uboot.mk
+++ b/boot/uboot/uboot.mk
@@ -144,6 +144,10 @@ UBOOT_MAKE_TARGET += u-boot.stm32
 endif
 endif
 
+ifeq ($(BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE),y)
+UBOOT_MAKE_TARGET += u-boot-initial-env
+endif
+
 ifeq ($(BR2_TARGET_UBOOT_INITIAL_ENV),y)
 UBOOT_MAKE_TARGET += u-boot-initial-env
 define UBOOT_INSTALL_UBOOT_INITIAL_ENV
diff --git a/package/uboot-tools/uboot-tools.mk b/package/uboot-tools/uboot-tools.mk
index 1925047ccd..f8d9cae270 100644
--- a/package/uboot-tools/uboot-tools.mk
+++ b/package/uboot-tools/uboot-tools.mk
@@ -154,10 +154,11 @@ HOST_UBOOT_TOOLS_DEPENDENCIES += uboot
 ifeq ($(UBOOT_TOOLS_GENERATE_ENV_FILE),)
 UBOOT_TOOLS_GENERATE_ENV_FILE = $(@D)/boot-env-defaults.txt
 define HOST_UBOOT_TOOLS_GENERATE_ENV_DEFAULTS
-	CROSS_COMPILE="$(TARGET_CROSS)" \
-		$(UBOOT_SRCDIR)/scripts/get_default_envs.sh \
-		$(UBOOT_SRCDIR) \
-		> $(UBOOT_TOOLS_GENERATE_ENV_FILE)
+	if [ -x $(UBOOT_SRCDIR)/tools/printinitialenv ]; then \
+		$(UBOOT_SRCDIR)/tools/printinitialenv > $(UBOOT_TOOLS_GENERATE_ENV_FILE); \
+	else \
+		CROSS_COMPILE="$(TARGET_CROSS)" $(UBOOT_SRCDIR)/scripts/get_default_envs.sh $(UBOOT_SRCDIR); \
+	fi
 endef
 endif # UBOOT_TOOLS_GENERATE_ENV_FILE
 endif # BR2_TARGET_UBOOT
-- 
2.39.5

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Buildroot] [PATCH v2] package/uboot-tools: use U-Boot host tool printinitialenv to extract environment
  2026-01-05 13:23 [Buildroot] [PATCH v2] package/uboot-tools: use U-Boot host tool printinitialenv to extract environment Heiko Thiery
@ 2026-01-05 13:42 ` Thomas Petazzoni via buildroot
  2026-01-05 13:50   ` Heiko Thiery
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-01-05 13:42 UTC (permalink / raw)
  To: Heiko Thiery; +Cc: Matt Weber, Michael Walle, buildroot

Hello Heiko,

On Mon,  5 Jan 2026 14:23:27 +0100
Heiko Thiery <heiko.thiery@gmail.com> wrote:

> +	if [ -x $(UBOOT_SRCDIR)/tools/printinitialenv ]; then \
> +		$(UBOOT_SRCDIR)/tools/printinitialenv > $(UBOOT_TOOLS_GENERATE_ENV_FILE); \
> +	else \
> +		CROSS_COMPILE="$(TARGET_CROSS)" $(UBOOT_SRCDIR)/scripts/get_default_envs.sh $(UBOOT_SRCDIR); \

Aren't you now missing the > $(UBOOT_TOOLS_GENERATE_ENV_FILE)
redirection in this "else" clause ?

I'm not sure why we're using $(UBOOT_SRCDIR) in all of this instead of
$(@D), but that's a comment unrelated to your change.

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Buildroot] [PATCH v2] package/uboot-tools: use U-Boot host tool printinitialenv to extract environment
  2026-01-05 13:42 ` Thomas Petazzoni via buildroot
@ 2026-01-05 13:50   ` Heiko Thiery
  2026-01-05 13:56     ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 5+ messages in thread
From: Heiko Thiery @ 2026-01-05 13:50 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: Matt Weber, Michael Walle, buildroot

Hi Thomas,

Am Mo., 5. Jan. 2026 um 14:42 Uhr schrieb Thomas Petazzoni
<thomas.petazzoni@bootlin.com>:
>
> Hello Heiko,
>
> On Mon,  5 Jan 2026 14:23:27 +0100
> Heiko Thiery <heiko.thiery@gmail.com> wrote:
>
> > +     if [ -x $(UBOOT_SRCDIR)/tools/printinitialenv ]; then \
> > +             $(UBOOT_SRCDIR)/tools/printinitialenv > $(UBOOT_TOOLS_GENERATE_ENV_FILE); \
> > +     else \
> > +             CROSS_COMPILE="$(TARGET_CROSS)" $(UBOOT_SRCDIR)/scripts/get_default_envs.sh $(UBOOT_SRCDIR); \
>
> Aren't you now missing the > $(UBOOT_TOOLS_GENERATE_ENV_FILE)
> redirection in this "else" clause ?


you are right ;-/

>
>
> I'm not sure why we're using $(UBOOT_SRCDIR) in all of this instead of
> $(@D), but that's a comment unrelated to your change.
>

At least for the first case we need to use the file coming from the
built U-Boot and not from the used sources from u-boot-tools package
(an older U-Boot version). How it is for the "old" path I do not know
if we could use here the script from the u-boot-tools package version
or if it is also related to the U-Boot sources related to the
environment.

>
> Thomas
> --
> Thomas Petazzoni, co-owner and CEO, Bootlin
> Embedded Linux and Kernel engineering and training
> https://bootlin.com


-- 
BR
Heiko
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Buildroot] [PATCH v2] package/uboot-tools: use U-Boot host tool printinitialenv to extract environment
  2026-01-05 13:50   ` Heiko Thiery
@ 2026-01-05 13:56     ` Thomas Petazzoni via buildroot
  2026-01-05 15:31       ` Arnout Vandecappelle via buildroot
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-01-05 13:56 UTC (permalink / raw)
  To: Heiko Thiery; +Cc: Matt Weber, Michael Walle, buildroot

On Mon, 5 Jan 2026 14:50:44 +0100
Heiko Thiery <heiko.thiery@gmail.com> wrote:

> > I'm not sure why we're using $(UBOOT_SRCDIR) in all of this instead of
> > $(@D), but that's a comment unrelated to your change.
> 
> At least for the first case we need to use the file coming from the
> built U-Boot and not from the used sources from u-boot-tools package
> (an older U-Boot version). How it is for the "old" path I do not know
> if we could use here the script from the u-boot-tools package version
> or if it is also related to the U-Boot sources related to the
> environment.

Aaah, yes, indeed.

Isn't it a bit crappy that the uboot-tools package does that? This
logic is in uboot-tools, but it uses nothing from uboot-tools, only
stuff from the uboot package. But oh well, we're not going to
revolutionize this now :)

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Buildroot] [PATCH v2] package/uboot-tools: use U-Boot host tool printinitialenv to extract environment
  2026-01-05 13:56     ` Thomas Petazzoni via buildroot
@ 2026-01-05 15:31       ` Arnout Vandecappelle via buildroot
  0 siblings, 0 replies; 5+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2026-01-05 15:31 UTC (permalink / raw)
  To: Thomas Petazzoni, Heiko Thiery; +Cc: buildroot, Matt Weber, Michael Walle



On 05/01/2026 14:56, Thomas Petazzoni wrote:
> On Mon, 5 Jan 2026 14:50:44 +0100
> Heiko Thiery <heiko.thiery@gmail.com> wrote:
> 
>>> I'm not sure why we're using $(UBOOT_SRCDIR) in all of this instead of
>>> $(@D), but that's a comment unrelated to your change.
>>
>> At least for the first case we need to use the file coming from the
>> built U-Boot and not from the used sources from u-boot-tools package
>> (an older U-Boot version). How it is for the "old" path I do not know
>> if we could use here the script from the u-boot-tools package version
>> or if it is also related to the U-Boot sources related to the
>> environment.
> 
> Aaah, yes, indeed.
> 
> Isn't it a bit crappy that the uboot-tools package does that? This
> logic is in uboot-tools, but it uses nothing from uboot-tools, only
> stuff from the uboot package. But oh well, we're not going to
> revolutionize this now :)

  The file that comes out of it is used in HOST_UBOOT_TOOLS_GENERATE_ENVIMAGE. 
Of course, we could generate that file in uboot.mk and then use it in 
uboot-tools.mk, but then uboot.mk has to "know" that it needs to create this file...

  Regards,
  Arnout

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-01-05 15:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-05 13:23 [Buildroot] [PATCH v2] package/uboot-tools: use U-Boot host tool printinitialenv to extract environment Heiko Thiery
2026-01-05 13:42 ` Thomas Petazzoni via buildroot
2026-01-05 13:50   ` Heiko Thiery
2026-01-05 13:56     ` Thomas Petazzoni via buildroot
2026-01-05 15:31       ` Arnout Vandecappelle via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox