Mender u-boot env vars missing from manual patch?

Hi, I’m attempting to integrate Mender client into our Yocto Zeus build for a custom iMX6ULL board. Our source for u-boot is set up for EXTERNAL_SRC, so I have to do the manual patching via

The resulting patchfile (pasted below) seems to be missing the Mender env variables (mender_setup, mender_saveenv_canary, etc.) that are mentioned in this post:
https://hub.mender.io/t/beaglebone-missing-default-u-boot-environment-in-mmc/1505/6

Should these variables still be added to u-boot env?

Thanks,
Stu

diff -r -u /yocto-src/build/tmp/work/hermes-poky-linux-gnueabi/u-boot-imx/1_2020.04-r2/old-src/configs/hermes_uboot_emmc_defconfig /yocto-src/build/tmp/work/hermes-poky-linux-gnueabi/u-boot-imx/1_2020.04-r2/git/configs/hermes_uboot_emmc_defconfig
--- a/configs/hermes_uboot_emmc_defconfig	2021-02-08 22:20:09.582784106 +0000
+++ b/configs/hermes_uboot_emmc_defconfig	2021-02-08 22:20:54.975950846 +0000
@@ -1,8 +1,6 @@
 CONFIG_ARM=y
 CONFIG_ARCH_MX6=y
 CONFIG_TARGET_HERMES=y
-CONFIG_ENV_SIZE=0x2000
-CONFIG_ENV_OFFSET=0xE0000
 CONFIG_DM_GPIO=y
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/orro/hermes/imximage.cfg"
@@ -33,7 +31,6 @@
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="hermes"
-CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_DM_74X164=y
@@ -84,3 +81,32 @@
 CONFIG_FASTBOOT_BUF_SIZE=0x40000000
 CONFIG_FASTBOOT_FLASH=y
 CONFIG_EFI_PARTITION=y
+CONFIG_ENV_SIZE=0x20000
+CONFIG_ENV_OFFSET=0x100000
+CONFIG_ENV_OFFSET_REDUND=0x200000
+CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
+# CONFIG_ENV_IS_NOWHERE is not set
+# CONFIG_ENV_IS_IN_EEPROM is not set
+# CONFIG_ENV_IS_IN_FAT is not set
+# CONFIG_ENV_IS_IN_EXT4 is not set
+# CONFIG_ENV_IS_IN_FLASH is not set
+# CONFIG_ENV_IS_IN_NAND is not set
+# CONFIG_ENV_IS_IN_NVRAM is not set
+# CONFIG_ENV_IS_IN_ONENAND is not set
+# CONFIG_ENV_IS_IN_REMOTE is not set
+# CONFIG_ENV_IS_IN_SATA is not set
+# CONFIG_ENV_IS_IN_SPI_FLASH is not set
+# CONFIG_ENV_IS_IN_UBI is not set
+CONFIG_MMC=y
+CONFIG_ENV_IS_IN_MMC=y
+# CONFIG_BOOTCOUNT_BOOTLIMIT is not set
+# CONFIG_BOOTCOUNT_GENERIC is not set
+# CONFIG_BOOTCOUNT_EXT is not set
+# CONFIG_BOOTCOUNT_AM33XX is not set
+# CONFIG_BOOTCOUNT_RAM is not set
+# CONFIG_BOOTCOUNT_I2C is not set
+# CONFIG_BOOTCOUNT_AT91 is not set
+# CONFIG_BOOTCOUNT_ALEN is not set
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_ENV=y
+# CONFIG_BOOTCOMMAND is not set
Binary files /yocto-src/build/tmp/work/hermes-poky-linux-gnueabi/u-boot-imx/1_2020.04-r2/old-src/.git/index and /yocto-src/build/tmp/work/hermes-poky-linux-gnueabi/u-boot-imx/1_2020.04-r2/git/.git/index differ
diff -r -u /yocto-src/build/tmp/work/hermes-poky-linux-gnueabi/u-boot-imx/1_2020.04-r2/old-src/include/config_defaults.h /yocto-src/build/tmp/work/hermes-poky-linux-gnueabi/u-boot-imx/1_2020.04-r2/git/include/config_defaults.h
--- a/include/config_defaults.h	2021-02-08 22:20:09.866791406 +0000
+++ b/include/config_defaults.h	2021-02-08 22:20:54.631942004 +0000
@@ -10,3 +10,5 @@
 #define _CONFIG_DEFAULTS_H_
 
 #endif
