It seems that there are some errors in the JN-AN-1216 (version:1010)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

It seems that there are some errors in the JN-AN-1216 (version:1010)

1,851 次查看
panjun
Contributor III

The first doubtful error: It appears in the SerialLink.c

PUBLIC void vSL_LogSend(void)
{
int n;
uint8 u8CRC;
uint8 u8Length;

while (u8LogEnd - u8LogStart != 0)
{
/* Send start character */
vSL_TxByte(TRUE, SL_START_CHAR);

/* Send message type */
vSL_TxByte(FALSE, (E_SL_MSG_LOG >> 8) & 0xff);
vSL_TxByte(FALSE, (E_SL_MSG_LOG >> 0) & 0xff);

u8CRC = ((E_SL_MSG_LOG >> 8) & 0xff) ^ ((E_SL_MSG_LOG >> 0) & 0xff);

for (u8Length = 0; au8LogBuffer[(u8LogStart + u8Length) & 0xFF] |= '\0'; u8Length++)
{
u8CRC ^= au8LogBuffer[(u8LogStart + u8Length) & 0xFF];
}
u8CRC ^= 0;
u8CRC ^= u8Length;

/* Send message length */
vSL_TxByte(FALSE, 0);
vSL_TxByte(FALSE, u8Length);

/* Send message checksum */
vSL_TxByte(FALSE, u8CRC);

/* Send message payload */
for(n = 0; n < u8Length; n++)
{
vSL_TxByte(FALSE, au8LogBuffer[u8LogStart]);
u8LogStart++;
}
u8LogStart++;

/* Send end character */
vSL_TxByte(TRUE, SL_END_CHAR);
}
}

The above line of code:for (u8Length = 0; au8LogBuffer[(u8LogStart + u8Length) & 0xFF] |= '\0'; u8Length++)  ,should the part of the red code be changed to != ?

The second doubtful error: It appears in the app_Znc_cmds.c

PUBLIC bool APP_bSendHATransportKey ( uint16 u16ShortAddress,
uint64 u64DeviceAddress,
uint64 u64ParentAddress,
uint8 u8Status,
uint16 u16Mac)
{
bool_t bStatus = TRUE;
ZPS_teStatus eStatus;
uint16 u16Location;
AESSW_Block_u uKey;
bool_t bCredPresent = FALSE;

if( bBlackListEnable )
{
ZPS_teDevicePermissions eDevicePermissions;
eStatus = ZPS_bAplZdoTrustCenterGetDevicePermissions ( u64DeviceAddress,
&eDevicePermissions );
if( eStatus == ZPS_E_SUCCESS )
{
if ( eDevicePermissions != ZPS_DEVICE_PERMISSIONS_ALL_PERMITED )
{
bStatus = FALSE;
}
else
{
bStatus = TRUE;
}
}
else
{
bStatus = FALSE;
}
if ( ( sZllState.u8DeviceType >= 2 ) &&
( eStatus == ZPS_E_SUCCESS ) &&
( eDevicePermissions == ZPS_DEVICE_PERMISSIONS_ALL_PERMITED )
)
{
u64CallbackMacAddress = u64DeviceAddress;
ZTIMER_eStart ( u8HaModeTimer , ZTIMER_TIME_MSEC ( 500 ) );
}
}
else
{
if(sZllState.u8DeviceType >= 2)
{
u64CallbackMacAddress = u64DeviceAddress;
ZTIMER_eStart ( u8HaModeTimer, ZTIMER_TIME_MSEC ( 500 ) );
}
}
bCredPresent = zps_bGetFlashCredential ( u64DeviceAddress, &uKey, &u16Location, FALSE, FALSE );
if ( ( bSetTclkFlashFeature) ||
( u8Status == 1) )
{
extern tsMicroIntStorage sZpsIntStore;
extern PUBLIC void* zps_vGetZpsMutex ( void );
bCredPresent =
ZPS_u8ReleaseMutexLock ( zps_vGetZpsMutex , &sZpsIntStore );
uint8 au8Key[16] = { 0x5a, 0x69, 0x67, 0x42, 0x65, 0x65, 0x41,
0x6c, 0x6c, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x30, 0x39 };

ZPS_eAplZdoAddReplaceLinkKey( u64DeviceAddress, au8Key, ZPS_APS_UNIQUE_LINK_KEY);
if(bCredPresent)
{
asTclkStruct[u16Location].u16TclkRetries = 0xFFFF;
}

ZPS_u8GrabMutexLock ( zps_vGetZpsMutex , &sZpsIntStore );
bStatus = TRUE;
}

return bStatus;
}

