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.

  • The location of the FDS storage is set by the function in fds.c:

    static void flash_bounds_set(void)
    {
        uint32_t flash_size  = (FDS_PHY_PAGES * FDS_PHY_PAGE_SIZE * sizeof(uint32_t));
        m_fs.end_addr   = flash_end_addr();
        m_fs.start_addr = m_fs.end_addr - flash_size;
    }

    This works out to be 0x20000 to 0x22000

    I am using the latest SDK, think the softdevice is s132_nrf52_5.0.0_softdevice.hex

    I tried overriding that flash_bounds_set function and setting the FDS area to 0x1000 - 0x3000, but the code does exactly the same thing - all pages are FDS_PAGE_UNDEFINED and not erased, so the pages_init() function returns NO_PAGES

Reply
  • The location of the FDS storage is set by the function in fds.c:

    static void flash_bounds_set(void)
    {
        uint32_t flash_size  = (FDS_PHY_PAGES * FDS_PHY_PAGE_SIZE * sizeof(uint32_t));
        m_fs.end_addr   = flash_end_addr();
        m_fs.start_addr = m_fs.end_addr - flash_size;
    }

    This works out to be 0x20000 to 0x22000

    I am using the latest SDK, think the softdevice is s132_nrf52_5.0.0_softdevice.hex

    I tried overriding that flash_bounds_set function and setting the FDS area to 0x1000 - 0x3000, but the code does exactly the same thing - all pages are FDS_PAGE_UNDEFINED and not erased, so the pages_init() function returns NO_PAGES

Children
No Data
Related