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

How to make sure DFU erases all app data

Hi,
I want to make sure that all application data are erased when we do a DFU, so that the newer application get a clean start without having to worry about data from older versions. The application uses FDS.

Is it sufficient to set DFU_APP_DATA_RESERVED to 0 in the bootloader or do I also have have to make sure the BL erases the whole area? (not just reserving it)

We are using the secure BL with SDK 12.3.0 

Thanks in advance and best regards.

Erik

  • Hi,

    The bootloader will not erase the app data section unless it's required to fit the new image(s) you are uploading. If you want to guarantee that the app data reserved is erased you need to either modify the bootloader or add a mechanism in your app that erases the app data after an application update. 

    Maybe something like this:

    1. Create a new data record that holds the current version number of the application.

    2. Harcode the version number in the app or create a pointer that points to   nrf_dfu_settings_t::app_version in the bootloader settings.

    3. On startup, compare the version number from step 2 with the one in step 1. If there's a mismatch (ie app has been updated), erase user data then update the fds record with the new version number. 

Related