From 06247dd52a718e7aa7d7edba4383c5e2bd25ced4 Mon Sep 17 00:00:00 2001 From: adabreuti <76965454+adabreuti@users.noreply.github.com> Date: Wed, 30 Aug 2023 12:52:15 -0500 Subject: [PATCH] [TI] Optimize Thread Matter Builds for CC13x2x7/x4 (#28955) * Split Thread Message queues, increment OT-TI version * Increment CC13xx SDK version * Re-enable CC13x4 Crypto Accel * Fix Licence header * Move SDK Dependency for 32xx * Restyled by clang-format * Restyled by gn --------- Co-authored-by: Restyled.io --- .../cc13xx_26xx/ThreadStackManagerImpl.cpp | 39 +++++++++++++++---- .../cc13x2_26x2/ThreadStackManagerImpl.h | 2 + .../cc13x4_26x4/ThreadStackManagerImpl.h | 2 + .../crypto/cc13x4_26x4-mbedtls-config.h | 8 ++-- third_party/openthread/ot-ti | 2 +- third_party/ti_simplelink_sdk/BUILD.gn | 9 +++++ .../ti_simplelink_sdk/repo_cc13xx_cc26xx | 2 +- .../ti_simplelink_sdk/ti_simplelink_sdk.gni | 2 + 8 files changed, 53 insertions(+), 13 deletions(-) diff --git a/src/platform/cc13xx_26xx/ThreadStackManagerImpl.cpp b/src/platform/cc13xx_26xx/ThreadStackManagerImpl.cpp index caffe8443b6bbd..a338e915181ea8 100644 --- a/src/platform/cc13xx_26xx/ThreadStackManagerImpl.cpp +++ b/src/platform/cc13xx_26xx/ThreadStackManagerImpl.cpp @@ -81,7 +81,8 @@ CHIP_ERROR ThreadStackManagerImpl::InitThreadStack(otInstance * otInst) CHIP_ERROR err = CHIP_NO_ERROR; // Create FreeRTOS queue for platform driver messages - procQueue = xQueueCreate(16U, sizeof(ThreadStackManagerImpl::procQueueMsg)); + procQueue = xQueueCreate(20U, sizeof(ThreadStackManagerImpl::procQueueMsg)); + procQueue_radio = xQueueCreate(20U, sizeof(ThreadStackManagerImpl::procQueueMsg)); #if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE != 0 mbedtls_platform_set_calloc_free(ot_calloc, ot_free); @@ -116,7 +117,19 @@ bool ThreadStackManagerImpl::IsInitialized() void ThreadStackManagerImpl::_SendProcMessage(ThreadStackManagerImpl::procQueueMsg & procMsg) { - xQueueSendFromISR(procQueue, &procMsg, NULL); + + BaseType_t err; + + if (procMsg.cmd == procQueueCmd_radio) + { + err = xQueueSendFromISR(procQueue_radio, &procMsg, NULL); + } + else + { + err = xQueueSendFromISR(procQueue, &procMsg, NULL); + } + + (void) err; // signal processing loop SignalThreadActivityPendingFromISR(); @@ -138,6 +151,23 @@ extern "C" void otPlatFree(void * aPtr) void ThreadStackManagerImpl::_ProcMessage(otInstance * aInstance) { procQueueMsg procMsg; + procQueueMsg procMsg_radio; + + /* Process Radio events */ + while (pdTRUE == xQueueReceive(procQueue_radio, &procMsg_radio, 0U)) + { + switch (procMsg_radio.cmd) + { + case procQueueCmd_radio: { + platformRadioProcess(aInstance, procMsg_radio.arg); + break; + } + default: { + break; + } + } + } + while (pdTRUE == xQueueReceive(procQueue, &procMsg, 0U)) { switch (procMsg.cmd) @@ -147,11 +177,6 @@ void ThreadStackManagerImpl::_ProcMessage(otInstance * aInstance) break; } - case procQueueCmd_radio: { - platformRadioProcess(aInstance, procMsg.arg); - break; - } - case procQueueCmd_tasklets: { otTaskletsProcess(aInstance); break; diff --git a/src/platform/cc13xx_26xx/cc13x2_26x2/ThreadStackManagerImpl.h b/src/platform/cc13xx_26xx/cc13x2_26x2/ThreadStackManagerImpl.h index c7377336a2f38f..ff5b5cc34a89e4 100644 --- a/src/platform/cc13xx_26xx/cc13x2_26x2/ThreadStackManagerImpl.h +++ b/src/platform/cc13xx_26xx/cc13x2_26x2/ThreadStackManagerImpl.h @@ -95,6 +95,7 @@ class ThreadStackManagerImpl final : public ThreadStackManager, void _SendProcMessage(procQueueMsg & procMsg); void _ProcMessage(otInstance * aInstance); void GetExtAddress(otExtAddress & aExtAddr); + CHIP_ERROR GetBufferInfo(void); private: // ===== Methods that implement the ThreadStackManager abstract interface. @@ -114,6 +115,7 @@ class ThreadStackManagerImpl final : public ThreadStackManager, ThreadStackManagerImpl() = default; QueueHandle_t procQueue; + QueueHandle_t procQueue_radio; }; /** diff --git a/src/platform/cc13xx_26xx/cc13x4_26x4/ThreadStackManagerImpl.h b/src/platform/cc13xx_26xx/cc13x4_26x4/ThreadStackManagerImpl.h index afabf6069cc38f..dc4127d7033af1 100644 --- a/src/platform/cc13xx_26xx/cc13x4_26x4/ThreadStackManagerImpl.h +++ b/src/platform/cc13xx_26xx/cc13x4_26x4/ThreadStackManagerImpl.h @@ -94,6 +94,7 @@ class ThreadStackManagerImpl final : public ThreadStackManager, void _SendProcMessage(procQueueMsg & procMsg); void _ProcMessage(otInstance * aInstance); void GetExtAddress(otExtAddress & aExtAddr); + CHIP_ERROR GetBufferInfo(void); private: // ===== Methods that implement the ThreadStackManager abstract interface. @@ -113,6 +114,7 @@ class ThreadStackManagerImpl final : public ThreadStackManager, ThreadStackManagerImpl() = default; QueueHandle_t procQueue; + QueueHandle_t procQueue_radio; }; /** diff --git a/src/platform/cc13xx_26xx/cc13x4_26x4/crypto/cc13x4_26x4-mbedtls-config.h b/src/platform/cc13xx_26xx/cc13x4_26x4/crypto/cc13x4_26x4-mbedtls-config.h index f1bb207c945dc0..16b1dafdcc95d4 100644 --- a/src/platform/cc13xx_26xx/cc13x4_26x4/crypto/cc13x4_26x4-mbedtls-config.h +++ b/src/platform/cc13xx_26xx/cc13x4_26x4/crypto/cc13x4_26x4-mbedtls-config.h @@ -41,10 +41,10 @@ //#define MBEDTLS_AES_ALT //#define MBEDTLS_ECDH_COMPUTE_SHARED_ALT //#define MBEDTLS_ECDH_GEN_PUBLIC_ALT -//#define MBEDTLS_ECDSA_SIGN_ALT -//#define MBEDTLS_ECDSA_VERIFY_ALT -//#define MBEDTLS_ENTROPY_HARDWARE_ALT -//#define MBEDTLS_SHA256_ALT +#define MBEDTLS_ECDSA_SIGN_ALT +#define MBEDTLS_ECDSA_VERIFY_ALT +#define MBEDTLS_ENTROPY_HARDWARE_ALT +#define MBEDTLS_SHA256_ALT // Thread Joining disabled //#define MBEDTLS_ECJPAKE_ALT diff --git a/third_party/openthread/ot-ti b/third_party/openthread/ot-ti index a9dd46d64f7279..e61f379de62125 160000 --- a/third_party/openthread/ot-ti +++ b/third_party/openthread/ot-ti @@ -1 +1 @@ -Subproject commit a9dd46d64f7279974d3fd7b077e22aaf663d1460 +Subproject commit e61f379de62125e407568056cde58c876f22ce27 diff --git a/third_party/ti_simplelink_sdk/BUILD.gn b/third_party/ti_simplelink_sdk/BUILD.gn index 363d94685955fe..79f2e205b069ac 100644 --- a/third_party/ti_simplelink_sdk/BUILD.gn +++ b/third_party/ti_simplelink_sdk/BUILD.gn @@ -76,6 +76,15 @@ mbedtls_target("mbedtls") { "${chip_root}/src/platform/cc13xx_26xx/cc13x2_26x2/crypto/sha256_alt.c", ] } + if (ti_simplelink_device_family == "cc13x4_26x4") { + sources = [ + "${chip_root}/src/platform/cc13xx_26xx/cc13x4_26x4/crypto/aes_alt.c", + "${chip_root}/src/platform/cc13xx_26xx/cc13x4_26x4/crypto/ecdh_alt.c", + "${chip_root}/src/platform/cc13xx_26xx/cc13x4_26x4/crypto/ecdsa_alt.c", + "${chip_root}/src/platform/cc13xx_26xx/cc13x4_26x4/crypto/ecjpake_alt.c", + "${chip_root}/src/platform/cc13xx_26xx/cc13x4_26x4/crypto/sha256_alt.c", + ] + } public_configs = [ ":ti_simplelink_mbedtls_config" ] diff --git a/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx b/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx index 5d4cc6d8331df7..7692751f2c96c8 160000 --- a/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx +++ b/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx @@ -1 +1 @@ -Subproject commit 5d4cc6d8331df7b4a0880b52db53e54887f0b4f3 +Subproject commit 7692751f2c96c82d8207faa989f10a26b0cf2dd8 diff --git a/third_party/ti_simplelink_sdk/ti_simplelink_sdk.gni b/third_party/ti_simplelink_sdk/ti_simplelink_sdk.gni index 06c925ff8b0774..590d4884b867f5 100644 --- a/third_party/ti_simplelink_sdk/ti_simplelink_sdk.gni +++ b/third_party/ti_simplelink_sdk/ti_simplelink_sdk.gni @@ -247,6 +247,7 @@ template("ti_simplelink_sdk") { "${ti_simplelink_sdk_root}/kernel/freertos/dpl/PowerCC26X2_freertos.c", "${ti_simplelink_sdk_root}/kernel/freertos/dpl/TimerPCC26XX_freertos.c", "${ti_simplelink_sdk_root}/kernel/freertos/startup/startup_cc13x2_cc26x2_gcc.c", + "${ti_simplelink_sdk_root}/source/ti/drivers/sha2/SHA2CC26X2.c", ] } else if (ti_simplelink_device_family == "cc13x4_26x4") { sources += [ @@ -255,6 +256,7 @@ template("ti_simplelink_sdk") { "${ti_simplelink_sdk_root}/kernel/freertos/dpl/PowerCC26X2_freertos.c", "${ti_simplelink_sdk_root}/kernel/freertos/dpl/TimerPCC26XX_freertos.c", "${ti_simplelink_sdk_root}/kernel/freertos/startup/startup_cc13x4_cc26x4_gcc.c", + "${ti_simplelink_sdk_root}/source/ti/drivers/sha2/SHA2CC26X2.c", ] } else if (ti_simplelink_device_family == "cc32xx") { sources += [