Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Where does flash storage store Peer Manager data

Hi 

I am integrating BLE with LESC into a legacy sensor product using SDK v11.

The problem I am running into are errors in the FDS module when trying to make a secure connection. Also during reset I am receiving bank invalid messages from our internal api for accessing flash memory. I am trying to make these things coexist and have a question about where the Flash Storage module stores data.

From the Nordic documentation I have found the following statement:

"Flash storage assigns flash space with the highest memory address (right below the bootloader, if present) to the module with the highest priority. So if, for example, module 1 has low priority and needs one page and module 2 has high priority and needs two pages, fstorage assigns two pages starting with the highest memory address to module 2 and one page, starting after the two pages, to module 1."

Below is our memory map. Note there is a bootloader but it is not located in the highest memory location.

#define MEMORY_MAP_ROM_ADDRESS_SOFTDEVICE                0x0
#define MEMORY_MAP_ROM_ADDRESS_BANK_0                         0x1b000
#define MEMORY_MAP_ROM_ADDRESS_BOOTLOADER              0x3b400
#define MEMORY_MAP_ROM_ADDRESS_NVM                               0x3e800
#define MEMORY_MAP_ROM_ADDRESS_BANK_INFO                  0x3ec00
#define MEMORY_MAP_ROM_ADDRESS_PSTORAGE_SWAP      0x3f000
#define MEMORY_MAP_ROM_ADDRESS_HIGHEST                      0x3f400

Bank 0 is where our application goes. Bootloader is a custom bootloader we authored. NVM is where we store application data.

I assumed fstorage would allocate memory above what we call MEMORY_MAP_ROM_ADDRESS_HIGHEST. The addresses you see are the values after I subtracted 3 pages worth of memory from the size of bank 0, shifting the higher order addresses.

So with this memory map, where would fstorage allocate space? Can I control this location?

  • Hi David, 

     

    Could you let me now which softdevice version you are using ? Just to be sure that softdevice support LESC. 

    Regarding the start address of Fstorage. The way it located is it start from FS_PAGE_END_ADDR and go down from that. We use fs_flash_page_end_addr() to determine where shoudl that end address be, on top of the flash, or right before the bootloader. 

    In your case I'm not sure putting the fstorage above 0x3f400 is a good idea. This leaves only 3 pages left for fstorage, and we need one page as swap page, if you use fds on top. 

    I think leaving the fstorage right before the bootloader would be safer, you can expand fstorage area as much as needed. 

     

  • Thanks, I am using S130

    I changed my address settings back to original as shown below.

    #define MEMORY_MAP_ROM_ADDRESS_SOFTDEVICE              0x0
    #define MEMORY_MAP_ROM_ADDRESS_BANK_0                       0x1b000
    #define MEMORY_MAP_ROM_ADDRESS_BOOTLOADER            0x3c000
    #define MEMORY_MAP_ROM_ADDRESS_NVM                             0x3f400
    #define MEMORY_MAP_ROM_ADDRESS_BANK_INFO                 0x3f800
    #define MEMORY_MAP_ROM_ADDRESS_PSTORAGE_SWAP     0x3fc00
    #define MEMORY_MAP_ROM_ADDRESS_HIGHEST                     0x40000

    Then I put a brake point to test the address value being set in FS_PAGE_END_ADDR. I have confirmed it is being set to 0x3C000 which is the start of the bootloader.

    Still getting errors. Can pstorage and fstorage coexist?

  • Hi David, 

     

    All of these  MEMORY_MAP_ROM_ADDRESS_* macro define are not our define. I guess it's your application specific define and they are not related to fstorate or pstorage. 

    Basically fstorage starts (top down) from FS_PAGE_END_ADDR and pstorage starts (top down) from PSTORAGE_FLASH_PAGE_END. You just need to make sure they are not over lapping and not overlapping the bootloader , then you should be fine. 

Related