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 Reply Children
  • It should work with gcc and SES as well. We have covered those compile in the code: 

    #elif defined ( __CC_ARM )
    extern char Load$$LR$$LR_IROM1$$Base;
    extern char Load$$LR$$LR_IROM1$$Length;
    extern char Load$$LR$$LR_IROM1$$Limit;
    #define CODE_START ((uint32_t)&Load$$LR$$LR_IROM1$$Base)
    #define CODE_END   ((uint32_t)&Load$$LR$$LR_IROM1$$Limit)
    #define CODE_SIZE  ((uint32_t)&Load$$LR$$LR_IROM1$$Length)
    
    #elif defined ( __ICCARM__ )
    extern void * __vector_table;
    extern char RO_END$$Base;
    #define CODE_START ((uint32_t)&__vector_table)
    #define CODE_END   ((uint32_t)&RO_END$$Base)
    #define CODE_SIZE  (CODE_END - CODE_START)
    
    #elif defined(__SES_ARM)
    extern uint32_t * _vectors;
    extern uint32_t __FLASH_segment_used_end__;
    #define CODE_START ((uint32_t)&_vectors)
    #define CODE_END   ((uint32_t)&__FLASH_segment_used_end__)
    #define CODE_SIZE  (CODE_END - CODE_START)
    
    #elif defined ( __GNUC__ )
    extern uint32_t __isr_vector;
    extern uint32_t __etext;
    #define CODE_START ((uint32_t)&__isr_vector)
    #define CODE_END   ((uint32_t)&__etext)
    #define CODE_SIZE  (CODE_END - CODE_START)
    #endif

Related