MCUboot sign image: possible wrong slot size

I encountered the problem trying a Matter OTA-update and and asking myself why the bootloader wouldn't apply the image:

I am using the partition manager and defining the mcuboot_pad and mcuboot_primary_app partition both in the mcuboot_primary partition. MCUboot uses the mcuboot_primary_app partition value as definition of the maximum allowed partition size. However, both the sign function in nrf/modules/mcuboot/CMakeLists.txt as well as Zephyr use mcuboot_primary as available size for the image.

This leads to the problem that for an app, which exceeds the size of mcuboot_primary_app but is smaller than mcuboot_primary thebuild works fine, signing works as expected, but after the update file is send MCUboot does not apply the image.

I suggest setting

SLOT_SIZE $<TARGET_PROPERTY:partition_manager,PM_MCUBOOT_PRIMARY_APP_SIZE>

instead of

SLOT_SIZE $<TARGET_PROPERTY:partition_manager,PM_MCUBOOT_PRIMARY_SIZE>

Sadly, I haven't figured out where the app size in Zephyr is set, this may also need to be updated.

Related