This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Updating Bootloader to Bootloader Which Preserves App Data

I've recently tried add App Data (pstorage) to my Application. Thus I want to preserve this data over DFU Updates. To do this I updated my Bootloader to reserve App Data during the process via

dfu_types.h #define DFU_APP_DATA_RESERVED 0x0400

However when I update from the old Bootloader to the new Bootloader our board completely bricks. Are there any other steps I need to take to instruct the SoC to handle memory? If I merge and program the new Bootloader and App, everything works fine and I can switch into the Bootloader without issue. Its only when I update from the old Bootloader to New Bootloader. Thanks in advance for the help on this.

Regards,

DC

p.s. using SDK 6.2 S110 7.1

  • Hi, changing the app data reserved value causes the bank_1 address to change, but unfortunately the bootloader doesn't foresee this change (see dfu_types.h for calculation of bank areas). What happens then is that the new bootloader will tell the MBR to copy the bootloader image once again, but this time using the new bank_1 address even though it still located at the old bank_1 address specified by the old bootloader. The result is that you get a bootloader that lacks the first page of code.

    I think the easiest solution to this is to modify the dfu_bl_image_validate() function in your new bootloader to check on both the new and the old DFU_BANK_1_REGION_START address.

    Note, if you're updating to a new softdevice(major release - e.g., 8.x.x) you will have to update BL + SD in the same step due to API differences.

  • Thank you Vidar,

    A few things aren't entirely clear though. The new Bootloader image validation and swap occurs while running out of the Old Bootloader. So shouldn't the BANK_1 address still be valid? The new BANK_1 settings shouldn't take effect until the NEW bootloader image is running, no?

    And if I wish to use App Data, but don't care whether it is preserved over a DFU update I can simply ignore reserving that page of memory in the Bootloader, correct? This may be the simplest solution until we update to the latest SDK and SD.

  • That's correct, image validation and swap occurs while running out of the old Bootloader. However, the final step of updating the bootloader settings are handled by the new bootloader (in bootloader_dfu_sd_update_finalize() call). Problem is that the dfu_bl_image_validate() check has to return true before the update can be finalized. In this case it fails due to the new bank1 address. Thus, the MBR swap command is issued from the new bootloader, but with the wrong address parameter, see bootloader_dfu_sd_update_continue.

    Preservation of app data can be ignored as long as you do not need to retain the data while doing DFU.

  • Hi vidar, can you explain how the sd_bl image is copied, I followed the code but it very hard to understand I'm using sdk11.0.0

    thanks in advance

Related