Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Does Zigbee NVRAM get erased if the Zigbee network is not starting with already present network parameters in Zigbee NVRAM?

Hello Nordic support,

My application is based on nRF5 SDK for Thread and Zigbee v4.2.0, with Softdevice S140 as I want my application to operate in either in BLE or Zigbee mode (Note that when Nordic is running in Zigbee, the zigbee role is a coordinator). On first startup, I notice that in Zigbee handler, the events received are ZB_ZDO_SIGNAL_PRODUCTION_CONFIG_READY, ZB_ZDO_SIGNAL_SKIP_STARTUP and ZB_BDB_SIGNAL_DEVICE_REBOOT. From what I understand, ZB_BDB_SIGNAL_DEVICE_REBOOT is received if Zigbee parameters are already present in Zigbee NVRAM area.

In my application,  if ZB_BDB_SIGNAL_STEERING is not received within 30s, I restart . So, I noticed that the applications restarts twice because ZB_BDB_SIGNAL_STEERING  is not received. After another startup, I noticed that Zigbee events received were ZB_ZDO_SIGNAL_PRODUCTION_CONFIG_READY, ZB_ZDO_SIGNAL_SKIP_STARTUP  and ZB_BDB_SIGNAL_DEVICE_FIRST_START. After this event sequence, ZB_BDB_SIGNAL_STEERING  was received and Zigbee network was formed successfully. From what I understand, ZB_BDB_SIGNAL_DEVICE_FIRST_START event is generated when Zigbee NVRAM was erased and no previous network configuration was present. 

I would like to understand what could have triggered Zigbee NVRAM to get erased since my application is not doing any Zigbee NVRAM erase? 

Please let me know if you need more details in looking into the issue.

Regards,

