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

Flash memory and bonding data from Peer Manager

Hi! 

My setup:

* nRF52 DK

* nRF5_SDK_15.0.0_a53641a

* s132_nrf52_6.0.0

* SES V3.34b 64-bit

In my application I am using Peer Manager to manage bonding and also I am going to store some user data in persistent storage (FDS), for example measurement results. I am not really familiar with the memory structure in Nordic chips, I have seen Product Specification, but some things are still unclear. My questions are:

1) How many bonding records will Peer Manager store? And what is the size of a bonding record? What function should I use to limit maximum bonds number?

2) In case my application for now is 191KB large (512KB chip):

Configuration memory segments:

FLASH RX 0x0 0x80000

RAM RWX 0x20000000 0x10000

Section placement macros:

FLASH_PH_START=0x0

FLASH_PH_SIZE=0x80000

RAM_PH_START=0x20000000

RAM_PH_SIZE=0x10000

FLASH_START=0x26000

FLASH_SIZE=0x5a000

RAM_START=0x20003770

RAM_SIZE=0xc890

What are my limitations on storing my personal nonvolatile data? How can I assure that bonding records will not overwrite my data and vice-versa? Is there any way to assign certain FLASH pages to bond manager and other for other uses?

3) I have noticed that when I program my device the bonds stay untouched (which is weird for me). Where is the declaration for them to be in another memory segment than the code?

Parents
  • Hi,

     

    How many bonding records will Peer Manager store? And what is the size of a bonding record? What function should I use to limit maximum bonds number?

    The peer manager uses the FDS library for storing bonds. A bond has a variable length (~100 bytes) based on what type of connection, central settings, etc.

    If FDS is configured to use 3 pages of flash (2 x 4K for data storage, and 1 x 4K for swap), then you have a total of 8 kBytes of storage. This can however be configured in your sdk_config.h to match your needs.

    What are my limitations on storing my personal nonvolatile data? How can I assure that bonding records will not overwrite my data and vice-versa? Is there any way to assign certain FLASH pages to bond manager and other for other uses?

    The FDS uses record and key IDs to handle your data, and certain values are restricted (to use by peer manager for instance). A more detailed overview and description can be found here:

    http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/lib_fds_functionality.html?cp=4_0_0_3_52_1

    I have noticed that when I program my device the bonds stay untouched (which is weird for me). Where is the declaration for them to be in another memory segment than the code?

    This is because your IDE (or nrfjprog --program as well) will work on a flash-page aligned operation. it will therefore only erase pages that your program uses.

    Do delete your bond data, you can perform an erase all: "nrfjprog -e", or call peer_manager_init(true) in your program to clear your bonds.

     

    Best regards,

    Håkon

     

     

  • Thank you, Hakon, for detailed answers :)

    There are more questions that came to my mind:

    1)  If keys from 0xC000 to 0xFFFF are reserved to Peer Manager (which I am using) will I get crash/error when I try to assign those keys to my personal nonvolatile data? And this is the way to protect bonding data from being overwritten by other stored records?

    2) In the Infocenter you have linked there are keys of values: 0x1111 and 0x2222. Is there any purpose on setting those values instead of 0x0001 and 0x0002 respectively? Or is it just an example and nothing to worry about?

    3) How to understand the "files" in FDS? Is it just a name for a group of records to help managing them?

    4) Limitations on memory:
        4.1) I have seen uint32_t 0xDEADBEEF and char [ ]  "Hello, world!" assigned to single records. Is there any maximum size for a single record? Is it possible for the record to be larger than 4KB page size?
        4.2.) Can a single file consist of records that are cumulatively larger than the page size?

  • Hi, 

    1) If keys from 0xC000 to 0xFFFF are reserved to Peer Manager (which I am using) will I get crash/error when I try to assign those keys to my personal nonvolatile data? And this is the way to protect bonding data from being overwritten by other stored records?

    You will then potentially use files that are in use by the peer manager, thus potentially corruption those records.

    2) In the Infocenter you have linked there are keys of values: 0x1111 and 0x2222. Is there any purpose on setting those values instead of 0x0001 and 0x0002 respectively? Or is it just an example and nothing to worry about?

    Just an example, nothing to worry about. You are free to use record keys in the range 0x0001 - 0xBFFF.

    3) How to understand the "files" in FDS? Is it just a name for a group of records to help managing them?

    "Files" can consist of one or more record_id's. As you mention, it is essentially a group of records.

    4) Limitations on memory:
        4.1) I have seen uint32_t 0xDEADBEEF and char [ ]  "Hello, world!" assigned to single records. Is there any maximum size for a single record? Is it possible for the record to be larger than 4KB page size?
        4.2.) Can a single file consist of records that are cumulatively larger than the page size?

    The maximum amount of data in one single record is inherited by the restriction from the softdevice API sd_flash_write(), which limits it to one flash page (4kByte on nRF52-devices). 

    This restriction is on records only, so a file consisting of more than one record can be >4 kByte.

     

    Note that each record must be word-aligned (4 byte aligned)

     

    Best regards,

    Håkon

Reply
  • Hi, 

    1) If keys from 0xC000 to 0xFFFF are reserved to Peer Manager (which I am using) will I get crash/error when I try to assign those keys to my personal nonvolatile data? And this is the way to protect bonding data from being overwritten by other stored records?

    You will then potentially use files that are in use by the peer manager, thus potentially corruption those records.

    2) In the Infocenter you have linked there are keys of values: 0x1111 and 0x2222. Is there any purpose on setting those values instead of 0x0001 and 0x0002 respectively? Or is it just an example and nothing to worry about?

    Just an example, nothing to worry about. You are free to use record keys in the range 0x0001 - 0xBFFF.

    3) How to understand the "files" in FDS? Is it just a name for a group of records to help managing them?

    "Files" can consist of one or more record_id's. As you mention, it is essentially a group of records.

    4) Limitations on memory:
        4.1) I have seen uint32_t 0xDEADBEEF and char [ ]  "Hello, world!" assigned to single records. Is there any maximum size for a single record? Is it possible for the record to be larger than 4KB page size?
        4.2.) Can a single file consist of records that are cumulatively larger than the page size?

    The maximum amount of data in one single record is inherited by the restriction from the softdevice API sd_flash_write(), which limits it to one flash page (4kByte on nRF52-devices). 

    This restriction is on records only, so a file consisting of more than one record can be >4 kByte.

     

    Note that each record must be word-aligned (4 byte aligned)

     

    Best regards,

    Håkon

Children
No Data
Related