From 69d80ace5f33b1aa41d7d9599d9ea2b308aeb654 Mon Sep 17 00:00:00 2001 From: Mason Tran Date: Wed, 22 Nov 2023 12:23:30 -0500 Subject: [PATCH] [radio] fix low power multi-vendor certification failures OpenThread stack update change 992be2781->a363396eb (in commit 2c459e3a3) had a change in the stack to clarify and adjust various CSL timing units to existing 802.15.4 standards based timing concepts. See https://github.com/openthread/openthread/commit/6da6e09392349f8c165c482662e3070f5afd0e6d One of the changes was to clarify that the rxTimestamp (used to calculate "next" CSL transmissions) should point to the end of the sync header (SHR). So when scheduling our transmit, we must make sure to subtract the SHR duration value from our base time since this is already accounted for when calculating next CSL transmission delay. Co-authored-by: Suvesh Pratapa --- src/src/radio.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/src/radio.c b/src/src/radio.c index 86c95c04..fa394768 100644 --- a/src/src/radio.c +++ b/src/src/radio.c @@ -407,6 +407,8 @@ static const RAIL_IEEE802154_Config_t sRailIeee802154Config = { #define SHR_SIZE 5 // 4 bytes of preamble, 1 byte sync-word #endif +#define SHR_DURATION_US 160 // Duration of SHR in us. + // Misc static volatile uint32_t miscRadioState = 0; static bool emPendingData = false; @@ -1634,7 +1636,8 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame) sTxFrame->mInfo.mTxInfo.mTxDelay = 3000; // Chosen after internal certification testing } #endif - updateIeInfoTxFrame(sTxFrame->mInfo.mTxInfo.mTxDelayBaseTime + sTxFrame->mInfo.mTxInfo.mTxDelay + 160); + updateIeInfoTxFrame(sTxFrame->mInfo.mTxInfo.mTxDelayBaseTime + sTxFrame->mInfo.mTxInfo.mTxDelay + + SHR_DURATION_US); // Note - we need to call this outside of txCurrentPacket as for Series 2, // this results in calling the SE interface from a critical section which is not permitted. @@ -1824,7 +1827,7 @@ void txCurrentPacket(void) // #if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2 RAIL_ScheduleTxConfig_t scheduleTxOptions = {.when = sTxFrame->mInfo.mTxInfo.mTxDelayBaseTime - + sTxFrame->mInfo.mTxInfo.mTxDelay, + + sTxFrame->mInfo.mTxInfo.mTxDelay - SHR_DURATION_US, .mode = RAIL_TIME_ABSOLUTE, .txDuringRx = RAIL_SCHEDULED_TX_DURING_RX_POSTPONE_TX}; @@ -3032,8 +3035,9 @@ static bool validatePacketTimestamp(RAIL_RxPacketDetails_t *pPacketDetails, uint // Get the timestamp when the SFD was received otEXPECT_ACTION(pPacketDetails->timeReceived.timePosition != RAIL_PACKET_TIME_INVALID, rxTimestampValid = false); - // + 1 for the 1-byte PHY header - pPacketDetails->timeReceived.totalPacketBytes = packetLength + 1; + // + PHY HEADER SIZE for PHY header + // We would not need this if PHR is not included and we want the MHR + pPacketDetails->timeReceived.totalPacketBytes = packetLength + PHY_HEADER_SIZE; otEXPECT_ACTION((RAIL_GetRxTimeSyncWordEndAlt(gRailHandle, pPacketDetails) == RAIL_STATUS_NO_ERROR), rxTimestampValid = false);