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
  • Hi Sebastian,
    I'm experiencing something similar.

    I have built a new bootloader with the extra configurations;
    `
    # Overwrite
    CONFIG_BOOT_UPGRADE_ONLY=y
    # Swap algorithm
    CONFIG_BOOT_SWAP_USING_MOVE=n
    `

    I'm building my app with config
    `
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_MCUBOOT_SIGNATURE_KEY_FILE="zephyrproject/bootloader/mcuboot/root-rsa-2048.pem"

    `
    I also tried adding these configs to my app
    `
    CONFIG_MCUBOOT_BOOTLOADER_MODE_OVERWRITE_ONLY=y
    CONFIG_MCUBOOT_BOOTLOADER_NO_DOWNGRADE=y
    `
    When I try to upgrade with the new application, the bootloader still use the move algorithm to swap. It seems like the config flags are ignored.
  • I just figured out when I was flashing my application it was also building a default bootloader and flashing that. That's why my Kconfigs was ignored.


    Is it possible to build an application for a bootloader, without also building a default bootloader that is also flashed.? I would like these two builds to be seperate.

  • I don't know if west has support for it, but you can always flash the images yourself with nrfjprog.

    There is a build/zephyr/app_signed.hex to just install the app (in the primary area).

    build/zephyr/app_moved_test_update.hex is for the secondary area, so the bootloader can update it.

    build/zephyr/merged.hex file that contains both the bootloader and the app.

  • Can you choose to only build the app? So far when I do west build, it builds both the bootloader and the application.
    I would like to separate the development of these to projects

Reply Children
Related