U-Boot integration [stm32mpu157 dk2]

Hi,
My board bases on development kit stm32mpu157 dk2 and yocto dunfell version.
I somehow integrated mender layers with my hardware and here is specific layre for my board:
Owner avatar viotas_meta-mender-st-stm32mp15x-port

The problem is when I want to perform OTA update from mender dashboard I got an error like:

ERRO[0000] Failed to read the current active partition: No match between boot and root partitions.: Failed mender_saveenv_canary check. There is an error in the U-Boot setup. Likely causes are: 1) Mismatch between the U-Boot boot loader environment location and the location specified in /etc/fw_env.config. 2) 'mender_setup' is not run by the U-Boot boot script: mender_saveenv_canary variable could not be parsed 

I can print envirnoment in u-boot printenv and user space fw_printenv -c fw_env.config.mmc (see at the boottom)

I can switch bettween partion A/B but only using u-boot envirnoment rootfsp but not

fw_setenv mender_boot_part 6
fw_setenv mender_boot_part_hex 6
reboot

they indeed change its state but seems like doesnt takes effect.

I use sd card which after prepared looks like:
Fip partion ~4MB is occupied only with the first 1MB so envirnoment was set at the end of this partition.

/dev/mmcblk0 4710400 0x20000
/dev/mmcblk0 4702208 0x20000

According to documentation mender should integrate with u-boot envrnoment automatically

What can be wrong?


U-Boot envirnoment are:

ViotasUM> printenv
altbootcmd=run bootcmd
arch=arm
autoload=no
baudrate=115200
board=micrometer
board_name=micrometer
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_device=mmc
boot_efi_binary=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr ${fdtcontroladdr};fi;load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootarm.efi; if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r};else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_instance=0
boot_net_usb_start=true
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
boot_targets=mmc1 ubifs0 mmc0 mmc2 pxe 
bootargs=isolcpus=1 root=/dev/mmcblk0p4 rootwait rw console=ttySTM0,115200
bootcmd=run bootcmd_vioum
bootcmd_mmc0=devnum=0; run mmc_boot
bootcmd_mmc1=devnum=1; run mmc_boot
bootcmd_mmc2=devnum=2; run mmc_boot
bootcmd_pxe=run boot_net_usb_start; dhcp; if pxe get; then pxe boot; fi
bootcmd_ubifs0=devnum=0; run ubifs_boot
bootcmd_vioum=if test ${boot_device} = serial || test ${boot_device} = usb;then echo "Boot over ${boot_device}${boot_instance}!"; stm32prog ${boot_device} ${boot_instance}; else if test -e mmc 0:6 /boot/2;then setenv rootfsp 5;fi;echo "Boot from ${boot_device}${boot_instance}:${rootfsp}!";if mmc dev ${devnum}; then run vio_sd_dynamic_boot; else echo "Unsupported boot device"; fi;fi;
bootcount=1
bootdelay=1
bootlimit=1
cpu=armv7
devnum=0
devtype=mmc
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
efi_dtb_prefixes=/ /dtb/ /dtb/current/
env_check=if env info -p -d -q; then env save; fi
extlinscript=/boot/mmc0_extlinux/extlinux.conf
fdt_addr_r=0xc4000000
fdtcontroladdr=fdde46c0
fdtfile=viotas-micrometer.dtb
kernel_addr_r=0xc2000000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
loadaddr=0xc2000000
mender_altbootcmd=if test ${mender_boot_part} = 5; then setenv mender_boot_part 6; setenv mender_boot_part_hex 6; else setenv mender_boot_part 5; setenv mender_boot_part_hex 5; fi; setenv upgrade_available 0; saveenv; run mender_setup
mender_boot_kernel_type=bootm
mender_boot_part=5
mender_boot_part_hex=5
mender_check_saveenv_canary=1
mender_dtb_name=viotas-micrometer.dtb
mender_kernel_name=uImage
mender_setup=if test "${mender_saveenv_canary}" != "1"; then setenv mender_saveenv_canary 1; saveenv; fi; if test "${mender_pre_setup_commands}" != ""; then run mender_pre_setup_commands; fi; if test "${mender_systemd_machine_id}" != ""; then setenv bootargs "systemd.machine_id=${mender_systemd_machine_id} ${bootargs}"; fi; setenv mender_kernel_root /dev/mmcblk0p${mender_boot_part}; if test ${mender_boot_part} = 5; then setenv mender_boot_part_name /dev/mmcblk0p5; else setenv mender_boot_part_name /dev/mmcblk0p6; fi; setenv mender_kernel_root_name ${mender_boot_part_name}; setenv mender_uboot_root mmc 0:${mender_boot_part_hex}; setenv mender_uboot_root_name ${mender_boot_part_name}; setenv expand_bootargs "setenv bootargs \\"${bootargs}\\""; run expand_bootargs; setenv expand_bootargs; if test "${mender_post_setup_commands}" != ""; then run mender_post_setup_commands; fi
mender_try_to_recover=if test ${upgrade_available} = 1; then reset; fi
mender_uboot_boot=mmc 0:4
mender_uboot_dev=0
mender_uboot_if=mmc
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
pxefile_addr_r=0xc4200000
ramdisk_addr_r=0xc4400000
rootfsp=4
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;run scan_dev_for_efi;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done; setenv devplist
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; if test -z "${fdtfile}" -a -n "${soc}"; then setenv efi_fdtfile ${soc}-${board}${boardver}.dtb; fi; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${efi_fdtfile}; then run load_efi_dtb; fi;done;if test -e ${devtype} ${devnum}:${distro_bootpart} efi/boot/bootarm.efi; then echo Found EFI removable media binary efi/boot/bootarm.efi; run boot_efi_binary; echo EFI LOAD FAILED: continuing...; fi; setenv efi_fdtfile
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
scriptaddr=0xc4100000
serial#=004600383030510939393639
serverip=192.168.1.1
soc=stm32mp
splashimage=0xc4300000
ubifs_boot=env exists bootubipart || env set bootubipart UBI; env exists bootubivol || env set bootubivol boot; if ubi part ${bootubipart} && ubifsmount ubi${devnum}:${bootubivol}; then devtype=ubi; run scan_dev_for_boot; fi
upgrade_available=0
usb_boot=usb start; if usb dev ${devnum}; then devtype=usb; run scan_dev_for_boot_part; fi
vendor=viotas
vio_sd_dynamic_boot=setenv bootargs isolcpus=1 root=/dev/mmcblk0p${rootfsp} rootwait rw console=ttySTM0,115200;load ${devtype} ${devnum}:${rootfsp} ${kernel_addr_r} /boot/uImage;load ${devtype} ${devnum}:${rootfsp} ${fdt_addr_r} /boot/${fdtfile};load ${devtype} ${devnum}:${rootfsp} ${ramdisk_addr_r} /boot/uInitrd;bootm ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r};
vio_sd_extlinux_boot=rootfsp=4; devnum=0; fstype ${devtype} ${devnum}:${rootfsp} bootfstype;sysboot ${devtype} ${devnum}:${rootfsp} any ${scriptaddr} ${extlinscript}

