Flashing redundant u-boot environments in separate uboot environment image file

The Apalis Image v2.7B (aka Linux BSP Image) “puts” u-boot and the u-boot environment into the cbootimage. I already modified the u-boot of the apalis image in a way that two redundant u-boot environments are created instead of a single one (by modifying the u-boot configuration and compiling a custom u-boot). With this modification the two redundant u-boot environments should still be placed in the cbootimage. This modified state of the image works fine.

Now I would like to flash the two redundant u-boot environments separate from u-boot. To achieve that I use mkenvimage from the u-boot tools. I created an uboot environment source file uboot-env.txt (which contains the same environment variables like the default ones as key=value pair per line) and executed ./tools/mkenvimage -r -s 0x20000 -o uboot-env.bin uboot-env.txt (-r for redundant environments, -s for custom environment size 0x20000) to get the u-boot environment image file uboot-env.bin. I added the copying of the uboot-env.bin into the tftp output directory in update.sh and added the flashing of the uboot environment image in flash_eth.scr with something equivalent like

setenv startblk_uboot_env 0x0
setenv update_uboot_env 'tftpboot ${loadaddr} ${board_name}/uboot-env.bin; && run set_blkcnt && mmc dev 0 1 && mmc write ${loadaddr} ${startblk_uboot_env} ${blkcnt}'

Then I tried to update a Apalis TK1 SOM which is flashed with the Apalis Image v2.7B1 with my custom u-boot (still in apalis-tk1.img) and the u-boot environment (in new image file uboot-env.bin). To debug the update I entered the u-boot command line prompt, triggered the tftp update of u-boot with run update_uboot and the update of the environment with run update_uboot_env (both successfully transfered). The variables of the uboot environment image are added in the currently active u-boot environment (RAM) then.

But when I poweroff/on the Apalis TK1 after poweron I do not get any u-boot command line prompt output anymore (the same custom u-boot worked without the separate u-boot env image file) and I need to use the “unbricking” procedure to get it back to life.

  • Is the call of mkenvimage not correct (location of the second uboot environment or the enviornment offset, I assumed that these informations are taken from the according u-boot configuration variables mkenvimage usage for redundant uboot environments)?
  • Do I have to remove the u-boot environment from the cbootimage apalis-tk1.img explicitly (I assumed that the separate u-boot image overrides the u-boot environments in the cbootimage)?

Seems like the location where uboot-env.bin has been written to was not correct (wrong value for startblk_uboot_env and wrong mmc device mmc dev 0 0 in flash_eth.scr).