We are using NRF5 SDK 17.0.2 on an NRF52840.
I am implementing a bootloader update procedure. Our updates always store the new image in external flash. The spare space in the internal flash is insufficient to operate as a second bank for DFU. As a result, we cannot directly use SD_MBR_COMMAND_COPY_BL since that requires the image to be present in the internal flash space.
As an aside.. technically we could use the MBR but it would involve copying the application out to external flash and an unsigned application copy back from external flash, which I want to avoid for security reasons.
My preference would be for the application to perform the bootloader copy from external flash into the bootloader space. This seems relatively straight forward, except I'm not sure how I can notify the MBR the bootloader is invalid during the update process. It appears I can use the SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET with the softdevice address to bypass the bootloader loading, but its not clear from the documentation:
1) How do I revert the changes caused by NRF_UICR_BOOTLOADER_START_ADDRESS?
2) Can the SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET command be called multiple times or is it only allowed to be called once? If multiple calls are allowed, is the swap fail safe?
Alternatively, can I erase the MBR page and clear NRF_UICR_BOOTLOADER_START_ADDRESS during the update and then re-write the NRF_UICR_BOOTLOADER_START_ADDRESS at the completion to re-enable the bootloader?