From 7fae90cd7a77d711fa3f8341035e66142a931426 Mon Sep 17 00:00:00 2001 From: Andrii Bilynskyi Date: Mon, 2 Oct 2023 17:39:57 +0300 Subject: [PATCH 1/3] [Telink] Use common Zephyr heap --- config/telink/chip-module/Kconfig.defaults | 9 --------- .../telink/project_include/OpenThreadConfig.h | 3 --- src/platform/Zephyr/PlatformManagerImpl.cpp | 12 ++++++------ src/platform/telink/telink-mbedtls-config.h | 8 ++++++++ 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 9933e961ffbfb5..1d31f548ac2943 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -247,15 +247,6 @@ config MBEDTLS_USER_CONFIG_ENABLE config MBEDTLS_USER_CONFIG_FILE default "telink-mbedtls-config.h" -config MBEDTLS_ENABLE_HEAP - default y - -# TBD: Something wrong with this heap. Need to be investigated. Cirrently just set minimal size -config MBEDTLS_HEAP_SIZE - default 0 - -config OPENTHREAD_EXTERNAL_HEAP - default y # getopt version config GETOPT_LONG diff --git a/examples/platform/telink/project_include/OpenThreadConfig.h b/examples/platform/telink/project_include/OpenThreadConfig.h index 381b5e09bb07fc..eabe238820ae7f 100644 --- a/examples/platform/telink/project_include/OpenThreadConfig.h +++ b/examples/platform/telink/project_include/OpenThreadConfig.h @@ -35,9 +35,6 @@ #define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_DEBUG_UART -#undef OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT -#define OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT 1 - #undef OPENTHREAD_CONFIG_LOG_LEVEL #if (CONFIG_LOG_MODE_MINIMAL) #define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_NONE diff --git a/src/platform/Zephyr/PlatformManagerImpl.cpp b/src/platform/Zephyr/PlatformManagerImpl.cpp index 0e5aac4bda8dda..c900d072778c61 100644 --- a/src/platform/Zephyr/PlatformManagerImpl.cpp +++ b/src/platform/Zephyr/PlatformManagerImpl.cpp @@ -45,7 +45,7 @@ PlatformManagerImpl PlatformManagerImpl::sInstance{ sChipThreadStack }; static k_timer sOperationalHoursSavingTimer; -#if !CONFIG_NORDIC_SECURITY_BACKEND +#if !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) static int app_entropy_source(void * data, unsigned char * output, size_t len, size_t * olen) { const struct device * entropy = DEVICE_DT_GET(DT_CHOSEN(zephyr_entropy)); @@ -71,7 +71,7 @@ static int app_entropy_source(void * data, unsigned char * output, size_t len, s return ret; } -#endif // !CONFIG_NORDIC_SECURITY_BACKEND +#endif // !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) void PlatformManagerImpl::OperationalHoursSavingTimerEventHandler(k_timer * timer) { @@ -108,20 +108,20 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) { CHIP_ERROR err; -#if !CONFIG_NORDIC_SECURITY_BACKEND +#if !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) // Minimum required from source before entropy is released ( with mbedtls_entropy_func() ) (in bytes) const size_t kThreshold = 16; -#endif // !CONFIG_NORDIC_SECURITY_BACKEND +#endif // !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) // Initialize the configuration system. err = Internal::ZephyrConfig::Init(); SuccessOrExit(err); -#if !CONFIG_NORDIC_SECURITY_BACKEND +#if !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) // Add entropy source based on Zephyr entropy driver err = chip::Crypto::add_entropy_source(app_entropy_source, NULL, kThreshold); SuccessOrExit(err); -#endif // !CONFIG_NORDIC_SECURITY_BACKEND +#endif // !CONFIG_NORDIC_SECURITY_BACKEND && !defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) // Call _InitChipStack() on the generic implementation base class to finish the initialization process. err = Internal::GenericPlatformManagerImpl_Zephyr::_InitChipStack(); diff --git a/src/platform/telink/telink-mbedtls-config.h b/src/platform/telink/telink-mbedtls-config.h index ccd3de88f1f77e..23d7d97bc43c9a 100644 --- a/src/platform/telink/telink-mbedtls-config.h +++ b/src/platform/telink/telink-mbedtls-config.h @@ -24,6 +24,14 @@ #ifndef MBEDTLS_TSLR9_CONF_H #define MBEDTLS_TSLR9_CONF_H +#ifdef MBEDTLS_PLATFORM_MEMORY +#undef MBEDTLS_PLATFORM_MEMORY +#endif + +#ifdef MBEDTLS_MEMORY_BUFFER_ALLOC_C +#undef MBEDTLS_MEMORY_BUFFER_ALLOC_C +#endif + #define MBEDTLS_HKDF_C #define MBEDTLS_PKCS5_C #define MBEDTLS_X509_CREATE_C From 2fdb91413e760fa3c31216b4c11a5a61a853298a Mon Sep 17 00:00:00 2001 From: Misha Tkachenko Date: Mon, 2 Oct 2023 17:39:57 +0300 Subject: [PATCH 2/3] [Telink] Added default RF TX power selection --- config/telink/chip-module/Kconfig.defaults | 8 ++++++++ examples/all-clusters-app/telink/prj.conf | 4 ---- examples/all-clusters-minimal-app/telink/prj.conf | 4 ---- examples/bridge-app/telink/prj.conf | 4 ---- examples/chef/telink/prj.conf | 4 ---- examples/lighting-app/telink/prj.conf | 4 ---- examples/ota-requestor-app/telink/prj.conf | 4 ---- examples/shell/telink/prj.conf | 4 ---- 8 files changed, 8 insertions(+), 28 deletions(-) diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 1d31f548ac2943..d70fff0d50f3fa 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -143,6 +143,10 @@ config B9X_BLE_CTRL_MASTER_MAX_NUM config B9X_BLE_CTRL_SLAVE_MAX_NUM default 1 +config B9X_BLE_CTRL_RF_POWER + default 3 if PM + default 9 + choice B9X_BLE_CTRL_MAC_TYPE default B9X_BLE_CTRL_MAC_TYPE_RANDOM_STATIC endchoice @@ -220,6 +224,10 @@ config OPENTHREAD_SLAAC config OPENTHREAD_MANUAL_START default y +config OPENTHREAD_DEFAULT_TX_POWER + default 3 if PM + default 9 + config NET_TX_STACK_SIZE default 554 if PM diff --git a/examples/all-clusters-app/telink/prj.conf b/examples/all-clusters-app/telink/prj.conf index 8551f44e560424..f0e82ad971d4d8 100644 --- a/examples/all-clusters-app/telink/prj.conf +++ b/examples/all-clusters-app/telink/prj.conf @@ -55,7 +55,3 @@ CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n # Enable Power Management CONFIG_PM=n - -# Custom RF power values -CONFIG_B9X_BLE_CTRL_RF_POWER_P9P11DBM=y -CONFIG_OPENTHREAD_DEFAULT_TX_POWER=9 diff --git a/examples/all-clusters-minimal-app/telink/prj.conf b/examples/all-clusters-minimal-app/telink/prj.conf index 0e540f339d8d1f..8b63c719c3875c 100644 --- a/examples/all-clusters-minimal-app/telink/prj.conf +++ b/examples/all-clusters-minimal-app/telink/prj.conf @@ -53,7 +53,3 @@ CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE=n # Enable Power Management CONFIG_PM=n - -# Custom RF power values -CONFIG_B9X_BLE_CTRL_RF_POWER_P9P11DBM=y -CONFIG_OPENTHREAD_DEFAULT_TX_POWER=9 diff --git a/examples/bridge-app/telink/prj.conf b/examples/bridge-app/telink/prj.conf index fa580fce1076c5..c6365484b80b22 100644 --- a/examples/bridge-app/telink/prj.conf +++ b/examples/bridge-app/telink/prj.conf @@ -56,7 +56,3 @@ CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE=n # Enable Power Management CONFIG_PM=n - -# Custom RF power values -CONFIG_B9X_BLE_CTRL_RF_POWER_P9P11DBM=y -CONFIG_OPENTHREAD_DEFAULT_TX_POWER=9 diff --git a/examples/chef/telink/prj.conf b/examples/chef/telink/prj.conf index 9a15c1d2ac621e..b5986b7d07a5bc 100755 --- a/examples/chef/telink/prj.conf +++ b/examples/chef/telink/prj.conf @@ -55,7 +55,3 @@ CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE=n # Enable Power Management CONFIG_PM=n - -# Custom RF power values -CONFIG_B9X_BLE_CTRL_RF_POWER_P9P11DBM=y -CONFIG_OPENTHREAD_DEFAULT_TX_POWER=9 diff --git a/examples/lighting-app/telink/prj.conf b/examples/lighting-app/telink/prj.conf index c5371f92565214..0c71925928bec0 100644 --- a/examples/lighting-app/telink/prj.conf +++ b/examples/lighting-app/telink/prj.conf @@ -56,7 +56,3 @@ CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE=n # Enable Power Management CONFIG_PM=n - -# Custom RF power values -CONFIG_B9X_BLE_CTRL_RF_POWER_P9P11DBM=y -CONFIG_OPENTHREAD_DEFAULT_TX_POWER=9 \ No newline at end of file diff --git a/examples/ota-requestor-app/telink/prj.conf b/examples/ota-requestor-app/telink/prj.conf index e854a2167fc02a..82f29519af3bcb 100755 --- a/examples/ota-requestor-app/telink/prj.conf +++ b/examples/ota-requestor-app/telink/prj.conf @@ -56,7 +56,3 @@ CONFIG_CHIP_LIB_SHELL=n # Enable Power Management CONFIG_PM=n - -# Custom RF power values -CONFIG_B9X_BLE_CTRL_RF_POWER_P9P11DBM=y -CONFIG_OPENTHREAD_DEFAULT_TX_POWER=9 diff --git a/examples/shell/telink/prj.conf b/examples/shell/telink/prj.conf index 53bdac24f943de..88846b63b4aa15 100755 --- a/examples/shell/telink/prj.conf +++ b/examples/shell/telink/prj.conf @@ -55,7 +55,3 @@ CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE=n # Enable Power Management CONFIG_PM=n - -# Custom RF power values -CONFIG_B9X_BLE_CTRL_RF_POWER_P9P11DBM=y -CONFIG_OPENTHREAD_DEFAULT_TX_POWER=9 From 7654ab6407640002b70f497412773cad970e7139 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Mon, 2 Oct 2023 17:39:57 +0300 Subject: [PATCH 3/3] [Telink] Update Telink image to 16 --- .github/workflows/chef.yaml | 2 +- .github/workflows/examples-telink.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index be4f1ce9d98052..330118bd958cfc 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -96,7 +96,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: ghcr.io/project-chip/chip-build-telink:12 + image: ghcr.io/project-chip/chip-build-telink:16 options: --user root steps: diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 993f63d1e4bb5d..7951fe5ac46d1e 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -36,7 +36,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: ghcr.io/project-chip/chip-build-telink:12 + image: ghcr.io/project-chip/chip-build-telink:16 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports"