Meta-mender master rpi4 boot issue

Hi, I’m using meta-mender master branch for rpi4 integration. Build pass without issue. When flashed board cannot boot due to then fact that MENDER_DEVICETREE is not properly set (it’s set to overlay_map.dtb):

boot
Failed to load '/boot/overlay_map.dtb'
24070656 bytes read in 1028 ms (22.3 MiB/s)
Moving Image from 0x80000 to 0x200000, end=19f0000
ERROR: Did not find a cmdline Flattened Device Tree
Could not find a valid device tree

I checked but overlay_map.dtb is there for quite some time.

KERNEL_DEVICETREE looks like:

KERNEL_DEVICETREE=" broadcom/bcm2711-rpi-4-b.dtb broadcom/bcm2711-rpi-400.dtb broadcom/bcm2711-rpi-cm4.dtb overlays/overlay_map.dtb overlays/at86rf233.dtbo overlays/disable-bt.dtbo overlays/dwc2.dtbo overlays/gpio-ir.dtbo overlays/gpio-ir-tx.dtbo overlays/gpio-key.dtbo overlays/hifiberry-amp.dtbo overlays/hifiberry-dac.dtbo overlays/hifiberry-dacplus.dtbo overlays/hifiberry-digi.dtbo overlays/justboom-both.dtbo overlays/justboom-dac.dtbo overlays/justboom-digi.dtbo overlays/i2c-rtc.dtbo overlays/imx219.dtbo overlays/imx477.dtbo overlays/iqaudio-dac.dtbo overlays/iqaudio-dacplus.dtbo overlays/mcp2515-can0.dtbo overlays/mcp2515-can1.dtbo overlays/miniuart-bt.dtbo overlays/pitft22.dtbo overlays/pitft28-capacitive.dtbo overlays/pitft28-resistive.dtbo overlays/pitft35-resistive.dtbo overlays/pps-gpio.dtbo overlays/rpi-ft5406.dtbo overlays/rpi-poe.dtbo overlays/vc4-fkms-v3d.dtbo overlays/vc4-kms-v3d.dtbo overlays/vc4-kms-v3d-pi4.dtbo overlays/vc4-kms-dsi-7inch.dtbo overlays/w1-gpio.dtbo overlays/w1-gpio-pullup.dtbo overlays/wm8960-soundcard.dtbo overlays/uart0.dtbo overlays/uart1.dtbo overlays/uart2.dtbo overlays/uart3.dtbo overlays/uart4.dtbo overlays/uart5.dtbo overlays/pcie-32bit-dma.dtbo overlays/gpio-shutdown.dtbo overlays/i2c-rtc.dtbo "

but in mender_get_clean_kernel_devicetree method in meta-mender-core/classes/mender-helpers.bbclass it seems it pick wrong dtb due to that.Ideas? Thanks.

IMAGE_INSTALL:append = " kernel-devicetree" helps a bit, but the mender_dtb_name is still wrong. Trying to use MENDER_DTB_NAME_FORCE

Seems that this was an issue:

diff --git a/meta-mender-raspberrypi/recipes-bsp/u-boot/u-boot-raspberrypi.inc b/meta-mender-raspberrypi/recipes-bsp/u-boot/u-boot-raspberrypi.inc
index de8a6a50..4932b156 100644
--- a/meta-mender-raspberrypi/recipes-bsp/u-boot/u-boot-raspberrypi.inc
+++ b/meta-mender-raspberrypi/recipes-bsp/u-boot/u-boot-raspberrypi.inc
@@ -1,10 +1,10 @@
 FILESEXTRAPATHS:prepend:rpi := "${THISDIR}/patches:"
 
-BOOTENV_SIZE_rpi ?= "0x4000"
+BOOTENV_SIZE:rpi ?= "0x4000"
 
 # U-Boot auto-configuration doesn't work properly for Raspberry Pi, due to its
 # use of boot.scr and cmdline.txt.
-MENDER_UBOOT_AUTO_CONFIGURE_rpi = "0"
+MENDER_UBOOT_AUTO_CONFIGURE:rpi = "0"
 
 SRC_URI:append:rpi:mender-uboot = "${@bb.utils.contains('MENDER_UBOOT_AUTO_CONFIGURE', \
                                                         '1', \

Also one rpi patch needs to be refreshed. Now board boot fine. Should I make PR with this fix? Thanks

One more thing: fw_printenv seems not working:

fw_printenv 
Cannot read environment, using default
Cannot read default environment from file

Offset seems to be fine.

Was able to fix with adding to local.conf: BOOTENV_SIZE = "0x4000". But when apply mender update board still boots from old partition despite of fact that mender_uboot_root=mmc 0:3 and others are set to 3 (not 2)

Posted PR: Raspberrypi honister fixes by nandra · Pull Request #1643 · mendersoftware/meta-mender · GitHub