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

BLE MESH PERSISTENT_STORAGE questions, and coexistence with MBR parameter storage (SDK v16, mesh v 4.0)

I am just starting development of a BLE mesh product on the nRF52840 using the serial demo on the nRF52840DK.  By default PERSISTENT_STORAGE=0 in the demo so the nodes forget their configuration after each power cycle.  I set PERSISTENT_STORAGE=1 in Segger and now the configuration is persistent - great.  However I have some questions:

- By breakpointing I found the flash file system is using a 4k FLASH sector at 0xFE000 - this is the same location as MBR parameter storage on the 52840 with S140 V 7.0.  Is this an issue ?  Also the mp_recovery_area is at 0xFF000 - which conflicts with the bootloader settings.

- Does PERSISTENT_STORAGE=1 also cause mesh traffic to be persistent ?  (e.g. the mesh replay cache)   Is this automatic with the reception / relay of each mesh message, or must the application invoke a function to store the replay cache to NVM prior to power off ?

My requirements, in short are that the mesh nodes retain their configuration (netkeys, appkeys, replay cache)  when powered off, and ideally retain netkeys and appkeys when reprogrammed (either via serial or BLE).  I'd be very grateful for any guidance you can offer.

  • I think I may have found the answer to my question in the function flash_manager_defrag_init() which sets up the flash file system 1 page below the top of FLASH if there is no bootloader, and 1 page below the bootloader (or rather 2) if the bootloader is present.  My FLASHing the 52840DK must have erased the bootloader (if there was one on the DK) hence the location I am finding of my flash file system.  I was considering canceling this post, but I'll leave it here in case other developers run into the same question.

    bool flash_manager_defrag_init(void)
    {
    #ifdef FLASH_MANAGER_RECOVERY_PAGE
    mp_recovery_area = (flash_manager_recovery_area_t *) FLASH_MANAGER_RECOVERY_PAGE;
    #else
    flash_manager_recovery_area_t * p_flash_end;
    if (BOOTLOADERADDR() != BLANK_FLASH_WORD && BOOTLOADERADDR() != 0)
    {
    #if NRF52_SERIES
    /* The 52-series SoftDevice's MBR needs an extra page for bootloader and SoftDevice DFU-ing. */
    p_flash_end = (flash_manager_recovery_area_t *) (BOOTLOADERADDR() - PAGE_SIZE);
    #else
    p_flash_end = (flash_manager_recovery_area_t *) BOOTLOADERADDR();
    #endif
    }
    else
    {
    p_flash_end = (flash_manager_recovery_area_t *) DEVICE_FLASH_END_GET();
    }
    /* Recovery area is last page of application controlled flash */
    mp_recovery_area = p_flash_end - FLASH_MANAGER_RECOVERY_PAGE_OFFSET_PAGES - 1; /* pointer arithmetic */
    #endif

    __LOG(LOG_SRC_FM, LOG_LEVEL_DBG3, "BOOTLOADERADDR(): 0x%08x fm_recovery_area: 0x%08x\n",
    BOOTLOADERADDR(), mp_recovery_area);
    return recover_defrag_progress();
    }

Related