This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC1352P7: Where is the zigbee key stored in the CC1352/2652? And how can I store it in the mcu during the production of the boards?

Part Number: CC1352P7
Other Parts Discussed in Thread: SYSCONFIG, Z-STACK

Hi TI!

Where is the zigbee key stored in the CC1352/2652?

How can I store it in the mcu during the production of the boards?

Can it be configured via UART?

Note: The questions are mainly oriented to the CC1352/CC2652 as the end device.

Thanks!

  • Hi albgarc,

    Are you referring to the Default NWK Key?  This can be defined by the compiler inside of the SysConfig -> Z-Stack -> Network module.  This value is stored into a defaultKey variable defined inside nwk_globals.c, and is further evaluated inside of stackInit -> zgInit -> zgPreconfigKeyInit which occurs during stack initialization  If not set to all 0x00 then it determines the value of zgPreConfigKey, otherwise this value is randomly generated.  It is then stored inside of NV item ZCD_NV_PRECFGKEY before being cleared locally.  You could choose to re-write the value of ZCD_NV_PRECFGKEY using UART during run-time, this is similar to the Monitor and Test UTIL_SET_PRECFGKEY command which translates to MT_UtilSetPreCfgKey of the ZNP project.

    Regards,
    Ryan

  • Hi Ryan!

    Sincerely, thank you very much!

    We need to set de NWK Key in production. 

    If we know the flash address where the NWK key is stored we can write it through the JTAG, right?

    So how can I know the address in the flash where the NWK key is stored?

    In this sense,
    In the firmware we have defined these values:
    #define FLASH_NV_BASE 0xAA000
    #define ZCD_NV_EX_EX_LEGACY 0x0000
    #define ZCD_NV_PRECFGKEY 0x0062

    With these values we can calculate the address of the NWK key?

    Thank you very much.

    Best regards.

  • I do not recommend directly modifying a single NV item as this could conflict with the NVOCMP TI Driver expected operation.  Instead, it would be better to specify the location of a known definition inside of flash memory which you can then program through JTAG as seen fit.  For example, the following CUSTOM_DEFAULT_KEY will be written to flash location 0xAE000, as can be verified through reviewing the .hex output file.

    //nwk_globals.c
    
    // LINES ADDED
    __attribute__((section(".custom")))
    #define CUSTOM_DEFAULT_KEY {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0xC0,0x0D,0x0E,0x0F}
    
    CONFIG_ITEM uint8_t defaultKey[SEC_KEY_LEN] = CUSTOM_DEFAULT_KEY; // LINE MODIFIED
    
    //cc13x2_cc26x2_tirtos7_ticlang.cmd
    
        .emb_text       :   > FLASH
        .custom         :   > FLASH_LAST        /* LINE ADDED */
        .ccfg           :   > FLASH_LAST (HIGH)

    Regards,
    Ryan

  • Hi Ryan!

    Thank yuo very much!

    You mean specify in the code an address in the flash where to save the key?

    If yes, I don't think it will work for me. Note that we must write a custom key to each board in production. So the solution must be independent of the code.

  • The initial post asked for a known location on the MCU to contain the NWK key for board production.  I have fully detailed and provided an explanation to resolve this by giving a pre-determined location to store the NWK key, which is then read and used by the application code.  You now "know the flash address where the NWK key is stored we can write it through the JTAG".  You can modify the memory address inside the output hex/bin file, write it through JTAG, or modify it with the bootloader.  NV memory is also stored in flash memory, and you can perform the necessary debug steps to discover the stored NWK key memory location if this is the preferred method.  You could refer to SWRA671 in this regard.

    Regards,
    Ryan