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

[ZIGBEE] ZED lost connection param data

SDK: 14.1.0

CHIP: nRF52840

CONFIG: ZIGBEE&BLE MULTI PROTOCOL

I wants to keep store zigbee pairing data after reset.

I setups like this.

zigbee_erase_persistent_storage(ERASE_PERSISTENT_CONFIG); // ZB_FALSE


zb_ret_t zigbee_default_signal_handler(zb_bufid_t bufid)
{
    ...
    case ZB_ZDO_SIGNAL_SKIP_STARTUP:
        NRF_LOG_INFO("Zigbee stack initialized");
        comm_status = bdb_start_top_level_commissioning(ZB_BDB_INITIALIZATION);
        NRF_LOG_INFO("initialized zb_bdb_is_factory_new(): %d\r\n", zb_bdb_is_factory_new());
    ...
}

After joining procedure, I reset my device with nrfjprog -r.

until zb_bdb_is_factory_new set 1, zb_bdb_is_factory_new  return 0. 

When I repeated 2~3 times, zb_bdb_is_factory_new is 1.

Zed fails to rejoin the network after that.

How can I fix it?

and Where I can check data structure used by zigbee stack?

attaching flash config in sdk_config.h

// <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

// <s> 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 ((ZIGBEE_NVRAM_PAGE_SIZE * ZIGBEE_NVRAM_PAGE_COUNT + ZIGBEE_NVRAM_CONFIG_PAGE_SIZE * ZIGBEE_NVRAM_CONFIG_PAGE_COUNT)/(FDS_VIRTUAL_PAGE_SIZE * 4))
#endif
 

And I check After the steering is successful, the zb_bdb_is_factory_new() interface returns true

but I can't find "bdb_load_factory_new" function.

  • Hi,

    I wants to keep store zigbee pairing data after reset.

     This should be handled by ERASE_PERSISTENT_CONFIG. If it's set to false, then the network data will not get erased after a power cycle or reboot. The device will remember things such as PAN ID, Extended PAN ID, network address, and security key and will be able to rejoing silently to the network after reset. This information is stored in the NVRAM. So it should work in your case, and zb_bdb_is_factory_new should return 0. The function bdb_load_factory_new is a part of the ZBOSS stack where the implementation is unavailable to the user, but if you search for it in the SDK you should still find references to it, and you should be able to use it. Could you please try calling it before zb_bdb_is_factory_new and see if you get the correct value from zb_bdb_is_factory_new then, and if your device is able to rejoin?

    If this doesn't fix your problem, got you please get a sniffer log and attach it here as a pcac file?

    Best regards,

    Marte

  • This should be handled by ERASE_PERSISTENT_CONFIG. If it's set to false, then the network data will not get erased after a power cycle or reboot.

    ERASE_PERSISTENT_CONFIG already set false.

    The function bdb_load_factory_new is a part of the ZBOSS stack where the implementation is unavailable to the user, but if you search for it in the SDK you should still find references to it, and you should be able to use it.

    extern void bdb_load_factory_new_flag(void);
    
    
    ...
    bdb_load_factory_new_flag();

    I add this to the code. but It still be same. I wants to know data structure of read/write flash data.

    Could you please try calling it before zb_bdb_is_factory_new and see if you get the correct value from zb_bdb_is_factory_new then, and if your device is able to rejoin?

    Yes, If zb_bdb_is_factory_new returns 0, zed is always successfully rejoined.

  • Hi,

    Are you still experiencing issues with this? Did adding bdb_load_factory_new_flag change anything at all?

    _maibi said:
    I wants to know data structure of read/write flash data.

     For this, you should look at the NVRAM, which handles the flash in the Zigbee SDK. You can use zb_nvram_write_dataset to write to flash. You can also read about  Zigbee stack flash usage configuration and the new NVRAM API in v4.0.0 of the SDK.

    Best regards,

    Marte

  • I checked log and found that sometimes flash write function called but data is empty.
    I added the code to read back flash data after writing flash data in "nrf52_nvram.c" file.
    It sometimes doesn't properly write flash. after reading flash data in 2~3 time, the flash data which read after writing flash is equal to writing data.

    I don't experienced this issue after adding this code. Would you check up about this?

  • Hi,

    I'll ask internally about this and come back to you.

    Best regards,

    Marte

Related