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

DFU of App Data section

SDK14.0.0 nRF52832 s132

I would like to DFU the contents of the App Data section. In particular, I would like to erase the contents for a "factory reset" command.

I've tried creating a separate DFU package that just contains 0xff in addresses 0x74000..0x78000. However, there is no way to specify a "data" DFU package. If I create an application DFU package, then the entire application is erased, and the 0xffs that were intended for 0x74000 are written to 0x23000 instead.

One way I think will work is to increase the size of the application so that it includes addresses up to 0x78000. However, this method adds a lot of time to the DFU process. Is there another way?

  • One way I think will work is to increase the size of the application so that it includes addresses up to 0x78000.

    This method won't work either. The bootloader will refuse to overwrite the app data section. (And I don't want it erased during a normal DFU, so I have set DFU_APP_DATA_RESERVED appropriately).

    -- Daniel

  • If you have a look here, you can find that by default the application data reserved is 3 pages. If you set DFU_APP_DATA_RESERVED to 0, the application data should be erase.

  • Understood. For my application, I've increased the number of pages to 4 and set DFU_APP_DATA_RESERVED to 0x4000 to match (nrf52832, virtual page size is 1024).

    The issue is that I normally do not want to erase this region during a DFU. It's only during special situations, such as a factory reset, that the region should be erased.

  • So you meant you want a special DFU update that will do "factory reset" when normal DFU update will keep the DFU_APP_DATA_RESERVED ?

    I would suggest to either modify the bootloader to erase the region when you receive the "factory reset" command, or if you don't want to modify the bootloader, you can have some code in your application that can erase the region before you switch to bootloader (assume you have buttonless DFU) .

  • So you meant you want a special DFU update that will do "factory reset" when normal DFU update will keep the DFU_APP_DATA_RESERVED ?

    Correct.

    I would suggest to either modify the bootloader to erase the region when you receive the "factory reset" command, or if you don't want to modify the bootloader, you can have some code in your application that can erase the region before you switch to bootloader (assume you have buttonless DFU) .

    Thanks. I'd prefer that the functionality wasn't in the application (in case the app data contents cause the application to behave unexpectedly). That leaves updating the bootloader.

Related