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

Flash Data Storage place in memory

Hi,

I'm using the FDS library to store some data (configuration data). For production, I'd like to flash an initial configuration to the nRF52832. I know the storage format because it is well documented in the FDS library documentation, but I don't know where I should write the initial data in flash. In what way does the FDS library figure out where to store the data?

Does anyone have experience with this case?

  • Isn't it better to simply run the FW once without read-back protection, dump the flash and see? I know this looks like 16th century method but surprisingly this is how many embedded programming techniques work till today and they work very well;)

  • I know this doesn`t exactly answer your question, but what I do is have my initial values in my sourcecode. Then on startup I check, if the Entry with my rec_key and file_id exists. If not, it is the first startup since flashing the code so I create the entry. Otherwise I update/read the config (if I want to). Of course this will have you read the flash every time you restart your device but you have to do the read anyways if you want to access your config. On the other hand you can then do something like a "factory reset" even if you overwrite your initial data.

  • FormerMember
    0 FormerMember

    FDS/fstorage will place the data in the last available physical pages. Where the FDS/fstorage data ends depends on if there is a bootloader present or not. The end address is calculated by fs_flash_page_end_addr() in fstorage_internal_defs.h.

    If there is no bootloader present, the end address for nRF52832 is 0x80000.

    The amount of flashed used by (reserved for) FDS/fstorage depends on:

    • FDS_VIRTUAL_PAGES (sdk_config.h) (3)
    • FDS_VIRTUAL_PAGE_SIZE (sdk_config.h) (1024, number of 4-byte words)
    • FDS_PHY_PAGE_SIZE (fds_internal_defs.h) (1024, number of 4-byte words)

    The default values for nRF52832 are in parenthesis.

    Based on the above numbers, the start address for the three virtual pages will be the following:

    • 0x80000 - (1 * 0x1000) = 0x7F000)
    • 0x80000 - (2 * 0x1000) = 0x7E000)
    • 0x80000 - (3 * 0x1000) = 0x7D000)

    The stored data will be written up-wards.

    It means that the start address for the FDS/fstorage data in this case is 0x7D000.

    The start address can be doubled check by reading the address, and checking that the address contains the tag 0xDEAD0DE.

Related