Skip to contentSkip to conversation

package/uboot: detect missing user-supplied environment source files

PATCH New Yann E. MORIN 3 participants 3 messages Dec 9, 2017 – Dec 27, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 package/uboot: detect missing user-supplied environment source files

Since 0542bb79e8 (uboot: Support multiple environment source files), missing user-supplied environment source files is no longer detected.

This is because we cat them all, and feed the concatenation to the stdin of mkenvimage. So, if one source file is missing, the cat exits in error, but the compound command exits with the exit code of the last command, which is that of mkenvimage, which happens to be happy with whatever it is fed on its stdin, even is empty.

We fix that by creating a temporary file, that we even leave afterward for the user to inspect.

We also move it out of the _CMDS block and into a macro of its own, so that it is easier to write and maintain.

Cc Cam Hutchison <[email protected]>
Cc Thomas Petazzoni <[email protected]>

---
Changes v2 -> v3:
- generate inter;ediate file in $(@D) to avoid conflicts with

    user-generated files in $(O)/images/  (Cam)

- typo

Changes v1 -> v2:
- move into its own macro (Thomas)

---
 boot/uboot/uboot.mk | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
boot/uboot/uboot.mk +13 -6
index 39175999ec..d2f241cd8b 100644
@@ -243,6 +243,18 @@ define UBOOT_BUILD_OMAP_IFT
 		-c $(call qstrip,$(BR2_TARGET_UBOOT_OMAP_IFT_CONFIG))
 endef
 
+ifneq ($(BR2_TARGET_UBOOT_ENVIMAGE),)
+define UBOOT_GENERATE_ENV_IMAGE
+	cat $(call qstrip,$(BR2_TARGET_UBOOT_ENVIMAGE_SOURCE)) \
+		>$(@D)/buildroot-env.txt
+	$(HOST_DIR)/bin/mkenvimage -s $(BR2_TARGET_UBOOT_ENVIMAGE_SIZE) \
+		$(if $(BR2_TARGET_UBOOT_ENVIMAGE_REDUNDANT),-r) \
+		$(if $(filter BIG,$(BR2_ENDIAN)),-b) \
+		-o $(BINARIES_DIR)/uboot-env.bin \
+		$(@D)/buildroot-env.txt
+endef
+endif
+
 define UBOOT_INSTALL_IMAGES_CMDS
 	$(foreach f,$(UBOOT_BINS), \
 			cp -dpf $(@D)/$(f) $(BINARIES_DIR)/
@@ -254,12 +266,7 @@ define UBOOT_INSTALL_IMAGES_CMDS
 			cp -dpf $(@D)/$(f) $(BINARIES_DIR)/
 		)
 	)
-	$(if $(BR2_TARGET_UBOOT_ENVIMAGE),
-		cat $(call qstrip,$(BR2_TARGET_UBOOT_ENVIMAGE_SOURCE)) | \
-			$(HOST_DIR)/bin/mkenvimage -s $(BR2_TARGET_UBOOT_ENVIMAGE_SIZE) \
-			$(if $(BR2_TARGET_UBOOT_ENVIMAGE_REDUNDANT),-r) \
-			$(if $(filter BIG,$(BR2_ENDIAN)),-b) \
-			-o $(BINARIES_DIR)/uboot-env.bin -)
+	$(UBOOT_GENERATE_ENV_IMAGE)
 	$(if $(BR2_TARGET_UBOOT_BOOT_SCRIPT),
 		$(HOST_DIR)/bin/mkimage -C none -A $(MKIMAGE_ARCH) -T script \
 			-d $(call qstrip,$(BR2_TARGET_UBOOT_BOOT_SCRIPT_SOURCE)) \
Signature · 1 line
2.11.0
#1 lore raw

PATCH v3 1/1 package/uboot: detect missing user-supplied environment source files

Hello,

Quoted 19 lines · Yann E. MORIN

Since 0542bb79e8 (uboot: Support multiple environment source files), missing user-supplied environment source files is no longer detected.

This is because we cat them all, and feed the concatenation to the stdin of mkenvimage. So, if one source file is missing, the cat exits in error, but the compound command exits with the exit code of the last command, which is that of mkenvimage, which happens to be happy with whatever it is fed on its stdin, even is empty.

We fix that by creating a temporary file, that we even leave afterward for the user to inspect.

We also move it out of the _CMDS block and into a macro of its own, so that it is easier to write and maintain.

Cc Cam Hutchison <[email protected]>
Cc Thomas Petazzoni <[email protected]>
Quoted 5 lines

---
Changes v2 -> v3:
- generate inter;ediate file in $(@D) to avoid conflicts with

    user-generated files in $(O)/images/  (Cam)

- typo

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH v3 1/1 package/uboot: detect missing user-supplied environment source files

In reply to Yann E. MORIN
Quoted 21 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

Since 0542bb79e8 (uboot: Support multiple environment source files), missing user-supplied environment source files is no longer detected.

This is because we cat them all, and feed the concatenation to the stdin of mkenvimage. So, if one source file is missing, the cat exits in error, but the compound command exits with the exit code of the last command, which is that of mkenvimage, which happens to be happy with whatever it is fed on its stdin, even is empty.

We fix that by creating a temporary file, that we even leave afterward for the user to inspect.

We also move it out of the _CMDS block and into a macro of its own, so that it is easier to write and maintain.

Cc Cam Hutchison <[email protected]>
Cc Thomas Petazzoni <[email protected]>
Quoted 5 lines

---
Changes v2 -> v3:
- generate inter;ediate file in $(@D) to avoid conflicts with

    user-generated files in $(O)/images/  (Cam)

- typo

Committed to 2017.11.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard