From a40104a046cdbf5d28677efcd1a61219d46c2a6e Mon Sep 17 00:00:00 2001 From: Seth Rickard Date: Wed, 23 Mar 2022 21:40:40 -0500 Subject: [PATCH] [TI] Test Event #8 feedback (#16495) * Platform updates found from TE#8 OpenThread config added DNS client support to fully enable SRP. Configuration limiting OpenThread message buffers removed for higher memory devices. It was found that the OpenThread stack would not de-fragment the long packets needed for OTA. This ended up silently failing before the packets reached the LwIP stack. GN build updated to include missing dependencies. KVS updated to return proper CHIP_ERROR value instead of a platform error. AES hardware acceleration disabled due to a runtime error. This is likely a missing `mbedtls_aes_free()` call. Further debug is required before re-enabling. * Centralize TI OpenThread config * Restyled by whitespace * Restyled by clang-format * Restyled by gn * add CHIP DNS configuration * Update length calculation for NVS * Restyled by clang-format Co-authored-by: Restyled.io --- .../main/include/OpenThreadConfig.h | 33 +------------------ .../main/include/OpenThreadConfig.h | 33 +------------------ .../cc13x2x7_26x2x7/main/AppTask.cpp | 11 +++++-- .../main/include/OpenThreadConfig.h | 33 +------------------ src/platform/cc13x2_26x2/BUILD.gn | 2 ++ .../cc13x2_26x2/CC13X2_26X2Config.cpp | 22 ++++++++----- .../cc13x2_26x2/CHIPDevicePlatformConfig.h | 1 + .../cc13x2_26x2/ConfigurationManagerImpl.cpp | 1 + .../cc13x2_26x2/KeyValueStoreManagerImpl.cpp | 10 +++++- .../crypto/cc13x2_26x2-mbedtls-config.h | 2 +- .../openthread-core-cc13x2_26x2-config.h | 32 ++++++++++++++++++ 11 files changed, 71 insertions(+), 109 deletions(-) diff --git a/examples/lock-app/cc13x2x7_26x2x7/main/include/OpenThreadConfig.h b/examples/lock-app/cc13x2x7_26x2x7/main/include/OpenThreadConfig.h index 4079b251280ddc..30f5633cc3bc7f 100644 --- a/examples/lock-app/cc13x2x7_26x2x7/main/include/OpenThreadConfig.h +++ b/examples/lock-app/cc13x2x7_26x2x7/main/include/OpenThreadConfig.h @@ -23,38 +23,7 @@ * */ -#ifndef OPENTHREAD_PLATFORM_CONFIG_H -#define OPENTHREAD_PLATFORM_CONFIG_H - -// Disable the Nordic-supplied OpenThread logging facilities and use -// the facilities provided by the CHIP Device Layer -#define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_APP - -// When operating in a less than ideal RF environment, having a more forgiving configuration -// of OpenThread makes thread a great deal more reliable. -#define OPENTHREAD_CONFIG_TMF_ADDRESS_QUERY_MAX_RETRY_DELAY 120 // default is 28800 -#define OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_DIRECT 15 // default is 3 -#define OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_INDIRECT 1 // default is 0 -#define OPENTHREAD_CONFIG_MAC_MAX_TX_ATTEMPTS_INDIRECT_POLLS 16 // default is 4 - -// Enable periodic parent search to speed up finding a better parent. -#define OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE 1 // default is 0 -#define OPENTHREAD_CONFIG_PARENT_SEARCH_RSS_THRESHOLD -45 // default is -65 -#define OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH 1 // default is 0 - -// Use smaller maximum interval to speed up reattaching. -#define OPENTHREAD_CONFIG_MLE_ATTACH_BACKOFF_MAXIMUM_INTERVAL (60 * 10 * 1000) // default 1200000 ms - -#define OPENTHREAD_CONFIG_JOINER_ENABLE 1 -#define OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE 0 -#define UART_AS_SERIAL_TRANSPORT 1 -#define OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE 1 - -#define OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE 1 -#define OPENTHREAD_CONFIG_ECDSA_ENABLE 1 -#define OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE 1 +#pragma once // Use the TI-supplied default platform configuration for remainder #include "openthread-core-cc13x2_26x2-config.h" - -#endif // OPENTHREAD_PLATFORM_CONFIG_H diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/include/OpenThreadConfig.h b/examples/pump-app/cc13x2x7_26x2x7/main/include/OpenThreadConfig.h index 4079b251280ddc..30f5633cc3bc7f 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/include/OpenThreadConfig.h +++ b/examples/pump-app/cc13x2x7_26x2x7/main/include/OpenThreadConfig.h @@ -23,38 +23,7 @@ * */ -#ifndef OPENTHREAD_PLATFORM_CONFIG_H -#define OPENTHREAD_PLATFORM_CONFIG_H - -// Disable the Nordic-supplied OpenThread logging facilities and use -// the facilities provided by the CHIP Device Layer -#define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_APP - -// When operating in a less than ideal RF environment, having a more forgiving configuration -// of OpenThread makes thread a great deal more reliable. -#define OPENTHREAD_CONFIG_TMF_ADDRESS_QUERY_MAX_RETRY_DELAY 120 // default is 28800 -#define OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_DIRECT 15 // default is 3 -#define OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_INDIRECT 1 // default is 0 -#define OPENTHREAD_CONFIG_MAC_MAX_TX_ATTEMPTS_INDIRECT_POLLS 16 // default is 4 - -// Enable periodic parent search to speed up finding a better parent. -#define OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE 1 // default is 0 -#define OPENTHREAD_CONFIG_PARENT_SEARCH_RSS_THRESHOLD -45 // default is -65 -#define OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH 1 // default is 0 - -// Use smaller maximum interval to speed up reattaching. -#define OPENTHREAD_CONFIG_MLE_ATTACH_BACKOFF_MAXIMUM_INTERVAL (60 * 10 * 1000) // default 1200000 ms - -#define OPENTHREAD_CONFIG_JOINER_ENABLE 1 -#define OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE 0 -#define UART_AS_SERIAL_TRANSPORT 1 -#define OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE 1 - -#define OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE 1 -#define OPENTHREAD_CONFIG_ECDSA_ENABLE 1 -#define OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE 1 +#pragma once // Use the TI-supplied default platform configuration for remainder #include "openthread-core-cc13x2_26x2-config.h" - -#endif // OPENTHREAD_PLATFORM_CONFIG_H diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp index 8ccd13b292aeb4..f96411cfa8d0de 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -31,8 +31,9 @@ #if defined(CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR) #include +#include +#include #include -#include #include #endif #include @@ -68,6 +69,7 @@ AppTask AppTask::sAppTask; #if defined(CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR) static OTARequestor sRequestorCore; +static DefaultOTARequestorStorage sRequestorStorage; static GenericOTARequestorDriver sRequestorUser; static BDXDownloader sDownloader; static OTAImageProcessorImpl sImageProcessor; @@ -77,7 +79,8 @@ void InitializeOTARequestor(void) // Initialize and interconnect the Requestor and Image Processor objects SetRequestorInstance(&sRequestorCore); - sRequestorCore.Init(&Server::GetInstance(), &sRequestorUser, &sDownloader); + sRequestorStorage.Init(chip::Server::GetInstance().GetPersistentStorage()); + sRequestorCore.Init(chip::Server::GetInstance(), sRequestorStorage, sRequestorUser, sDownloader); sImageProcessor.SetOTADownloader(&sDownloader); sDownloader.SetImageProcessorDelegate(&sImageProcessor); sRequestorUser.Init(&sRequestorCore, &sImageProcessor); @@ -200,6 +203,10 @@ int AppTask::Init() ConfigurationMgr().LogDeviceConfig(); +#if defined(CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR) + InitializeOTARequestor(); +#endif + // QR code will be used with CHIP Tool PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/OpenThreadConfig.h b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/OpenThreadConfig.h index 4079b251280ddc..30f5633cc3bc7f 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/OpenThreadConfig.h +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/OpenThreadConfig.h @@ -23,38 +23,7 @@ * */ -#ifndef OPENTHREAD_PLATFORM_CONFIG_H -#define OPENTHREAD_PLATFORM_CONFIG_H - -// Disable the Nordic-supplied OpenThread logging facilities and use -// the facilities provided by the CHIP Device Layer -#define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_APP - -// When operating in a less than ideal RF environment, having a more forgiving configuration -// of OpenThread makes thread a great deal more reliable. -#define OPENTHREAD_CONFIG_TMF_ADDRESS_QUERY_MAX_RETRY_DELAY 120 // default is 28800 -#define OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_DIRECT 15 // default is 3 -#define OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_INDIRECT 1 // default is 0 -#define OPENTHREAD_CONFIG_MAC_MAX_TX_ATTEMPTS_INDIRECT_POLLS 16 // default is 4 - -// Enable periodic parent search to speed up finding a better parent. -#define OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE 1 // default is 0 -#define OPENTHREAD_CONFIG_PARENT_SEARCH_RSS_THRESHOLD -45 // default is -65 -#define OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH 1 // default is 0 - -// Use smaller maximum interval to speed up reattaching. -#define OPENTHREAD_CONFIG_MLE_ATTACH_BACKOFF_MAXIMUM_INTERVAL (60 * 10 * 1000) // default 1200000 ms - -#define OPENTHREAD_CONFIG_JOINER_ENABLE 1 -#define OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE 0 -#define UART_AS_SERIAL_TRANSPORT 1 -#define OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE 1 - -#define OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE 1 -#define OPENTHREAD_CONFIG_ECDSA_ENABLE 1 -#define OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE 1 +#pragma once // Use the TI-supplied default platform configuration for remainder #include "openthread-core-cc13x2_26x2-config.h" - -#endif // OPENTHREAD_PLATFORM_CONFIG_H diff --git a/src/platform/cc13x2_26x2/BUILD.gn b/src/platform/cc13x2_26x2/BUILD.gn index d110cb240eb81b..22292330ce3108 100644 --- a/src/platform/cc13x2_26x2/BUILD.gn +++ b/src/platform/cc13x2_26x2/BUILD.gn @@ -55,6 +55,8 @@ static_library("cc13x2_26x2") { "${chip_root}/src/crypto", "${chip_root}/src/platform:platform_base", ] + public_configs = + [ "${chip_root}/src/lib/address_resolve:default_address_resolve_config" ] if (chip_enable_ble) { sources += [ diff --git a/src/platform/cc13x2_26x2/CC13X2_26X2Config.cpp b/src/platform/cc13x2_26x2/CC13X2_26X2Config.cpp index f8a4493fb9461b..3795cf9aa77430 100644 --- a/src/platform/cc13x2_26x2/CC13X2_26X2Config.cpp +++ b/src/platform/cc13x2_26x2/CC13X2_26X2Config.cpp @@ -212,6 +212,7 @@ CHIP_ERROR CC13X2_26X2Config::ReadKVS(const char * key, void * value, size_t val NVINTF_itemID_t val_item = CC13X2_26X2Config::kConfigKey_KVS_value.nvID; uint16_t subID; size_t len; + uint16_t read_len; VerifyOrExit(FindKVSSubID(key, subID) == NVINTF_SUCCESS, err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); @@ -220,19 +221,22 @@ CHIP_ERROR CC13X2_26X2Config::ReadKVS(const char * key, void * value, size_t val len = sNvoctpFps.getItemLen(val_item); VerifyOrExit(len > 0, err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // key not found - VerifyOrExit(sNvoctpFps.readItem(val_item, (uint16_t) offset_bytes, (uint16_t) value_size, value) == NVINTF_SUCCESS, + if ((offset_bytes + value_size) > len) + { + // trying to read up to the end of the element + read_len = len - offset_bytes; + } + else + { + read_len = value_size; + } + + VerifyOrExit(sNvoctpFps.readItem(val_item, (uint16_t) offset_bytes, read_len, value) == NVINTF_SUCCESS, err = CHIP_ERROR_PERSISTED_STORAGE_FAILED); if (read_bytes_size) { - if (len - offset_bytes > value_size) - { - *read_bytes_size = value_size; - } - else - { - *read_bytes_size = len - offset_bytes; - } + *read_bytes_size = read_len; } exit: diff --git a/src/platform/cc13x2_26x2/CHIPDevicePlatformConfig.h b/src/platform/cc13x2_26x2/CHIPDevicePlatformConfig.h index 5927b58b3c2c60..cd5e9c927dd6a6 100644 --- a/src/platform/cc13x2_26x2/CHIPDevicePlatformConfig.h +++ b/src/platform/cc13x2_26x2/CHIPDevicePlatformConfig.h @@ -54,4 +54,5 @@ #define CHIP_DEVICE_CONFIG_ENABLE_PAIRING_AUTOSTART 0 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT 1 +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT 1 #define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1 diff --git a/src/platform/cc13x2_26x2/ConfigurationManagerImpl.cpp b/src/platform/cc13x2_26x2/ConfigurationManagerImpl.cpp index 1db7197b6fdac1..108a6ef03805a4 100644 --- a/src/platform/cc13x2_26x2/ConfigurationManagerImpl.cpp +++ b/src/platform/cc13x2_26x2/ConfigurationManagerImpl.cpp @@ -77,6 +77,7 @@ CHIP_ERROR ConfigurationManagerImpl::Init() } err = CHIP_NO_ERROR; +exit: return err; } diff --git a/src/platform/cc13x2_26x2/KeyValueStoreManagerImpl.cpp b/src/platform/cc13x2_26x2/KeyValueStoreManagerImpl.cpp index 118945be4337d2..b74146c1de3704 100644 --- a/src/platform/cc13x2_26x2/KeyValueStoreManagerImpl.cpp +++ b/src/platform/cc13x2_26x2/KeyValueStoreManagerImpl.cpp @@ -41,10 +41,18 @@ KeyValueStoreManagerImpl KeyValueStoreManagerImpl::sInstance; CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t value_size, size_t * read_bytes_size, size_t offset_bytes) const { + CHIP_ERROR err; + VerifyOrReturnError(key, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnError(value, CHIP_ERROR_INVALID_ARGUMENT); - return CC13X2_26X2Config::ReadKVS(key, value, value_size, read_bytes_size, offset_bytes); + err = CC13X2_26X2Config::ReadKVS(key, value, value_size, read_bytes_size, offset_bytes); + + if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + { + err = CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + return err; } CHIP_ERROR KeyValueStoreManagerImpl::_Put(const char * key, const void * value, size_t value_size) diff --git a/src/platform/cc13x2_26x2/crypto/cc13x2_26x2-mbedtls-config.h b/src/platform/cc13x2_26x2/crypto/cc13x2_26x2-mbedtls-config.h index 04e91bae54616b..44286fdb35e106 100644 --- a/src/platform/cc13x2_26x2/crypto/cc13x2_26x2-mbedtls-config.h +++ b/src/platform/cc13x2_26x2/crypto/cc13x2_26x2-mbedtls-config.h @@ -39,7 +39,7 @@ /* Enable Hardware Acceleration */ -#define MBEDTLS_AES_ALT +//#define MBEDTLS_AES_ALT #define MBEDTLS_ECDH_COMPUTE_SHARED_ALT #define MBEDTLS_ECDH_GEN_PUBLIC_ALT #define MBEDTLS_ECDSA_SIGN_ALT diff --git a/src/platform/cc13x2_26x2/openthread-core-cc13x2_26x2-config.h b/src/platform/cc13x2_26x2/openthread-core-cc13x2_26x2-config.h index b206345f339db2..0873f031b4355f 100644 --- a/src/platform/cc13x2_26x2/openthread-core-cc13x2_26x2-config.h +++ b/src/platform/cc13x2_26x2/openthread-core-cc13x2_26x2-config.h @@ -28,5 +28,37 @@ #pragma once +#ifdef DeviceFamily_CC13X2_CC26X2 + /* Number of message buffers reduced to fit into CC26x2x3 RAM */ #define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS 22 + +#endif // DeviceFamily_CC13X2_CC26X2 + +#define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_APP + +// When operating in a less than ideal RF environment, having a more forgiving configuration +// of OpenThread makes thread a great deal more reliable. +#define OPENTHREAD_CONFIG_TMF_ADDRESS_QUERY_MAX_RETRY_DELAY 120 // default is 28800 +#define OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_DIRECT 15 // default is 3 +#define OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_INDIRECT 1 // default is 0 +#define OPENTHREAD_CONFIG_MAC_MAX_TX_ATTEMPTS_INDIRECT_POLLS 16 // default is 4 + +// Enable periodic parent search to speed up finding a better parent. +#define OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE 1 // default is 0 +#define OPENTHREAD_CONFIG_PARENT_SEARCH_RSS_THRESHOLD -45 // default is -65 +#define OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH 1 // default is 0 + +// Use smaller maximum interval to speed up reattaching. +#define OPENTHREAD_CONFIG_MLE_ATTACH_BACKOFF_MAXIMUM_INTERVAL (60 * 10 * 1000) // default 1200000 ms + +#define OPENTHREAD_CONFIG_JOINER_ENABLE 1 +#define OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE 0 +#define UART_AS_SERIAL_TRANSPORT 1 +#define OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE 1 + +#define OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE 1 +#define OPENTHREAD_CONFIG_ECDSA_ENABLE 1 +#define OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE 1 +#define OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE 1 +#define OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE 1