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.

[FAQ] CC2652R: CC13x2 CC26x2 SDK Zigbee Known Issues and Fixes

Guru 97405 points

Replies: 1

Views: 846

Part Number: CC2652R

simplelink_cc13x2_26x2_sdk_3_30_00_03

1. When more than one group is added (with unique group IDs), they are not restored correctly after a reset.

Apply the following code changes:

uint8 osal_nv_write( uint16 id, uint16 ndx, uint16 len, void *buf )
{
    // Fix added
    #include "aps_groups.h"

    extern uint8_t restoreInProgress_NLME;
    extern apsGroupItem_t *apsGroupTable;
    struct apsGroupNVItem {
        uint8_t                endpoint;
        aps_Group_t          group;
    };

    apsGroupItem_t *pLoop = apsGroupTable;
    struct apsGroupNVItem item;

    if (id == ZCD_NV_GROUP_TABLE)
    {
        if (restoreInProgress_NLME)
            return; // don't write to NV group table while a restore is in progress

        // write correctly to NV group table
        uint16_t i = 0;
        while ( pLoop )
        {
          // Build the record
          item.endpoint = pLoop->endpoint;
          OsalPort_memcpy( &(item.group), &(pLoop->group), sizeof ( aps_Group_t ) );

          OsalPort_memcpy(buf + (uint16_t)((sizeof(uint16_t)) + (i * sizeof ( struct apsGroupNVItem ))),  &item, sizeof ( struct apsGroupNVItem ));

          pLoop = pLoop->next;
          i += 1;
        }
    }
    // End of fix

  // Legacy items use ZCD_NV_EX_LEGACY as the ID and the id as the sub-id.
  return ( osal_nv_write_ex( ZCD_NV_EX_LEGACY, id, ndx, len, buf ) );
}
uint8_t restoreInProgress_NLME = FALSE; // Fix added
uint8_t ZDApp_RestoreNetworkState( void )
{
  uint8_t nvStat;

  // Initialize NWK NV items
  nvStat = NLME_InitNV();

  if ( nvStat == SUCCESS )
  {
      restoreInProgress_NLME = TRUE; // Fix added

    if ( NLME_RestoreFromNV() )
    {
      // Are we a coordinator
      ZDAppNwkAddr.addr.shortAddr = NLME_GetShortAddr();
      if ( ZDAppNwkAddr.addr.shortAddr == 0 )
      {
        ZDO_Config_Node_Descriptor.LogicalType = NODETYPE_COORDINATOR;
      }
      if(ZG_DEVICE_ENDDEVICE_TYPE)
      {
        devStartMode = MODE_REJOIN;
        _NIB.nwkState = NWK_INIT;
      }
      else
      {
        devStartMode = MODE_RESUME;
      }
      osal_cpyExtAddr( ZDO_UseExtendedPANID, _NIB.extendedPANID );
    }
    else
      nvStat = NV_ITEM_UNINIT;

    restoreInProgress_NLME = FALSE; // Fix added


    nwkFrameCounterChanges = 0;

    if ( ZG_BUILD_COORDINATOR_TYPE && ZG_DEVICE_COORDINATOR_TYPE )
    {
      ZDApp_RestoreNwkKey( TRUE );
    }

    // The default for RxOnWhenIdle is true for Routers and false for end devices
    // [setup in the NLME_RestoreFromNV()].  Change it here if you want something
    // other than default.
  }

  if ( nvStat == ZSUCCESS )
    return ( ZDO_INITDEV_RESTORED_NETWORK_STATE );
  else
    return ( ZDO_INITDEV_NEW_NETWORK_STATE );
}
#endif // NV_RESTORE

2. Project initialization asserts if HEAPMGR_ASSERT is defined.

Make the following code changes:

void HEAPMGR_INIT(void)
{   initInProgress = 1;
// ...

   initInProgress = 0;
}
void *HEAPMGR_MALLOC(hmU32_t size)
{// ...
    if (!initInProgress)
        HEAPMGR_ASSERT(size);
// ...
}

3. *zclParseInConfigReportCmd assumes the reportable attribute field will always be at least one, causing parse issues when multiple attributes are reported

Remove the else {pBuf++;} statement from *zclParseInConfigReportCmd

4. ZCD_NV_EX_DEVICE_LIST is not updated for all necessary instances