+#define CONFIG_SYS_MMC_ENV_DEV 1
+#define CONFIG_SYS_MMC_ENV_PART 0
diff -r -u /yocto-src/build/tmp/work/hermes-poky-linux-gnueabi/u-boot-imx/1_2020.04-r2/old-src/include/configs/hermes.h /yocto-src/build/tmp/work/hermes-poky-linux-gnueabi/u-boot-imx/1_2020.04-r2/git/include/configs/hermes.h
--- a/include/configs/hermes.h	2021-02-08 22:20:09.882791817 +0000
+++ b/include/configs/hermes.h	2021-02-08 22:20:54.635942107 +0000
@@ -80,23 +80,16 @@
 	CONFIG_MFG_ENV_SETTINGS \
 	TEE_ENV \
 	"splashimage=0x8c000000\0" \
-	"fdt_addr=0x83000000\0" \
+	"fdt_addr_r=0x83000000\0" \
 	"fdt_high=0xffffffff\0"	  \
 	"tee_addr=0x84000000\0" \
 	"console=ttymxc0\0" \
 	"bootargs=console=ttymxc0,115200 ubi.mtd=nandrootfs "  \
-		"root=ubi0:rootfs rootfstype=ubifs "		     \
+		"rootfstype=ubifs "		     \
 		BOOTARGS_CMA_SIZE \
 		MFG_NAND_PARTITION \
 		"\0" \
-	"bootcmd=nand read ${loadaddr} 0x4000000 0xc00000;"\
-		"nand read ${fdt_addr} 0x5000000 0x100000;"\
-		"if test ${tee} = yes; then " \
-			"nand read ${tee_addr} 0x6000000 0x400000;"\
-			"bootm ${tee_addr} - ${fdt_addr};" \
-		"else " \
-			"bootz ${loadaddr} - ${fdt_addr};" \
-		"fi\0"
+
 
 #else
 #define CONFIG_EXTRA_ENV_SETTINGS \
@@ -108,7 +101,7 @@
 	"fdt_high=0xffffffff\0" \
 	"initrd_high=0xffffffff\0" \
 	"fdt_file=undefined\0" \
-	"fdt_addr=0x83000000\0" \
+	"fdt_addr_r=0x83000000\0" \
 	"tee_addr=0x84000000\0" \
 	"tee_file=undefined\0" \
 	"boot_fdt=try\0" \
@@ -120,7 +113,7 @@
 	"mmcautodetect=yes\0" \
 	"mmcargs=setenv bootargs console=${console},${baudrate} " \
 		BOOTARGS_CMA_SIZE \
-		"root=${mmcroot}\0" \
+		"\0" \
 	"loadbootscript=" \
 		"fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
 	"bootscript=echo Running bootscript from mmc ...; " \
@@ -149,7 +142,7 @@
 		"fi;\0" \
 	"netargs=setenv bootargs console=${console},${baudrate} " \
 		BOOTARGS_CMA_SIZE \
-		"root=/dev/nfs " \
+		"" \
 	"ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
 		"netboot=echo Booting from net ...; " \
 		"${usb_net_cmd}; " \
@@ -204,20 +197,6 @@
 				"fi; " \
 			"fi;\0" \
 
-#define CONFIG_BOOTCOMMAND \
-	   "run findfdt;" \
-	   "run findtee;" \
-	   "mmc dev ${mmcdev};" \
-	   "mmc dev ${mmcdev}; if mmc rescan; then " \
-		   "if run loadbootscript; then " \
-			   "run bootscript; " \
-		   "else " \
-			   "if run loadimage; then " \
-				   "run mmcboot; " \
-			   "else run netboot; " \
-			   "fi; " \
-		   "fi; " \
-	   "else run netboot; fi"
 #endif
 
 /* Miscellaneous configurable options */
