The upper limit of user that saved by peer_manage

How many users data can be saved by peer_manege that may limited by the size of flash?

I want to know the max value.

Parents
  • Hi,

    There is no defined maximum value of peers, it is only limited by flash size (and the number of pages allocafted to FDS and/or other data that is also stored in FDS. See this post for the typical size of a bond.

  • I find such define in peer_manager_types.h我在peer_manager_types.h中找到了这样的定义

    #define PM_PEER_ID_N_AVAILABLE_IDS      256                                            /**< @brief The number of available peer IDs. */

    This define will not limit the number of peers?这个定义不会限制节点的数量吗?

    Besides,I find such explain in third-party course about FDS.另外,我在关于FDS的第三方课程中也发现了这样的解释。

    Whether it is true?If it is certain,What is the end address of FDS for peer_manager?

    Maybe it depends on the number of pages allocafted to FDS?

    Here's a new problem.If the number of pages allocafted to FDS is limited?If not,The defined flash space will more than the virtual flash space.How the chip will deal with it?

    这是真的吗?如果确定,peer_manager的FDS结束地址是什么?

  • Hi,

    Chaoyue Ying said:
    I find such define in peer_manager_types.h

    You are right, there is a PM_PEER_ID_N_AVAILABLE_IDS. This is set to 256 though which is a value that is selected to be higher than what will normally ever be needed (and if we assume the same bond size as in the post I linked to with one CCCD, that wnumber will requier 38 kB flash storage, so in practice you would need to reserve 44 kB (10 flash pages) for FDS in order to be able to store that much. (If you need a higher value I would be intersted in understanding why, but that said you may adjust PM_PEER_ID_N_AVAILABLE_IDS to a higher value but make sure that the larges possible peer ID + connection handle is still lower than 0xFFFE which is PDS_LAST_RESERVED_FILE_ID.

    Chaoyue Ying said:

    Maybe it depends on the number of pages allocafted to FDS?

    Yes, a normal project will allocate less than 10 pages for FDS, but that is configurable.

    Chaoyue Ying said:
    Here's a new problem.If the number of pages allocafted to FDS is limited?If not,The defined flash space will more than the virtual flash space.How the chip will deal with it?

    I did not understand the question. Can you elaborate? Generally though, you can monitor FDS usage and take action if the usage is too high (for instance delete the oldest bonds). It often makes sense to do this proactively for instance check after every bonding. You can check FDS usage with fds_stat().

  • Maybe you ignored the picture in previous reply.

    It said the record key and file id was be saved for peer_manage start with 0xC0000.But the end value was not be refer to.And I want to know if their end value depends on pages.

    And maybe I'm wrong to understand the relationship of (record key and file id) with flash.If they are not related?

    About the question of FDS pages max value above.I think this situation exists that pages multiply by size more than 512KB that is the all flash size of nRF52832-QFAA.How it will deal it?

Reply
  • Maybe you ignored the picture in previous reply.

    It said the record key and file id was be saved for peer_manage start with 0xC0000.But the end value was not be refer to.And I want to know if their end value depends on pages.

    And maybe I'm wrong to understand the relationship of (record key and file id) with flash.If they are not related?

    About the question of FDS pages max value above.I think this situation exists that pages multiply by size more than 512KB that is the all flash size of nRF52832-QFAA.How it will deal it?

Children
  • Chaoyue Ying said:
    Maybe you ignored the picture in previous reply.

    Yes, I was unable to read that.

    Chaoyue Ying said:
    It said the record key and file id was be saved for peer_manage start with 0xC0000.But the end value was not be refer to.And I want to know if their end value depends on pages.

    The recod key and file ID is not related to where it is located on flash. The location will move around every time FDS garbage collection is perfomed. If you want to understand more about this you can see the FDS documentation.

    Chaoyue Ying said:
    About the question of FDS pages max value above.I think this situation exists that pages multiply by size more than 512KB that is the all flash size of nRF52832-QFAA.How it will deal it?

    Unelss you have very good reason not to, you will set the virtual page size equal to the physical page size, which is 4 kB (0x1000). You configure FDS in sdk_config.h. Most example use this default config for FDS:

    // <e> FDS_ENABLED - fds - Flash data storage module
    //==========================================================
    #ifndef FDS_ENABLED
    #define FDS_ENABLED 1
    #endif
    // <h> Pages - Virtual page settings
    
    // <i> Configure the number of virtual pages to use and their size.
    //==========================================================
    // <o> FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. 
    // <i> One of the virtual pages is reserved by the system for garbage collection.
    // <i> Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection.
    // <i> The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes.
    
    #ifndef FDS_VIRTUAL_PAGES
    #define FDS_VIRTUAL_PAGES 3
    #endif
    
    // <o> FDS_VIRTUAL_PAGE_SIZE  - The size of a virtual flash page.
     
    
    // <i> Expressed in number of 4-byte words.
    // <i> By default, a virtual page is the same size as a physical page.
    // <i> The size of a virtual page must be a multiple of the size of a physical page.
    // <1024=> 1024 
    // <2048=> 2048 
    
    #ifndef FDS_VIRTUAL_PAGE_SIZE
    #define FDS_VIRTUAL_PAGE_SIZE 1024
    #endif
    
    // <o> FDS_VIRTUAL_PAGES_RESERVED - The number of virtual flash pages that are used by other modules. 
    // <i> FDS module stores its data in the last pages of the flash memory.
    // <i> By setting this value, you can move flash end address used by the FDS.
    // <i> As a result the reserved space can be used by other modules.
    
    #ifndef FDS_VIRTUAL_PAGES_RESERVED
    #define FDS_VIRTUAL_PAGES_RESERVED 0
    #endif
    

    Here, the virtual page size is 1024 words, which is 4096 bytes which is one page, and that is what I recomend you keep. 3 pages are reserved, which is in total 12 kB. Of this 1 page (4 kB) is used as swap page used during garbage collection, so you h ave 8 kB of data you can store (ignoring overhead). You can increase the FDS_VIRTUAL_PAGES as needed if you need mre FDS data as long as there is available flash on your device.

  • So,Whether I can understand it as that,I can set 1024 words per page and reserved 128 pages.那么,我是否可以理解为,我可以设置每页1024个单词,预留128页。那么,我是否可以理解为,我可以设置每页1024个单词,预留128页。

    One page will used to garbage collection(assumption unchanged),therefore I can save 127 pages data of peer_data.And I see a bond informaton need 20 words,that means about 6502 bond informations can be saved if flash all used to save without recycle? 垃圾收集一个页面将用于垃圾收集(假设不变),因此我可以保存127个页面垃圾收集一个页面将用于垃圾收集(假设不变),因此我可以保存127个页面垃圾收集

  • Hi,

    Please ask the whole question in English.

    Chaoyue Ying said:
    I can set 1024 words per page and reserved 128 pages.

    No. That would reserve the entier flash for FDS, leaving no room for the application or anything else.

  • Theoretically,I can reserve the entier flash for FDS used to save bond information?RAM will ensure application running normally?In this premise,The max number of bond users can be calculate that without out of range result in overwrite the previous data. 从理论上讲,

  • Chaoyue Ying said:
    Theoretically,I can reserve the entier flash for FDS used to save bond information?

    No. You need space for your application at the very least.

    Chaoyue Ying said:
    RAM will ensure application running normally?

    No. The applicaiton reside in flash (though theoretically you could run parts from RAM but it would still need to be stored in flash and copied to RAM on reset).

Related