package/uboot-tools: use uboot host tool printinitialenv to extract env
PATCH v3 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.
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.
---
v3:
- fixed redirect (thanks Thomas)
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(-)
boot/uboot/uboot.mk +4 -0
@@ -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 +5 -4
@@ -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
Signature · 6 lines
2.39.5 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Heiko,
Quoted 6 lines · On Tue, 6 Jan 2026 16:10:23 +0100 Heiko Thiery <[email protected]> wrote:
package/uboot-tools/uboot-tools.mk +0
-0@@ -154,10 +154,11 @@ HOST_UBOOT_TOOLS_DEPENDENCIES += uboot ifeq ($(UBOOT_TOOLS_GENERATE_ENV_FILE),)
package/uboot-tools/uboot-tools.mk HOST_UBOOT_TOOLS_DEPENDENCIES += uboot · line 160
Quoted 10 lines
package/uboot-tools/uboot-tools.mk +4
-4UBOOT_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); \
The redirect is still broken here, this command line is not correct, as it's not the same as it used to be.
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hi,
Am Di., 6. Jan. 2026 um 16:43 Uhr schrieb Thomas Petazzoni <[email protected]>:
Quoted 17 lines
Hello Heiko,
Quoted 11 lines · On Tue, 6 Jan 2026 16:10:23 +0100 Heiko Thiery <[email protected]> wrote:
package/uboot-tools/uboot-tools.mk +0
-3@@ -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) \
Quoted 9 lines
package/uboot-tools/uboot-tools.mk HOST_UBOOT_TOOLS_DEPENDENCIES += uboot · line 160
Quoted 5 lines
package/uboot-tools/uboot-tools.mk +4
-1- > $(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); \The redirect is still broken here, this command line is not correct, as it's not the same as it used to be.
shame on me .. I shouldn't do things like that on the side and then send them out untested.
Quoted 5 lines
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot