Skip to contentSkip to conversation

package/uboot-tools: use uboot host tool printinitialenv to extract env

PATCH Superseded Heiko Thiery 2 participants 4 messages Sep 5, 2025 – Dec 3, 2025

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/uboot-tools: use uboot host tool printinitialenv to extract env

If u-boot is compiled with the LTO option, it is no longer possible to use the script 'get_default_envs.sh'. 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.

Instead of using the script the new tool 'printinitialenv' 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

---

The question I ask myself is, how can this problem be solved for older U-Boot versions, or how can both options be supported? With the proposed option, old U-Boats will no longer build.

 boot/uboot/uboot.mk                | 4 ++++
 package/uboot-tools/uboot-tools.mk | 5 +----
 2 files changed, 5 insertions(+), 4 deletions(-)
boot/uboot/uboot.mk +4 -0
index 2796b0a310..66264bb3f0 100644
@@ -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
package/uboot-tools/uboot-tools.mk +1 -4
index 1925047ccd..25d7b26c6a 100644
@@ -154,10 +154,7 @@ 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)
+	$(UBOOT_SRCDIR)/tools/printinitialenv > $(UBOOT_TOOLS_GENERATE_ENV_FILE)
 endef
 endif # UBOOT_TOOLS_GENERATE_ENV_FILE
 endif # BR2_TARGET_UBOOT
Signature · 6 lines
2.39.5

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Hi,

I add Arnout here with the actual address, since I used his old mail address.

Am Fr., 5. Sept. 2025 um 14:38 Uhr schrieb Heiko Thiery <[email protected]>:

Quoted 54 lines

If u-boot is compiled with the LTO option, it is no longer possible to use the script 'get_default_envs.sh'. 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.

Instead of using the script the new tool 'printinitialenv' 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

---

The question I ask myself is, how can this problem be solved for older U-Boot versions, or how can both options be supported? With the proposed option, old U-Boats will no longer build.

 boot/uboot/uboot.mk                | 4 ++++
 package/uboot-tools/uboot-tools.mk | 5 +----
 2 files changed, 5 insertions(+), 4 deletions(-)
boot/uboot/uboot.mk +4 -0
index 2796b0a310..66264bb3f0 100644
@@ -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
package/uboot-tools/uboot-tools.mk +1 -5
index 1925047ccd..25d7b26c6a 100644
@@ -154,10 +154,7 @@ 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)
+       $(UBOOT_SRCDIR)/tools/printinitialenv > $(UBOOT_TOOLS_GENERATE_ENV_FILE)
 endef
 endif # UBOOT_TOOLS_GENERATE_ENV_FILE
 endif # BR2_TARGET_UBOOT
--
Quoted 2 lines

2.39.5

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw

Hi,

Quoted 11 lines · Heiko Thiery
Quoted 11 lines

If u-boot is compiled with the LTO option, it is no longer possible to use the script 'get_default_envs.sh'. 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.

Instead of using the script the new tool 'printinitialenv' 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

Is there any update on this? This really blocks us using the stock buildroot with CONFIG_LTO in the bootloader (which is the default for the TI SoCs now) and BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE.

-michael

Quoted 5 lines
Quoted 5 lines

---

The question I ask myself is, how can this problem be solved for older U-Boot versions, or how can both options be supported? With the proposed option, old U-Boats will no longer build.

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw
In reply to Heiko Thiery
Quoted 8 lines · Heiko Thiery

If u-boot is compiled with the LTO option, it is no longer possible to use the script 'get_default_envs.sh'. 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.

Instead of using the script the new tool 'printinitialenv' is used. The tool is build with u-boot that is a dependency of this package.

Quoted 8 lines

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

---

The question I ask myself is, how can this problem be solved for older U-Boot versions, or how can both options be supported? With the proposed option, old U-Boats will no longer build.

See below.

Quoted 25 lines
  boot/uboot/uboot.mk                | 4 ++++
  package/uboot-tools/uboot-tools.mk | 5 +----
  2 files changed, 5 insertions(+), 4 deletions(-)
boot/uboot/uboot.mk +4 -0
index 2796b0a310..66264bb3f0 100644
@@ -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
package/uboot-tools/uboot-tools.mk +0 -0
index 1925047ccd..25d7b26c6a 100644

package/uboot-tools/uboot-tools.mk HOST_UBOOT_TOOLS_DEPENDENCIES += uboot · line 157

Quoted 8 lines
package/uboot-tools/uboot-tools.mk +1 -4
@@ -154,10 +154,7 @@ 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)
+	$(UBOOT_SRCDIR)/tools/printinitialenv > $(UBOOT_TOOLS_GENERATE_ENV_FILE)

You can use a shell condition here to choose one or the other based on existence:

	if [ -x $(UBOOT_SRCDIR)/tools/printinitialenv ]; then
		... Use pintinitialenv ...
	else
		... Use get_default_envs.sh ...
	fi

Regards,
Arnout

package/uboot-tools/uboot-tools.mk HOST_UBOOT_TOOLS_DEPENDENCIES += uboot · line 160

Quoted 3 lines
package/uboot-tools/uboot-tools.mk +0 -0
  endef
  endif # UBOOT_TOOLS_GENERATE_ENV_FILE
  endif # BR2_TARGET_UBOOT

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot