One application with MCUboot and overwrite image upgrades?

I'm trying to build an app with MCUboot and overwrite-based image upgrades.

We use NCS v2.5.0, and in my experiments the nRF52840 DK board.

First I tried to test this with samples/application_development/sysbuild/with_mcuboot. It has
 CONFIG_BOOT_UPGRADE_ONLY=y
 CONFIG_MCUBOOT_DOWNGRADE_PREVENTION=y
for its mcuboot.conf

I built a new version of its application. The build system didn't give me a file to upgrade with. I noticed in nrf/modules/mcuboot/CMakeList.txt that there is a check in the beginning for SYSBUILD and then returning, so I tried to create the upgrade image myself:

objcopy -O ihex --change-addresses 0x86000 -I binary build/with_mcuboot/zephyr/zephyr.signed.bin --gap-fill 0xff --pad-to 0x100000 app_moved.hex

The addresses are from the partition_manager_report. I flashed that file, but the bootloader didn't update the application to it, nor write any error messages. I guess that file isn't correct to use for upgrades.

My next try was to not use sysbuild and change the hello_world sample instead. I updated the prj.conf to:

CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_MCUBOOT_BOOTLOADER_MODE_OVERWRITE_ONLY=y
CONFIG_MCUBOOT_BOOTLOADER_NO_DOWNGRADE=y
CONFIG_BOOT_UPGRADE_ONLY=y
CONFIG_MCUBOOT_DOWNGRADE_PREVENTION=y

Then the build system complains that the last two keys are unknown (I had copied them from the sysbuild sample), so I removed them. This made me get the app_moved_test_update.hex file.

I tried to just flash that one and then the bootloader from the first sample used it and did an overwriting upgrade, just like I want it. Great!

Then I tried to use the newly built bootloader from the hello_world sample instead, but then it does a swap upgrade.

How do I get one project to both build MCUboot with the overwrite support as well as getting an app_moved_test_update.hex file for the application?

I don't really care if the project uses sysbuild or not, but it would be great if both ways could be used as this is supposed to be a sample for other applications to copy.

Parents Reply Children
Related