Force an association device update through the ZDApp_SaveNetworkStateEvt:

  for( n = 0; n < gNWK_MAX_DEVICE_LIST; n++ )
  {
    uint16_t shortAddr;
    osal_nv_read_ex( ZCD_NV_EX_DEVICE_LIST, n, 0, sizeof(shortAddr), &shortAddr );
    if( (AssociatedDevList[n].shortAddr == 0xFFFF) && ( shortAddr != 0xFFFF ) )
    {
      //not delete NVID, fixed by luoyiming 2019-10-16
      uint8_t tmpBuf[16];
      memset( tmpBuf, 0xFF, sizeof(tmpBuf) );
      osal_nv_write_ex( ZCD_NV_EX_DEVICE_LIST, n, sizeof(tmpBuf), tmpBuf );
    }
  }

5. Duplicate TCLK entries after a device performs a second network join

Make the following corrections to zd_sec_mgr.c:

ZStatus_t ZDSecMgrDeviceJoinDirect( ZDSecMgrDevice_t* device )
{
// ...

       //... and found and it was verified, then allow it to join in a fresh state by erasing the key entry
        if((found == TRUE) && (TCLKDevEntry.keyAttributes == ZG_VERIFIED_KEY))
        {
          uint16_t index;
          TCLKDevEntry.keyAttributes = ZG_DEFAULT_KEY;
          //Increase the shift by one. Validate the maximum shift of the seed which is 15
          TCLKDevEntry.SeedShift_IcIndex++;
          TCLKDevEntry.SeedShift_IcIndex &= 0x0F;

          TCLKDevEntry.rxFrmCntr = 0;
          TCLKDevEntry.txFrmCntr = 0;

          index = keyNvIndex;

          TCLinkKeyRAMEntry[index].rxFrmCntr = 0;
          TCLinkKeyRAMEntry[index].txFrmCntr = 0;
          //TCLinkKeyRAMEntry[index].entryUsed = FALSE; // fix: remove this line

          //Update the entry
          osal_nv_write_ex(ZCD_NV_EX_TCLK_TABLE, keyNvIndex,
                           sizeof(APSME_TCLinkKeyNVEntry_t),
                           &TCLKDevEntry);
        }

// ...
}
void ZDSecMgrUpdateDeviceInd( ZDO_UpdateDeviceInd_t* ind )
{
// ...

      //If found and it was verified, then allow it to join in a fresh state by erasing the key entry
      if((found == TRUE) && (TCLKDevEntry.keyAttributes == ZG_VERIFIED_KEY))
      {
        TCLKDevEntry.keyAttributes = ZG_DEFAULT_KEY;
        //Increase the shift by one. Validate the maximum shift of the seed which is 15
        TCLKDevEntry.SeedShift_IcIndex++;
        TCLKDevEntry.SeedShift_IcIndex &= 0x0F;

        TCLKDevEntry.rxFrmCntr = 0;
        TCLKDevEntry.txFrmCntr = 0;

        index = keyNvIndex;
        TCLinkKeyRAMEntry[index].rxFrmCntr = 0;
        TCLinkKeyRAMEntry[index].txFrmCntr = 0;
        // TCLinkKeyRAMEntry[index].entryUsed = FALSE; // fix: remove this line

        //Update the entry
        osal_nv_write_ex(ZCD_NV_EX_TCLK_TABLE, keyNvIndex,
                         sizeof(APSME_TCLinkKeyNVEntry_t),
                         &TCLKDevEntry);
      }

// ...
}


6. *zclParseInDiscCmdsRspCmd causes stack failure

Add pDiscoverRspCmd->pCmdID = (uint8_t*)( pDiscoverRspCmd + 1 ); after pDiscoverRspCmd->numCmd = numCmds;

7. Incorrect parsing of ZDO_EXT_SEC_APS_REMOVE_REQ MT command

Correct the order of parsing in function MT_ZdoExtSecApsRemoveReq:

if ( ZG_SECURE_ENABLED && ZG_BUILD_COORDINATOR_TYPE && ZG_DEVICE_COORDINATOR_TYPE )
{
  nwkAddr = osal_build_uint16( pBuf );
  pBuf += 10;

 
  parentAddr = osal_build_uint16( pBuf );
  pBuf -= 8;

 
  status = ZDSecMgrAPSRemove( nwkAddr, pBuf, parentAddr );
}

Regards,
Ryan

To better aid the community, please click on the "This Resolved my issue" button whenever a post answers your question!

1 Reply

  • Good to know, thanks!

    Regards,
    Toby

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.