This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVICE_MANAGER_MAX_BONDS problem

Hello

I made the switch from SDK 6.0.0 to SDK 6.1.0 with SD7. At first we didn't get it to work. We would get the error NRF_ERROR_INVALID_PARAM on dm_init(). The problem was that the DEVICE_MANAGER_MAX_BONDS was set to high. With SDK 6.0.0 we where able to set DEVICE_MANAGER_MAX_BONDS to 26 while with SDK 6.1.0 the maximum seems to be 13. If we set this any higher the dm_init() will return the NRF_ERROR_INVALID_PARAM error. Now my question is why does this error happen because the comments in the code says that the maximum value for DEVICE_MANAGER_MAX_BONDS is 254 with no dependencies. The application that we are building is based on the ble_app_proximity example.

Best Regards, Rinze van der Wal

Parents
  • NRF_ERROR_INVALID_PARAM actually comes from pstorage, because you are requesting more than one page of flash (1024B,0x400). One bond requires 80B, 0x50 of flash, and with 13 bonds 13 * 80=1040B is requested. 12 is accepted because 12 * 80=960B.

    The check BLOCK_COUNT_CHECK was modified between SDK6.0 and SDK6.1 to avoid storing a single bond in two separate pages, like 13th bond would be.

    This is not how it supposed to be, you should be able to store more than 12 bonds. So this is a bug. I have reported it, and I will add updates to the answer.

    Until we have a permanent fix on this, I suggest the following workaround:

    In device_manager_peripheral.c find the dm_init function, and change

    #define ALL_CONTEXT_SIZE (DEVICE_CONTEXT_SIZE + SERVICE_CONTEXT_SIZE + APP_CONTEXT_SIZE) to #define ALL_CONTEXT_SIZE 128;

    This will ensure that a bond are not stored in two separate pages. Since 1024%128 is 0.

    You must also ensure that pstorage has enough flash available. 26 * 128=3328B is required, which means you need 4 pages 4 * 1024=4096B. You do this by modifying #define PSTORAGE_DATA_START_ADDR in pstorage_platform.h.

    This is how I did it:

    #define PSTORAGE_TOTAL_PAGES       4  //Total number of flash pages needed for all applications.
    #define PSTORAGE_DATA_START_ADDR   ((PSTORAGE_FLASH_PAGE_END - PSTORAGE_TOTAL_PAGES - 1) * PSTORAGE_FLASH_PAGE_SIZE)  /**< Start address for persistent data, configurable according to system requirements. */
    

    PSTORAGE_FLASH_PAGE_END is the total number of flash pages(256,0x100), -1 is to reserve a swap page, and PSTORAGE_FLASH_PAGE_SIZE is the page size(1024,0x400). This gives a pstorage start address of 0x3EC00.

    Edit: The define should be changed, not only the input to pstorage_register(...)

  • Still looking for an update/confirmation of where this has been fixed.

Reply Children
No Data
Related