Anusha

  • Hi Anusha,

    You are correct that ZB_BDB_SIGNAL_DEVICE_FIRST_START is generated when there is no network configuration in NVRAM. The network data could be deleted if the device leaves the network due to wrong network configuration or receiving a leave command.

    Please upload the complete log from the device.

    Best regards,
    Marte

  • Hi Marte,

    Thanks for your response. 


    The network data could be deleted if the device leaves the network due to wrong network configuration or receiving a leave command. - Since my application is a Zigbee coordinator application, the case of receiving a leave command would not apply as per my understanding. So, probably the network configuration is wrong then. If this is the case, I would like to understand if Softdevice deletes this network data. I would like to understand the complete flow of what happens when Zigbee network configuration is wrong. 

    I am afraid I cannot share the complete logs from the device as it has application specific information. However, I have attached the code snippet for zigbee handler and the corresponding log. Hope it helps.

    /**@brief Zigbee stack event handler.
     *
     * @param[in]   bufid   Reference to the Zigbee stack buffer used to pass signal.
     */
    void zboss_signal_handler(zb_bufid_t bufid)
    {
        /* Read signal description out of memory buffer. */
        zb_zdo_app_signal_hdr_t * p_sg_p      = NULL;
        zb_zdo_app_signal_type_t  sig         = zb_get_app_signal(bufid, &p_sg_p);
        zb_ret_t                  status      = ZB_GET_APP_SIGNAL_STATUS(bufid);
        zb_ret_t                  zb_err_code;
        zb_bool_t                 comm_status;
        zb_time_t                 timeout_bi;
    	
    	PRINT("Zigbee_signal_handler;%d\n\r", sig);
    
        switch(sig)
        {
            case ZB_ZDO_SIGNAL_PRODUCTION_CONFIG_READY:
              if (status != RET_OK)
              {
                PRINT("Production configuration is not present or invalid (status: %d)\n", status);
              }
              else
              {
                zb_production_config_ver_1_t *prod_conf = ZB_ZDO_SIGNAL_GET_PARAMS(p_sg_p, zb_production_config_ver_1_t);
                char ieee_addr_buf[17] = {0};
                int  addr_len;
    
                PRINT("Loading application production config");
    
                /* IEEE address is automatically parsed and set by the ZBOSS stack. */
                addr_len = ieee_addr_to_str(ieee_addr_buf, sizeof(ieee_addr_buf), prod_conf->extended_address);
                if (addr_len < 0)
                {
                    strcpy(ieee_addr_buf, "unknown");
                }
    
                /* Channel mask has to be parsed and applied manually. */
                zb_set_bdb_primary_channel_set(prod_conf->aps_channel_mask);
                zb_set_bdb_secondary_channel_set(prod_conf->aps_channel_mask);
                PRINT("\tChannel mask %08lx", prod_conf->aps_channel_mask);
    
                PRINT("Production configuration successfully loaded");
              }
            break;
    		
    		case ZB_ZDO_SIGNAL_SKIP_STARTUP:
              ZB_ERROR_CHECK(zigbee_default_signal_handler(bufid));
    		  //Application specific code
            break;
    		
    		case ZB_BDB_SIGNAL_DEVICE_FIRST_START:
                /* At this point Zigbee stack is ready to operate and the BDB initialization procedure has finished.
                 * There is no network configuration stored inside NVRAM.
                 *
                 * Next step:
                 *  - If the device implements Zigbee router or Zigbee end device,
                 *    perform network steering for a node not on a network (see BDB specification section 8.3).
                 *  - If the device implements Zigbee coordinator,
                 *    perform network formation (see BDB specification section 8.4).
                 */
                PRINT("enable trust center\r\n");
                zb_bdb_set_legacy_device_support(ZB_TRUE); //1 to disable trust center require key exchange; 0 to enable
    
                ZB_ERROR_CHECK(zigbee_default_signal_handler(bufid));
    			//Application specific code
            break;
    		
    		case ZB_BDB_SIGNAL_DEVICE_REBOOT:
                // BDB initialization completed after device reboot, use NVRAM contents during initialization. Device joined/rejoined and started.
                if (status == RET_OK)
                {
                    PRINT("Coordinator restarted successfully\r\n");
                }
                else
                {
                    PRINT("Failed to initialize Zigbee stack using NVRAM data (status: %d)", status);
                }
    			PRINT("enable trust center\r\n");
                zb_bdb_set_legacy_device_support(ZB_TRUE); //1 to disable trust center require key exchange; 0 to enable
                break;
    
            case ZB_BDB_SIGNAL_STEERING:
                //Application specific code
                break;
    
    
            default:
                /* Call default signal handler. */
                ZB_ERROR_CHECK(zigbee_default_signal_handler(bufid));
                break;
        }
    
        /* All callbacks should either reuse or free passed buffers. If bufid == 0, the buffer is invalid (not passed) */
        if (bufid)
        {
            zb_buf_free(bufid);
        }
    }
    00> 00:00:00.000;Starting application
    00> 00:00:00.044;Zigbee_signal_handler;sig;16
    00> 
    00> 00:00:00.044;Production configuration is not present or invalid (status: -1)
    00> 00:00:00.044;Zigbee_signal_handler;sig;1
    00> 
    00> 00:00:00.064;Zigbee_signal_handler;sig;6
    00> 
    00> 00:00:00.064;Coordinator restarted successfully
    00> 00:00:00.064;enable trust center
    
    00> 00:00:30.072;30s TimeOut
    00> 00:00:30.072;Restart
    
    00> 00:00:00.000;Starting application 
    00> 00:00:00.043;Zigbee_signal_handler;sig;16
    00> 
    00> 00:00:00.043;Production configuration is not present or invalid (status: -1)
    00> 00:00:00.043;Zigbee_signal_handler;sig;1
    00> 
    00> 00:00:00.062;Zigbee_signal_handler;sig;6
    00> 
    00> 00:00:00.062;Coordinator restarted successfully
    00> 00:00:00.062;enable trust center
    00> 00:00:30.074;30s TimeOut
    00> 00:00:30.074;Restart
    
    00> 00:00:00.000;Starting application 
    00> 00:00:00.040;Zigbee_signal_handler;sig;16
    00> 
    00> 00:00:00.040;Production configuration is not present or invalid (status: -1)
    00> 00:00:00.041;Zigbee_signal_handler;sig;1
    00> 
    00> 00:00:00.044;Zigbee_signal_handler;sig;5
    00> 
    00> 00:00:00.044;enable trust center
    
    00> 00:00:08.179;Zigbee_signal_handler;sig;8
    00> 00:00:08.653;Zigbee_signal_handler;sig;7
    
    //After this, network is formed properly
    
    
    

    Regards,

    Anusha

  • Hi Anusha,

    Is there a particular reason you restart the device if ZB_BDB_SIGNAL_STEERING is not received within 30 seconds?

    It is possible that the repeated restarts are causing some issues. I would recommend manually starting network steering upon receiving ZB_BDB_SIGNAL_DEVICE_REBOOT. You can find this in some of the examples in the SDK:

    #define ZIGBEE_MANUAL_STEERING            ZB_FALSE                              /**< If set to 1 then device will not open the network after forming or reboot. */
    
    
    
    case ZB_BDB_SIGNAL_DEVICE_REBOOT:
        // BDB initialization completed after device reboot, use NVRAM contents during initialization. Device joined/rejoined and started.
        if (status == RET_OK)
        {
            if (ZIGBEE_MANUAL_STEERING == ZB_FALSE)
            {
                NRF_LOG_INFO("Start network steering");
                comm_status = bdb_start_top_level_commissioning(ZB_BDB_NETWORK_STEERING);
                ZB_COMM_STATUS_CHECK(comm_status);
            }
            else
            {
                NRF_LOG_INFO("Coordinator restarted successfully");
            }
        }

    Best regards,
    Marte

  • Hi Marte,

    The reason for restarting was because we found that pairing of certain Zigbee devices was not working if this step was not done.

    Regards,

    Anusha

  • Hi Anusha,

    Did you try manually starting network steering when ZB_BDB_SIGNAL_DEVICE_REBOOT is generated, and did it help the problem?

    Best regards,
    Marte

Related