MCUBOOT_OVERWRITE_ONLY_KEEP_BACKUP flag is not exposed to config mechanism

MCUBOOT contains a flag  MCUBOOT_OVERWRITE_ONLY_KEEP_BACKUP that stops it erasing a big chunk of the start of the secondary image after an update.

We would like to set this flag, because we do delta-updates against the secondary image over a very low-rate data link, and it's useful to have the previous version of our code still available on the device.

However, there is no method to set this flag via the usual configuration mechanisms (e.g. sysbuild.conf), so we have had to add it to mcuboot_config.h within the SDK code.

Obviously we would prefer not to have to modify the SDK source code -- could this option please be exposed to normal configuration?

Parents
  • Hi,

    I might need some more details from you w.r.t what your goal is:

    Out of the box, the DFU procedure uses swap for the DFU procedure and swaps the contents of the primary and secondary slot when doing an update. If you've marked the new image as "confirm", MCUboot will boot from the new image within the primary application slot on the new reboot, but it does not remove the contents of the secondary flash before you upload yet another update image candidate to the MCU.

    This means that the old firmware is still on the MCU. What you can't do however, is to revert back to the old firmware due to downgrade protection, since the old image is an older image than what is currently running. See https://docs.nordicsemi.com/bundle/ncs-2.9.0/page/nrf/app_dev/bootloaders_dfu/mcuboot_nsib/bootloader_downgrade_protection.html.

    Does this change anything for you w.r.t the original case description? If not, I'm not sure what parts of the images you're trying to support, so please feel free to fill in the missing gaps

    The support for delta-updates are also AFAIK restricted to modem firmware updates and not for firmware updates

    Kind regards,
    Andreas

  • Thanks Andreas.

    We are running with SB_CONFIG_MCUBOOT_MODE_OVERWRITE_ONLY=y, so there is no "swap" going on, the secondary image is simply written into the primary image location.

    By default, MCU boot then erases both the "header" and the "trailer" of the secondary image.  The code to do this is around lines 1952-1972 in loader.c (in 2.9.0)

    When it erases the "header", it actually erases a large part of the start of the secondary image.   

    We don't want our secondary image damaged like this, because our remote update process involves updating the secondary image very carefully and very slowly, and we are able to re-use parts of the previous secondary image, as long as the bootloader hasn't erased them.

    Erasing the "trailer" is essential, because that prevents MCUBOOT trying to repeat the update.  We're fine with that.

    The feature to preserve the secondary image is ALREADY in MCUBOOT - that's the MCUBOOT_OVERWRITE_ONLY_KEEP_BACKUP flag, which is checked on line 1952 of loader.c.   It stops the "header" erase but leaves the "trailer" erase.

    So I am not asking for any new functionally, merely a way to turn on the functionality which is already in MCUBOOT, but which is not currently exposed by Zephyr/Sysbuild.

    Thanks.

Reply
  • Thanks Andreas.

    We are running with SB_CONFIG_MCUBOOT_MODE_OVERWRITE_ONLY=y, so there is no "swap" going on, the secondary image is simply written into the primary image location.

    By default, MCU boot then erases both the "header" and the "trailer" of the secondary image.  The code to do this is around lines 1952-1972 in loader.c (in 2.9.0)

    When it erases the "header", it actually erases a large part of the start of the secondary image.   

    We don't want our secondary image damaged like this, because our remote update process involves updating the secondary image very carefully and very slowly, and we are able to re-use parts of the previous secondary image, as long as the bootloader hasn't erased them.

    Erasing the "trailer" is essential, because that prevents MCUBOOT trying to repeat the update.  We're fine with that.

    The feature to preserve the secondary image is ALREADY in MCUBOOT - that's the MCUBOOT_OVERWRITE_ONLY_KEEP_BACKUP flag, which is checked on line 1952 of loader.c.   It stops the "header" erase but leaves the "trailer" erase.

    So I am not asking for any new functionally, merely a way to turn on the functionality which is already in MCUBOOT, but which is not currently exposed by Zephyr/Sysbuild.

    Thanks.

Children
Related