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

preserve data in the flash over DFU using FDS [sdk 14.2]

Hello everybody,

             I need to store some data in the flash for application purposes. I'm using the SD332 and the application goes in the DFU mode with the DFU buttonless service. I'm using the sdk14.2.

I modified the app using the FDS library to store the data. I was able to implement the functionality really fast (nice library, congrats to nordic) but then I need to modify it to retain the data even over a DFU update.

here, in the DFU description, is written I should define DFU_APP_DATA_RESERVED in the proper way, but this define is not used in any c file I'm using at the moment.

here, in the FDS description,it is not mentioned how to deal with the DFU.

I then tried to check what happen if I do the DFU update to the stored data and they are not erased, but I have not set anything in the application or in the boot to preserve the flash data when a DFU is performed, so I wonder if I did it properly or not and the infocenter information doesn't have any information on this.

Fabiano

Parents
  • Hi Fabiano, 

    the DFU_APP_DATA_RESERVED define is by default set to CODE_PAGE_SIZE * 3 in nrf_dfu_types.h in the bootloader code. This will ensure that both the bonding data and the application data is retained during a DFU. 

    So unless you expect your application data to exceed one flash page, i.e. 4kB, then you do not need to do anything with either the application or bootloader code. 

    Best regards

    Bjørn

Reply
  • Hi Fabiano, 

    the DFU_APP_DATA_RESERVED define is by default set to CODE_PAGE_SIZE * 3 in nrf_dfu_types.h in the bootloader code. This will ensure that both the bonding data and the application data is retained during a DFU. 

    So unless you expect your application data to exceed one flash page, i.e. 4kB, then you do not need to do anything with either the application or bootloader code. 

    Best regards

    Bjørn

Children
  • Thank you very much Bjørn, I have just another question:

    I noticed that every time I modify the value of any data (uploading it in the flash with the function fds_record_update(); like in the example flash_fds_example) the address where are saved my data keep increase, I guess till will reach the last address available in the space reserved to store data. At that point will I receive an FDS_ERR_NO_SPACE_IN_FLASH error when I try to update the data? if yes do I have just to use the garbace collector and then proceed to keep storing data?

    thank you very much for your help

    Fabiano

  • Hi Fabiano, 

    Yes, you are correct.  The fds_record_update documentation states that updating a record first writes a new record to flash and then deletes the old record. 

    Note that deleting a record does not free the space it occupies in flash memory. To reclaim flash space used by deleted records, call fds_gc to run garbage collection.

Related