From 0cee4576d981d5ad487c0ad70b58e7ebbcf2a5f0 Mon Sep 17 00:00:00 2001 From: Ricardo Casallas <77841255+rcasallas-silabs@users.noreply.github.com> Date: Tue, 26 Sep 2023 08:50:41 -0400 Subject: [PATCH] Silabs: RTT I/O stream support added. --- examples/platform/silabs/FreeRTOSConfig.h | 13 ++++--- examples/platform/silabs/args.gni | 3 ++ examples/platform/silabs/matter-platform.slcp | 1 + src/platform/silabs/SilabsConfig.cpp | 35 +++++++++++++++++++ src/platform/silabs/SilabsConfig.h | 3 ++ third_party/silabs/efr32_sdk.gni | 5 +++ third_party/silabs/matter_support | 2 +- third_party/silabs/silabs_board.gni | 3 ++ 8 files changed, 59 insertions(+), 6 deletions(-) diff --git a/examples/platform/silabs/FreeRTOSConfig.h b/examples/platform/silabs/FreeRTOSConfig.h index bce38a6a579039..e8d8f43e61e155 100644 --- a/examples/platform/silabs/FreeRTOSConfig.h +++ b/examples/platform/silabs/FreeRTOSConfig.h @@ -294,16 +294,19 @@ standard names. */ #ifdef PERFORMANCE_TEST_ENABLED // ot_debug_channel component uses thread-local storage #define configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS 2 +#endif /* PERFORMANCE_TEST_ENABLED */ + #ifndef configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS #define configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS 0 -#define configNUM_THREAD_LOCAL_STORAGE_POINTERS \ - (configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS + configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS) #endif -#else /* PERFORMANCE_TEST_ENABLED */ + #ifndef configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS -#define configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS 0 +#define configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS 1 +#endif + +#ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS +#define configNUM_THREAD_LOCAL_STORAGE_POINTERS (configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS + configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS + 1) #endif -#endif /* PERFORMANCE_TEST_ENABLED */ #if defined(__GNUC__) /* For the linker. */ diff --git a/examples/platform/silabs/args.gni b/examples/platform/silabs/args.gni index ff5317006bd805..41ad41f51c05e9 100644 --- a/examples/platform/silabs/args.gni +++ b/examples/platform/silabs/args.gni @@ -20,6 +20,9 @@ chip_project_config_include = "" chip_inet_project_config_include = "" chip_system_project_config_include = "" +segger_rtt_buffer_size_up = 1024 +segger_rtt_buffer_size_down = 1024 + declare_args() { app_data_model = "" } diff --git a/examples/platform/silabs/matter-platform.slcp b/examples/platform/silabs/matter-platform.slcp index 33ed32c11d909f..3616d074a6df88 100644 --- a/examples/platform/silabs/matter-platform.slcp +++ b/examples/platform/silabs/matter-platform.slcp @@ -63,6 +63,7 @@ component: - {id: mbedtls_base64} - {id: ot_psa_crypto} - {id: bluetooth_crypto} +- {id: iostream_rtt} # Necessary componenets for ot coap cert lib # - {id: mbedtls_dtls} # Requried by COAP lib # - {id: mbedtls_tls_server} # Requried by COAP lib diff --git a/src/platform/silabs/SilabsConfig.cpp b/src/platform/silabs/SilabsConfig.cpp index 950b6040490c0a..ed452f5504d6c4 100644 --- a/src/platform/silabs/SilabsConfig.cpp +++ b/src/platform/silabs/SilabsConfig.cpp @@ -106,6 +106,28 @@ CHIP_ERROR SilabsConfig::ReadConfigValue(Key key, bool & val) return err; } +CHIP_ERROR SilabsConfig::ReadConfigValue(Key key, uint16_t & val) +{ + CHIP_ERROR err; + uint32_t objectType; + size_t dataLen; + uint16_t tmpVal = 0; + + VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. + + // Get nvm3 object info. + err = MapNvm3Error(nvm3_getObjectInfo(nvm3_defaultHandle, key, &objectType, &dataLen)); + SuccessOrExit(err); + + // Read nvm3 bytes into tmp. + err = MapNvm3Error(nvm3_readData(nvm3_defaultHandle, key, &tmpVal, dataLen)); + SuccessOrExit(err); + val = tmpVal; + +exit: + return err; +} + CHIP_ERROR SilabsConfig::ReadConfigValue(Key key, uint32_t & val) { CHIP_ERROR err; @@ -296,6 +318,19 @@ CHIP_ERROR SilabsConfig::WriteConfigValue(Key key, bool val) return err; } +CHIP_ERROR SilabsConfig::WriteConfigValue(Key key, uint16_t val) +{ + CHIP_ERROR err; + + VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. + + err = MapNvm3Error(nvm3_writeData(nvm3_defaultHandle, key, &val, sizeof(val))); + SuccessOrExit(err); + +exit: + return err; +} + CHIP_ERROR SilabsConfig::WriteConfigValue(Key key, uint32_t val) { CHIP_ERROR err; diff --git a/src/platform/silabs/SilabsConfig.h b/src/platform/silabs/SilabsConfig.h index d5742c7c077d9d..9156fa461da284 100644 --- a/src/platform/silabs/SilabsConfig.h +++ b/src/platform/silabs/SilabsConfig.h @@ -24,6 +24,7 @@ #pragma once +#include #include #include "nvm3.h" @@ -176,6 +177,7 @@ class SilabsConfig // Configuration methods used by the GenericConfigurationManagerImpl<> template. static CHIP_ERROR ReadConfigValue(Key key, bool & val); + static CHIP_ERROR ReadConfigValue(Key key, uint16_t & val); static CHIP_ERROR ReadConfigValue(Key key, uint32_t & val); static CHIP_ERROR ReadConfigValue(Key key, uint64_t & val); static CHIP_ERROR ReadConfigValueStr(Key key, char * buf, size_t bufSize, size_t & outLen); @@ -183,6 +185,7 @@ class SilabsConfig static CHIP_ERROR ReadConfigValueBin(Key key, uint8_t * buf, size_t bufSize, size_t & outLen, size_t offset); static CHIP_ERROR ReadConfigValueCounter(uint8_t counterIdx, uint32_t & val); static CHIP_ERROR WriteConfigValue(Key key, bool val); + static CHIP_ERROR WriteConfigValue(Key key, uint16_t val); static CHIP_ERROR WriteConfigValue(Key key, uint32_t val); static CHIP_ERROR WriteConfigValue(Key key, uint64_t val); static CHIP_ERROR WriteConfigValueStr(Key key, const char * str); diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 0c743ddcd83b39..e04aa9d7070e75 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -157,6 +157,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/service/device_init/inc", "${efr32_sdk_root}/platform/service/hfxo_manager/inc", "${efr32_sdk_root}/platform/service/hfxo_manager/src", + "${efr32_sdk_root}/platform/service/iostream/inc", "${efr32_sdk_root}/platform/service/mpu/inc", "${efr32_sdk_root}/platform/service/power_manager/inc/", "${efr32_sdk_root}/platform/service/power_manager/src/", @@ -584,6 +585,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/bootloader/api/btl_interface_storage.c", "${efr32_sdk_root}/platform/bootloader/security/sha/crypto_sha.c", "${efr32_sdk_root}/platform/common/src/sl_slist.c", + "${efr32_sdk_root}/platform/common/src/sli_cmsis_os2_ext_task_register.c", "${efr32_sdk_root}/platform/emdrv/dmadrv/src/dmadrv.c", "${efr32_sdk_root}/platform/emdrv/gpiointerrupt/src/gpiointerrupt.c", "${efr32_sdk_root}/platform/emdrv/nvm3/src/nvm3_default.c", @@ -626,6 +628,8 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_lfrco.c", "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_nvic.c", "${efr32_sdk_root}/platform/service/hfxo_manager/src/sl_hfxo_manager.c", + "${efr32_sdk_root}/platform/service/iostream/src/sl_iostream.c", + "${efr32_sdk_root}/platform/service/iostream/src/sl_iostream_rtt.c", "${efr32_sdk_root}/platform/service/mpu/src/sl_mpu.c", "${efr32_sdk_root}/platform/service/power_manager/src/sl_power_manager.c", "${efr32_sdk_root}/platform/service/power_manager/src/sl_power_manager_debug.c", @@ -711,6 +715,7 @@ template("efr32_sdk") { "${silabs_gen_folder}/autogen/sl_board_default_init.c", "${silabs_gen_folder}/autogen/sl_device_init_clocks.c", "${silabs_gen_folder}/autogen/sl_event_handler.c", + "${silabs_gen_folder}/autogen/sl_iostream_handles.c", ] if (enable_dic) { sources += [ diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index d336c71c24b154..220e87668200a1 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit d336c71c24b1541c9099a258216dfd4585ace9fe +Subproject commit 220e87668200a1ac3c4bc3604a9408c2b12d440e diff --git a/third_party/silabs/silabs_board.gni b/third_party/silabs/silabs_board.gni index c69a09820d9c7f..6910e410a4e2f0 100644 --- a/third_party/silabs/silabs_board.gni +++ b/third_party/silabs/silabs_board.gni @@ -48,6 +48,9 @@ declare_args() { # Disable UART log forwarding by default sl_uart_log_output = false + + # Self-provision enabled + use_provision_channel = false } declare_args() {