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

Using FDS Flash storage for user settings as well as for DFU

I am building on a BLE DFU project which already has a NRF_FSTORAGE_DEF for allocation of non-volatile data used by DFU.
I want to add another instance of NRF_FSTORAGE_DEF for use with application setting data.

Can I define two different regions in Flash for this purpose, or do all uses of NRF_FSTORAGE_DEF need to be in a contiguous block of Flash memory?

One problem is that m_fs is used for both instance - which is easily fixed by renaming the DFU one to m_dfu_fs to avoid a name conflict.

The DFU section is set to between 0x7F000 - 0x80000.

Can I set my other section to 0x20000 - 0x22000?

I tried this and it compiles and runs OK, but when the pages_init() function is called on initialization of the FDS module, all three pages are marked as FDS_PAGE_UNDEFINED and are not erased, so all three are discounted and the function returns NO_PAGES.

I have the following settings in sdk_config.h:

#define FDS_VIRTUAL_PAGES 3

#define FDS_VIRTUAL_PAGE_SIZE 1024

#define FDS_VIRTUAL_PAGES_RESERVED 0

Are these settings correct for what I need?

If the Flash fs_data section needs to be contiguous, how should the region be defined? In the project settings or in code (as is done for the DFU region)?

Thanks...

Declan Traill

Parents
  • Hi Declan, 

    I don't think it's an problem to have multiple fstorage instances and if they are occupying different places in the flash. 

    However, why did you choose 0x20000 - 0x22000 ? Which SDK and softdevice you are using ?It's more likely inside the softdevice/application code space . I would suggest you to choose a place at the bottom of the flash, right before the bootloader. 

    In addition, to avoid the flash area being used by the bootloader as the swap bank , you would need to configure how large your data is by using NRF_DFU_APP_DATA_AREA_SIZE (the area right under the bootloader). The layout is here.

  • If I override the settings in the flash_bounds_set() function and set the FDS area to 0x7B000 to 0x7E000 then the pages are set correctly and the pages_init() function is successful. Now the code waits forever in wait_for_fds_ready(). It seems I am getting a NRF_ERROR_INTERNAL from the low level write function sd_flash_write() which is then reported back as a FDS_ERR_OPERATION_TIMEOUT error by init_execute().

Reply
  • If I override the settings in the flash_bounds_set() function and set the FDS area to 0x7B000 to 0x7E000 then the pages are set correctly and the pages_init() function is successful. Now the code waits forever in wait_for_fds_ready(). It seems I am getting a NRF_ERROR_INTERNAL from the low level write function sd_flash_write() which is then reported back as a FDS_ERR_OPERATION_TIMEOUT error by init_execute().

Children
No Data
Related