Above, The first time to use bCredPresent as the return value for zps_bGetFlashCredential, and then this return value bCredPresent is not used . The seconde time to use  bCredPresent as the return value for ZPS_u8ReleaseMutexLock, The type of variable bCredPresent is bool_t ,but the type of function  ZPS_u8ReleaseMutexLock is uint8. Feel that   bCredPresent as the return value for ZPS_u8ReleaseMutexLock is error.

In addition,i do not understand this line code->bCredPresent = zps_bGetFlashCredential ( u64DeviceAddress, &uKey, &u16Location, FALSE, FALSE ), and do not understand code after it, pls would you explain those to me? 

标签 (1)
10 回复数

1,274 次查看
panjun
Contributor III

Would pls the NXP engineer reply my question as above! 

0 项奖励

1,274 次查看
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Pan Jun,

Yes the code should be 

for (u8Length = 0; au8LogBuffer[(u8LogStart + u8Length) & 0xFF] != '\0'; u8Length++)

And in the next c file app_Znc_cmds.c try like the code below:

    if ( ( bSetTclkFlashFeature && !zps_bGetFlashCredential ( u64DeviceAddress, &uKey, &u16Location, FALSE, FALSE ) ) && bStatus == TRUE)
    {
          extern tsMicroIntStorage sZpsIntStore;
          extern PUBLIC void* zps_vGetZpsMutex ( void );

          ZPS_u8ReleaseMutexLock ( zps_vGetZpsMutex , &sZpsIntStore );

Regards,

Mario

0 项奖励

1,274 次查看
jasonchiang
NXP Employee
NXP Employee

Hi Mario,

     Customer and I attached below image where we compare difference between original one and you suggested.

Could you help to answer below Q1 and Q2 ? Thanks!

JN-AN-1216v1010_difference.png

1,274 次查看
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Jason, 

Yes you are correct, the bCredPresent should not be used as a return type for ZPS_u8ReleaseMutexLock and it is a typo in the code, We have raised an issue against JN-AN-1216 for this and it will be fixed in next release.

The code should look something like below:

bCredPresent = zps_bGetFlashCredential ( u64DeviceAddress, &uKey, &u16Location, FALSE,FALSE );
if ( ( bSetTclkFlashFeature) ||( u8Status == 1) )
{
  extern uint32 sZpsIntStore;
  extern PUBLIC void* zps_vGetZpsMutex ( void );
  ZPS_u8ReleaseMutexLock ( zps_vGetZpsMutex , &sZpsIntStore );
  uint8 au8Key[16] = { 0x5a, 0x69, 0x67, 0x42, 0x65, 0x65, 0x41,
  0x6c, 0x6c, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x30, 0x39 };

  ZPS_eAplZdoAddReplaceLinkKey( u64DeviceAddress, au8Key, ZPS_APS_UNIQUE_LINK_KEY);
  /*If credential is present roll back to confirm that key is used and not install code 
  */
  if(bCredPresent)
  {
    asTclkStruct[u16Location].u16TclkRetries = 0xFFFF;
  }

  ZPS_u8GrabMutexLock ( zps_vGetZpsMutex , &sZpsIntStore );
  bStatus = TRUE;
}

Best Regards,

Mario

1,274 次查看
jasonchiang
NXP Employee
NXP Employee

Hi Mario,

    I compare your new with the V1010 original one. Below is the difference.

 

* Original(v1010)

extern tsMicroInStorage sZpsIntStore;

bCredPresent =

ZPS_u8ReleaseMutexLock ( zps_vGetZpsMutex , &sZpsIntStore );

 

* Modified

extern uint32 sZpsIntStore;

ZPS_u8ReleaseMutexLock ( zps_vGetZpsMutex , &sZpsIntStore );

Could you confirm this again ?

0 项奖励

1,274 次查看
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Jason,

Yes, Please see the code below.

extern uint32 sZpsIntStore;

ZPS_u8ReleaseMutexLock ( zps_vGetZpsMutex , &sZpsIntStore );

Best Regards,

Mario

0 项奖励

1,274 次查看
jasonchiang
NXP Employee
NXP Employee

@Mario Ignacio Castaneda Lopez

Customer has one more question, They don't know how to use following function.

 

PUBLIC bool_t zps_bAreCredPresent ( uint64 u64IeeeAddr ,

uint16 *pu16Location,

uint8 *pu8CredData );

 

Where to find the detail definitions of "2nd" and "3rd" arguments?

For example

* uint16 pu16Location; ?

* uint16 pu16Location[n]; ?

 

When we define as "uint16 pu16Location", stack area is broken!

0 项奖励

1,274 次查看
jasonchiang
NXP Employee
NXP Employee

Please ignore this question. It is typo. Sorry !

1,274 次查看
jasonchiang
NXP Employee
NXP Employee

Thanks!

1,274 次查看
jasonchiang
NXP Employee
NXP Employee

Thanks!

0 项奖励