Mender integration of STM32MP157C on dunfell

Hi, @mirzak

we’re trying to use yocto dunfell and mender on a STM32MP157C-DK2

Our ( probably bad ) idea is to replicate the mender-community layer for thud, creating the u-boot patches using devtool.

Now, we can build (obtaining the .mender and the .gptimg files) and start the board. The Mender server recognize the board as a pending device and it’s possible to accept it. But we have some problems with partitions.
If we use the mender client we get this error:
“Failed to read the current active partition: No match between boot and root partitions.: exit status 243”

Moreover, if we use fw_printenv command we get:
“fw_printenv cannot read environment using default
cannot read default environment from file”

So we miss something but we can’t say what.
Have you any idea?

Thank you

This is probably a good idea :slight_smile:.

“fw_printenv cannot read environment using default
cannot read default environment from file”

It seems that you are missing the /etc/fw_env.config file. This should install it, so would look in to why this is not happening.

Thanks for the reply @mirzak .

we have 4 files in /etc related to fw_env :

fw_env.config (symbolic link to /data/u-boot/fw_env.config)
fw_env.config.mmc
fw_env.config.nand
fw_env.config.nor

the content of fw_env.config file in /data/u-boot/ is:

/dev/mmcblk0 0x800000 0x20000
/dev/mmcblk0 0x1000000 0x20000

Maybe the problem is that we have a symbolic link in /etc insted of the real file?
We aren’t able to undestand if this file is correct. There are two refs to mmcblk0 is this correct?

thank you

This file should be a symbolic link.

There are two refs to mmcblk0 is this correct?

This is correct, these are redundant environment for robustness.

I am curious, if you can halt U-Boot and share the output of printenv to start off.

How can i do that? It’s not the same as fw_printenv command?

Hi @mirzak,

Here our printenv