User space envirnoment after call:
fw_printenv -c fw_env.config.mmc

fw_printenv -c fw_env.config.mmc
altbootcmd=run bootcmd
arch=arm
autoload=no
baudrate=115200
board=micrometer
board_name=micrometer
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_device=mmc
boot_efi_binary=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr ${fdtcontroladdr};fi;load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootarm.efi; if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r};else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_instance=0
boot_net_usb_start=true
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
boot_targets=mmc1 ubifs0 mmc0 mmc2 pxe 
bootargs=isolcpus=1 root=/dev/mmcblk0p4 rootwait rw console=ttySTM0,115200
bootcmd=run bootcmd_vioum
bootcmd_mmc0=devnum=0; run mmc_boot
bootcmd_mmc1=devnum=1; run mmc_boot
bootcmd_mmc2=devnum=2; run mmc_boot
bootcmd_pxe=run boot_net_usb_start; dhcp; if pxe get; then pxe boot; fi
bootcmd_ubifs0=devnum=0; run ubifs_boot
bootcmd_vioum=if test ${boot_device} = serial || test ${boot_device} = usb;then echo "Boot over ${boot_device}${boot_instance}!"; stm32prog ${boot_device} ${boot_instance}; else if test -e mmc 0:6 /boot/2;then setenv rootfsp 5;fi;echo "Boot from ${boot_device}${boot_instance}:${rootfsp}!";if mmc dev ${devnum}; then run vio_sd_dynamic_boot; else echo "Unsupported boot device"; fi;fi;
bootcount=1
bootdelay=1
bootlimit=1
cpu=armv7
devnum=0
devtype=mmc
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
efi_dtb_prefixes=/ /dtb/ /dtb/current/
env_check=if env info -p -d -q; then env save; fi
extlinscript=/boot/mmc0_extlinux/extlinux.conf
fdt_addr_r=0xc4000000
fdtcontroladdr=fdde46c0
fdtfile=viotas-micrometer.dtb
kernel_addr_r=0xc2000000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
loadaddr=0xc2000000
mender_altbootcmd=if test ${mender_boot_part} = 5; then setenv mender_boot_part 6; setenv mender_boot_part_hex 6; else setenv mender_boot_part 5; setenv mender_boot_part_hex 5; fi; setenv upgrade_available 0; saveenv; run mender_setup
mender_boot_kernel_type=bootm
mender_boot_part=5
mender_boot_part_hex=5
mender_check_saveenv_canary=1
mender_dtb_name=viotas-micrometer.dtb
mender_kernel_name=uImage
mender_setup=if test "${mender_saveenv_canary}" != "1"; then setenv mender_saveenv_canary 1; saveenv; fi; if test "${mender_pre_setup_commands}" != ""; then run mender_pre_setup_commands; fi; if test "${mender_systemd_machine_id}" != ""; then setenv bootargs "systemd.machine_id=${mender_systemd_machine_id} ${bootargs}"; fi; setenv mender_kernel_root /dev/mmcblk0p${mender_boot_part}; if test ${mender_boot_part} = 5; then setenv mender_boot_part_name /dev/mmcblk0p5; else setenv mender_boot_part_name /dev/mmcblk0p6; fi; setenv mender_kernel_root_name ${mender_boot_part_name}; setenv mender_uboot_root mmc 0:${mender_boot_part_hex}; setenv mender_uboot_root_name ${mender_boot_part_name}; setenv expand_bootargs "setenv bootargs \\"${bootargs}\\""; run expand_bootargs; setenv expand_bootargs; if test "${mender_post_setup_commands}" != ""; then run mender_post_setup_commands; fi
mender_try_to_recover=if test ${upgrade_available} = 1; then reset; fi
mender_uboot_boot=mmc 0:4
mender_uboot_dev=0
mender_uboot_if=mmc
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
pxefile_addr_r=0xc4200000
ramdisk_addr_r=0xc4400000
rootfsp=5
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;run scan_dev_for_efi;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done; setenv devplist
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; if test -z "${fdtfile}" -a -n "${soc}"; then setenv efi_fdtfile ${soc}-${board}${boardver}.dtb; fi; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${efi_fdtfile}; then run load_efi_dtb; fi;done;if test -e ${devtype} ${devnum}:${distro_bootpart} efi/boot/bootarm.efi; then echo Found EFI removable media binary efi/boot/bootarm.efi; run boot_efi_binary; echo EFI LOAD FAILED: continuing...; fi; setenv efi_fdtfile
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
scriptaddr=0xc4100000
serial#=004600383030510939393639
serverip=192.168.1.1
soc=stm32mp
splashimage=0xc4300000
ubifs_boot=env exists bootubipart || env set bootubipart UBI; env exists bootubivol || env set bootubivol boot; if ubi part ${bootubipart} && ubifsmount ubi${devnum}:${bootubivol}; then devtype=ubi; run scan_dev_for_boot; fi
upgrade_available=0
usb_boot=usb start; if usb dev ${devnum}; then devtype=usb; run scan_dev_for_boot_part; fi
vendor=viotas
vio_sd_dynamic_boot=setenv bootargs isolcpus=1 root=/dev/mmcblk0p${rootfsp} rootwait rw console=ttySTM0,115200;load ${devtype} ${devnum}:${rootfsp} ${kernel_addr_r} /boot/uImage;load ${devtype} ${devnum}:${rootfsp} ${fdt_addr_r} /boot/${fdtfile};load ${devtype} ${devnum}:${rootfsp} ${ramdisk_addr_r} /boot/uInitrd;bootm ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r};
vio_sd_extlinux_boot=rootfsp=4; devnum=0; fstype ${devtype} ${devnum}:${rootfsp} bootfstype;sysboot ${devtype} ${devnum}:${rootfsp} any ${scriptaddr} ${extlinscript}
root@vio-um0025A:/etc# 

Hi @zhalat,

As neither your bootcmd nor the defaulted bootcmd_vioum call the mender_setup command, nor use its results there obviously cannot be any effect. Please see the documentation at Manual U-Boot integration | Mender documentation for the required changes.

Greets,
Josef

well, my boot.cmd.in seems to call it

@zhalat

Running mender_setup after setenv bootargs is kinda nonsensical, because the values of mender_kernel_root is set by mender_setup, and hence will never change. The first thing is to move the run mender_setup call upwards.

Then the obvious next steps are:

  • make sure that the boot.scr are actually executed as you expect
  • if it is, add debugging statements like echo along the way to see what happens, and adjust accordingly.

Greets,
Josef

1 Like