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

Protect NVM from being overwritten during reflash

I'm using the pstorage driver on the nRF51 to maintain several NVM variables. The NVM functions correctly and maintains state between power cycles. However, when I reflash the device using OTA reflash (application only, not SoftDevice), all of my NVM variables are reset to 0xFF. How do I prevent reflashing from modifying my NVM variables?

This is the command line I'm using to generate the zip file used for OTA reflash -

nrfutil dfu genpkg myProgram.zip --application myProgram.hex --application-version 0xffff --dev-revision 0xffff --dev-type 0xffff --sd-req 0xfffe

Thanks

Brian

Parents
  • FormerMember
    0 FormerMember

    The "Preserving application data" section in the bootloader documentation explains what to do to avoid loosing data during the DFU operation.

  • Thanks Kristin! I'm using SDK 9.0, and found the dfu_types.h file used by my bootloader. I changed the #define of DFU_APP_DATA_RESERVED from 0 to CODE_PAGE_SIZE (which is 0x400). I then rebuilt my bootloader and app, and combined them into a .zip file with nrfutil, like this: "nrfutil dfu genpkg strobe.zip --application myApplication.hex --bootloader myBootloader.hex --application-version 0xffff --dev-revision 0xffff --dev-type 0xffff --sd-req 0xfffe

    When I try to reflash this zip file to my device using nRF Toolbox, I get a message that says it is updating part 1 of 2, then a message that it is disconnecting from the device, and then a message saying the upload failed. My device no longer boots up now. Any idea what went wrong? Thanks.

Reply
  • Thanks Kristin! I'm using SDK 9.0, and found the dfu_types.h file used by my bootloader. I changed the #define of DFU_APP_DATA_RESERVED from 0 to CODE_PAGE_SIZE (which is 0x400). I then rebuilt my bootloader and app, and combined them into a .zip file with nrfutil, like this: "nrfutil dfu genpkg strobe.zip --application myApplication.hex --bootloader myBootloader.hex --application-version 0xffff --dev-revision 0xffff --dev-type 0xffff --sd-req 0xfffe

    When I try to reflash this zip file to my device using nRF Toolbox, I get a message that says it is updating part 1 of 2, then a message that it is disconnecting from the device, and then a message saying the upload failed. My device no longer boots up now. Any idea what went wrong? Thanks.

Children
No Data
Related