altbootcmd=run bootcmd
android_mmc_boot=mmc dev {devnum};run android_mmc_splash;run android_mmc_fdt;run android_mmc_kernel;bootm {kernel_addr_r} - {fdt_addr_r}; android_mmc_fdt=if part start mmc {devnum} dt_{suffix} dt_start &&part size mmc {devnum} dt_{suffix} dt_size;then mmc read {dtimg_addr} {dt_start} {dt_size};dtimg getindex {dtimg_addr} {board_id} {board_rev} dt_index;dtimg start {dtimg_addr} {dt_index} fdt_addr_r;fi android_mmc_kernel=if part start mmc {devnum} boot_{suffix} boot_start &&part size mmc {devnum} boot_{suffix} boot_size;then mmc read {kernel_addr_r} {boot_start} {boot_size};part nb mmc {devnum} system_{suffix} rootpart_nb;env set bootargsroot=/dev/mmcblk${devnum}p${rootpart_nb} androidboot.serialno={serial#} androidboot.slot_suffix=_{suffix};fi
android_mmc_splash=if part start mmc {devnum} splash splash_start && part size mmc {devnum} splash splash_size;then mmc read {splashimage} {splash_start} {splash_size};cls; bmp display {splashimage} m m;fi
arch=arm
autoload=no
baudrate=115200
board=stm32mp1
board_name=stm32mp157c-dk2
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_m4fw=rproc init; rproc load 0 {m4fw_addr} {filesize}; rproc load_rsc 0 {m4fw_addr} {filesize}; rproc start 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=mmc0 bootargs=root={mender_kernel_root} rootwait rw console=ttySTM0,115200
bootcmd=run bootcmd_stm32mp
bootcmd_android=env set mmc_boot run android_mmc_boot;run bootcmd_stm32mp
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_stm32mp=echo “Boot over {boot_device}{boot_instance}!”;if test {boot_device} = serial || test {boot_device} = usb;then stm32prog {boot_device} {boot_instance}; else run env_check;if test {boot_device} = mmc;then env set boot_targets "mmc{boot_instance}"; fi;if test {boot_device} = nand || test {boot_device} = spi-nand ;then env set boot_targets ubifs0; fi;if test {boot_device} = nor;then env set boot_targets mmc0; fi;run distro_bootcmd;fi; bootcmd_ubifs0=devnum=0; run ubifs_boot bootcount=1 bootdelay=1 bootfstype=fat bootlimit=1 cpu=armv7 devplist=4 distro_bootcmd=for target in {boot_targets}; do run bootcmd_{target}; done dtimg_addr=0xc4500000 efi_dtb_prefixes=/ /dtb/ /dtb/current/ env_check=env exists env_ver || env set env_ver {ver};if env info -p -d -q; then env save; fi;if test “$env_ver” != “ver"; then echo "*** Warning: old environment {env_ver}”; echo ‘* set default: env default -a; env save; reset’; echo '* update current: env set env_ver {ver}; env save';fi; env_ver=U-Boot 2020.01-stm32mp-r1 (Jan 06 2020 - 20:56:31 +0000) ethaddr=00:80:e1:42:75:c6 fdt_addr_r=0xc4000000 fdtcontroladdr=d7aec960 fdtfile=stm32mp157c-dk2.dtb fileaddr=c4100000 filesize=3ba kernel_addr_r=0xc2000000 load_efi_dtb=load {devtype} {devnum}:{distro_bootpart} {fdt_addr_r} {prefix}{efi_fdtfile} loadaddr=0xc2000000 m4fw_addr=0xc2000000 m4fw_name=rproc-m4-fw.elf 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=stm32mp157c-dk2-a7-examples.dtb
mender_kernel_name=uImage
mender_saveenv_canary=1
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
partitions=name=ssbl,size=2M;name=bootfs,size=64MB,bootable;name=vendorfs,size=16M;name=rootfs,size=746M;name=userfs,size=-
pxefile_addr_r=0xc4200000
ramdisk_addr_r=0xc4400000
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
scan_m4fw=if test -e {mender_kernel_root} /boot/{m4fw_name};then echo Found M4 FW m4fw_name; if load {mender_uboot_boot} {m4fw_addr} /boot/{m4fw_name}; then run boot_m4fw; fi; fi;
scriptaddr=0xc4100000
serial#=0041003D3338510B39303435
serverip=192.168.1.1
soc=stm32mp
splashimage=0xc4300000
suffix=a
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=st
ver=U-Boot 2020.01-stm32mp-r1 (Jan 06 2020 - 20:56:31 +0000)
Environment size: 7560/8187 bytes

Edit :
Looking at our boot process we get an error related to a mender service : mender-grow-data
Going in deep we get the failure:

root@stm32mp1-disco:~# systemctl status mender-grow-data
mender-grow-data.service - Mender service to grow data partition size
Loaded: loaded (/lib/systemd/system/mender-grow-data.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2020-11-16 12:35:13 UTC; 1min 3s ago
Process: 425 ExecStart=/usr/bin/mender-client-resize-data-part (code=exited, status=1/FAILURE)
Main PID: 425 (code=exited, status=1/FAILURE)
Nov 16 12:35:12 stm32mp1-disco systemd[1]: Starting Mender service to grow data partition size…
Nov 16 12:35:13 stm32mp1-disco mender-client-resize-data-part[444]: Warning: Partition /dev/mmcblk0p4 is being used. Are you sure you want to continue?
Nov 16 12:35:13 stm32mp1-disco systemd[1]: mender-grow-data.service: Main process exited, code=exited, status=1/FAILURE
Nov 16 12:35:13 stm32mp1-disco systemd[1]: mender-grow-data.service: Failed with result ‘exit-code’.
Nov 16 12:35:13 stm32mp1-disco systemd[1]: Failed to start Mender service to grow data partition size.

Edit 2 :
We fix the mender-grow-data error changing the partition number from 4 (p4 is our boot partition) to 7 (p7 is our data partition). We aren’t getting anymore the mender-grow-data fail and the data partition size is now 4Gb instead of 1Gb.
However we still have the real problem with mender and fw_env.

Hope this can help us,
Thank you

Hi @mirzak,
have you any idea for our problem? We are literally stucked

Thank You