Thread network key changes when migrating from NCS 2.4.1 to 2.6.1

nRF52840

NCS 2.4.1  to NCS 2.6.1

My project is based on the coap_server example.  When I ported it from NCS 2.4.1 to NCS 2.6.1, the network key and PSKC changed.  All other Thread credentials stayed the same (channel, channel mask,  panid, extended panid, mesh local prefix, network name, security policy).

The project supports DFU, so when upgrading from a 2.4.1 based version to a 2.6.1 based version, the network key changed and the device cannot communicate with other devices on the original network.

Both versions use identical pm_static.yml files, so the storage settings partition has not moved.

Is this a bug?  Is there a workaround?

Mary

  • Hi, 

    Which DFU do you use, via UART/USB or BLE?

    Do you use the nRF Device Manager app to update?

    Regards,
    Amanda H.

  • The nrf52840 is connected to Wiznet W5500 to access the ethernet and download  app_update.bin from the cloud.  

    I can see the problem just by programming with the DK.  It also happens when I go in the other direction (2.6.1 to 2.4.1).

    Mary

  • Is it only with DFU that the key is reset, or will it also reset over a power cycle?

    Since their project is based on the coap_server, are you setting the network key manually in your project? And if so, might you have changed it or set it to something other than the actual network key?

  • The network key is created randomly if, at bootup, there is not already a valid dataset.  The network key is empty in the prj.conf.

    prj.conf

    CONFIG_OPENTHREAD_NETWORKKEY=""

    coap_server_task()

    	ret = ot_coap_init(&on_publish_request, &on_subscribe_request, &on_tcpclient_request, &on_status_request);
    	if (ret) {
    		LOG_ERR("Could not initialize OpenThread CoAP");
    		goto end;
    	}
    
        // Network parameters
    	otOperationalDataset dataset;
    	otInstance *instance;
    	instance = openthread_get_default_instance();
    	if (!otDatasetIsCommissioned(instance))
    	{
    		LOG_INF("Thread not commissioned. Creating dataset.");
    		otDatasetCreateNewNetwork(instance, &dataset);
    
    		// Form network name from MAC address last three bytes (16 char limit)
    		// channel, panid, and networkkey will be random
    		uint32_t maclo = NRF_FICR->DEVICEADDR[0];
    		uint32_t machi = NRF_FICR->DEVICEADDR[1];
    		uint8_t mac[3];
    		mac[0] = machi;			// unique part
    		mac[1] = maclo >> 24;
    		mac[2] = maclo >> 16;
    
    		snprintk(dataset.mNetworkName.m8, sizeof(dataset.mNetworkName.m8), "MyNet_%02X%02X%02X", mac[0], mac[1], mac[2]);
    		dataset.mComponents.mIsNetworkNamePresent = true;
    		otDatasetSetActive(instance, &dataset);
    	}

    1. So, starting with project version 1.x, built with NCS 2.4.1, the server consistently uses the same network key, even after multiple DFUs and reboots/power cycles.

    2. Then  build version 2.x using NCS 2.6.1, and program the board using J-Link.  The network key has changed.  

    3. Using DFU, reload version 1.x.  Now the original network key is back.

    The other Thread parameters never change.

    Somehow there are two different network keys,

    Mary

  • Could you try to set the same key with CONFIG_OPENTHREAD_NETWORKKEY in the prj.conf for NCS 2.4.1 and NCS 2.6.1? Let me know if this can help or not. Here is the example: https://github.com/nrfconnect/sdk-nrf/blob/v2.4.1/samples/openthread/coap_client/prj.conf#L31 

Related