@@ -240,8 +219,6 @@
 	(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
 
 /* environment organization */
-#define CONFIG_SYS_MMC_ENV_DEV		1	/* USDHC2 */
-#define CONFIG_SYS_MMC_ENV_PART		0	/* user area */
 #define CONFIG_MMCROOT			"/dev/mmcblk1p2"  /* USDHC2 */
 
 #define CONFIG_IOMUX_LPSR

Hi @sjuengst,

You seem to be missing this patch. If our docs are missing a step please let me know.

Drew

I see 4 Mender-provided patches in build/tmp/work/hermes-poky-linux-gnueabi/u-boot-imx/1_2020.04-r4

sjuengst@ernie:~/hermes-mender/yocto-src/build/tmp/work/hermes-poky-linux-gnueabi/u-boot-imx/1_2020.04-r4$ ls
0001-Add-missing-header-which-fails-on-recent-GCC.patch		 deploy-u-boot-imx	pkgdata		       sysroot-destdir
0002-Generic-boot-code-for-Mender.patch				 fw_env.config.default	pkgdata-pdata-input    temp
0003-Integration-of-Mender-boot-code-into-U-Boot.patch		 hermes			pkgdata-sysroot        uboot_auto_configure.sh
0004-Disable-CONFIG_BOOTCOMMAND-and-enable-CONFIG_MENDER_.patch  image			pseudo		       uboot_auto_patch.sh
add_kconfig_option_with_depends.py				 license-destdir	recipe-sysroot	       uboot.env
boolean.py							 package		recipe-sysroot-native  u-boot-imx-2020.04
deploy-rpms							 packages-split		src-tar		       u-boot-imx.spec

I assumed that bitbake -c save_mender_auto_configured_patch u-boot would consolidate them into mender_auto_configured.patch. Do I have to apply them manually myself and then do save_auto_configured_patch?

Thanks,

Stu

I had MENDER_UBOOT_AUTO_CONFIGURE set to “0” when I first ran save_mender_auto_configured_patch. It occurred to me that maybe it should be ‘1’ for generating the patch and then turned off afterwards (the docs don’t say which setting to use). I tried regenerating the patch with MENDER_UBOOT_AUTO_CONFIGURE = “1” and ran into another problem. It seems that the do_configure_append() in my u-boot-imx_2020.04.bbappend is not being executed when I run save_mender_auto_configured_patch (none of my board-specific files, _defconfig, etc. are being installed) so the build fails.

ERROR: u-boot-imx-1_2020.04-r6 do_mender_uboot_auto_configure: Execution of '/yocto-src/build/tmp/work/hermes-poky-linux-gnueabi/u-boot-imx/1_2020.04-r6/temp/run.do_mender_uboot_auto_configure.2808' failed with exit code 2:
If at any point you get an unexpanded variable, there is probably an argument
you haven't given.
+ SUB_X=-x
+ set -u
+ rm -rf /yocto-src/build/tmp/work/hermes-poky-linux-gnueabi/u-boot-imx/1_2020.04-r6/tmp-src
++ dirname /yocto-src/build/tmp/work/hermes-poky-linux-gnueabi/u-boot-imx/1_2020.04-r6/tmp-src
+ mkdir -p /yocto-src/build/tmp/work/hermes-poky-linux-gnueabi/u-boot-imx/1_2020.04-r6
+ cp -r /yocto-src/build/tmp/work/hermes-poky-linux-gnueabi/u-boot-imx/1_2020.04-r6/git /yocto-src/build/tmp/work/hermes-poky-linux-gnueabi/u-boot-imx/1_2020.04-r6/tmp-src
+ cd /yocto-src/build/tmp/work/hermes-poky-linux-gnueabi/u-boot-imx/1_2020.04-r6/tmp-src
+ make 'HOSTCC=gcc  -DMENDER_AUTO_PROBING' 'CC=arm-poky-linux-gnueabi-gcc -DMENDER_AUTO_PROBING' hermes_uboot_emmc_config
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  YACC    scripts/kconfig/zconf.tab.c
  LEX     scripts/kconfig/zconf.lex.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
***
*** Can't find default configuration "arch/../configs/hermes_uboot_emmc_defconfig"!
***
scripts/kconfig/Makefile:128: recipe for target 'hermes_uboot_emmc_defconfig' failed
make[1]: *** [hermes_uboot_emmc_defconfig] Error 1
Makefile:539: recipe for target 'hermes_uboot_emmc_config' failed
make: *** [hermes_uboot_emmc_config] Error 2
WARNING: exit code 2 from a shell command.

I had worked around this the first time around by changing MACHINE to imx6ull14x14evk (which doesn’t require a do_configure_append), but this was unsatisfactory because the evk and hermes defconfigs are different enough to cause the patch to fail. I had to manually clean it up.

Thanks,
Stu

@kacf can you help here?
Drew

I fixed the build failure by changing my .bbappend to install my hermes board-specific files in do_mender_uboot_auto_configure_prepend() instead of do_configure_append(), but I’m still missing the 0001- through 0004- Mender-supplied patches even when MENDER_UBOOT_AUTO_CONFIGURE=“1”. So I’m back to the question of whether I’m supposed to apply them manually myself or should they be included in mender_auto_configured.patch?

Thanks,
Stu

They should not be included in mender_auto_configured.patch. Aren’t they listed in your SRC_URI? It can be checked with bitbake -e u-boot-imx and then grepping for it.