Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Silabs] RTT I/O stream support added. #29452

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions examples/platform/silabs/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,25 +291,29 @@ standard names. */
#define SysTick_Handler xPortSysTickHandler

/* Thread local storage pointers used by the SDK */
#ifdef PERFORMANCE_TEST_ENABLED
// ot_debug_channel component uses thread-local storage
#define configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS 2

#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)
#define configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS 2
#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 2
#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. */
#define fabs __builtin_fabs
#endif

#ifndef configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS
#error RC-FRTOS
#endif

#ifdef __cplusplus
}
#endif
3 changes: 3 additions & 0 deletions examples/platform/silabs/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ chip_project_config_include = "<CHIPProjectConfig.h>"
chip_inet_project_config_include = "<CHIPProjectConfig.h>"
chip_system_project_config_include = "<CHIPProjectConfig.h>"

segger_rtt_buffer_size_up = 1024
segger_rtt_buffer_size_down = 1024

declare_args() {
app_data_model = ""
}
1 change: 1 addition & 0 deletions examples/platform/silabs/matter-platform.slcp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions src/platform/silabs/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@
#endif

#include "AppConfig.h"
#include <FreeRTOS.h>
#include <queue.h>
#include <stdio.h>
#include <string.h>
#include <task.h>

#ifndef BRD4325A
#include "rail_types.h"

#ifdef RAIL_ASSERT_DEBUG_STRING
#include "rail_assert_error_codes.h"
Expand Down
49 changes: 42 additions & 7 deletions src/platform/silabs/SilabsConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@
* Utilities for accessing persisted device configuration on
* platforms based on the Silicon Labs SDK.
*/
/* this file behaves like a config.h, comes first */
#include <platform/internal/CHIPDeviceLayerInternal.h>

#include <platform/silabs/SilabsConfig.h>

#include <lib/core/CHIPEncoding.h>
#include <lib/support/CodeUtils.h>
#include <platform/internal/testing/ConfigUnitTest.h>
#include <platform/silabs/CHIPDevicePlatformConfig.h>

#include "FreeRTOS.h"
#include "nvm3.h"
#include "nvm3_default.h"
#include "nvm3_hal_flash.h"
#include <nvm3.h>
#include <nvm3_default.h>
#include <nvm3_hal_flash.h>
#include <nvm3_lock.h>

#ifndef BRD4325A // TODO: fix semaphore usage in nvm3_lock for siwx917. use weak implementation for that board instead
#include <FreeRTOS.h>
#include <semphr.h>
// Substitute the GSDK weak nvm3_lockBegin and nvm3_lockEnd
// for an application controlled re-entrance protection
static SemaphoreHandle_t nvm3_Sem;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/platform/silabs/SilabsConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#pragma once

#include <functional>
#include <platform/CHIPDeviceError.h>

#include "nvm3.h"
#include "nvm3_hal_flash.h"
Expand Down Expand Up @@ -176,13 +177,15 @@ 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);
static CHIP_ERROR ReadConfigValueBin(Key key, uint8_t * buf, size_t bufSize, size_t & outLen);
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);
Expand Down
11 changes: 10 additions & 1 deletion src/test_driver/efr32/include/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,17 @@ standard names. */
#define SysTick_Handler xPortSysTickHandler

/* Thread local storage pointers used by the SDK */
#ifndef configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS
#define configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS 2
#endif

#ifndef configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS
#define configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS 0
#define configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS 2
#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

#if defined(__GNUC__)
Expand Down
5 changes: 5 additions & 0 deletions third_party/silabs/efr32_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 += [
Expand Down
2 changes: 1 addition & 1 deletion third_party/silabs/matter_support
Submodule matter_support updated 56 files
+9 −0 matter/efr32/efr32mg12/BRD4161A/autogen/sl_event_handler.c
+27 −0 matter/efr32/efr32mg12/BRD4161A/autogen/sl_iostream_handles.c
+20 −0 matter/efr32/efr32mg12/BRD4161A/autogen/sl_iostream_handles.h
+16 −0 matter/efr32/efr32mg12/BRD4161A/autogen/sl_iostream_init_instances.h
+8 −0 matter/efr32/efr32mg12/BRD4162A/autogen/sl_event_handler.c
+27 −0 matter/efr32/efr32mg12/BRD4162A/autogen/sl_iostream_handles.c
+20 −0 matter/efr32/efr32mg12/BRD4162A/autogen/sl_iostream_handles.h
+16 −0 matter/efr32/efr32mg12/BRD4162A/autogen/sl_iostream_init_instances.h
+8 −0 matter/efr32/efr32mg12/BRD4163A/autogen/sl_event_handler.c
+27 −0 matter/efr32/efr32mg12/BRD4163A/autogen/sl_iostream_handles.c
+20 −0 matter/efr32/efr32mg12/BRD4163A/autogen/sl_iostream_handles.h
+16 −0 matter/efr32/efr32mg12/BRD4163A/autogen/sl_iostream_init_instances.h
+8 −0 matter/efr32/efr32mg12/BRD4164A/autogen/sl_event_handler.c
+27 −0 matter/efr32/efr32mg12/BRD4164A/autogen/sl_iostream_handles.c
+20 −0 matter/efr32/efr32mg12/BRD4164A/autogen/sl_iostream_handles.h
+16 −0 matter/efr32/efr32mg12/BRD4164A/autogen/sl_iostream_init_instances.h
+9 −0 matter/efr32/efr32mg12/BRD4166A/autogen/sl_event_handler.c
+27 −0 matter/efr32/efr32mg12/BRD4166A/autogen/sl_iostream_handles.c
+20 −0 matter/efr32/efr32mg12/BRD4166A/autogen/sl_iostream_handles.h
+16 −0 matter/efr32/efr32mg12/BRD4166A/autogen/sl_iostream_init_instances.h
+8 −0 matter/efr32/efr32mg12/BRD4170A/autogen/sl_event_handler.c
+27 −0 matter/efr32/efr32mg12/BRD4170A/autogen/sl_iostream_handles.c
+20 −0 matter/efr32/efr32mg12/BRD4170A/autogen/sl_iostream_handles.h
+16 −0 matter/efr32/efr32mg12/BRD4170A/autogen/sl_iostream_init_instances.h
+8 −0 matter/efr32/efr32mg24/BRD2601B/autogen/sl_event_handler.c
+27 −0 matter/efr32/efr32mg24/BRD2601B/autogen/sl_iostream_handles.c
+20 −0 matter/efr32/efr32mg24/BRD2601B/autogen/sl_iostream_handles.h
+16 −0 matter/efr32/efr32mg24/BRD2601B/autogen/sl_iostream_init_instances.h
+8 −0 matter/efr32/efr32mg24/BRD4187C/autogen/sl_event_handler.c
+27 −0 matter/efr32/efr32mg24/BRD4187C/autogen/sl_iostream_handles.c
+20 −0 matter/efr32/efr32mg24/BRD4187C/autogen/sl_iostream_handles.h
+16 −0 matter/efr32/efr32mg24/BRD4187C/autogen/sl_iostream_init_instances.h
+8 −0 matter/efr32/mgm24/BRD2704A/autogen/sl_event_handler.c
+27 −0 matter/efr32/mgm24/BRD2704A/autogen/sl_iostream_handles.c
+20 −0 matter/efr32/mgm24/BRD2704A/autogen/sl_iostream_handles.h
+16 −0 matter/efr32/mgm24/BRD2704A/autogen/sl_iostream_init_instances.h
+8 −0 matter/efr32/mgm24/BRD4316A/autogen/sl_event_handler.c
+27 −0 matter/efr32/mgm24/BRD4316A/autogen/sl_iostream_handles.c
+20 −0 matter/efr32/mgm24/BRD4316A/autogen/sl_iostream_handles.h
+16 −0 matter/efr32/mgm24/BRD4316A/autogen/sl_iostream_init_instances.h
+9 −0 matter/efr32/mgm24/BRD4317A/autogen/sl_event_handler.c
+27 −0 matter/efr32/mgm24/BRD4317A/autogen/sl_iostream_handles.c
+20 −0 matter/efr32/mgm24/BRD4317A/autogen/sl_iostream_handles.h
+16 −0 matter/efr32/mgm24/BRD4317A/autogen/sl_iostream_init_instances.h
+9 −0 matter/efr32/mgm24/BRD4318A/autogen/sl_event_handler.c
+27 −0 matter/efr32/mgm24/BRD4318A/autogen/sl_iostream_handles.c
+20 −0 matter/efr32/mgm24/BRD4318A/autogen/sl_iostream_handles.h
+16 −0 matter/efr32/mgm24/BRD4318A/autogen/sl_iostream_init_instances.h
+8 −0 matter/efr32/mgm24/BRD4319A/autogen/sl_event_handler.c
+27 −0 matter/efr32/mgm24/BRD4319A/autogen/sl_iostream_handles.c
+20 −0 matter/efr32/mgm24/BRD4319A/autogen/sl_iostream_handles.h
+16 −0 matter/efr32/mgm24/BRD4319A/autogen/sl_iostream_init_instances.h
+8 −1 matter/si91x/siwx917/BRD4325x/autogen/sl_event_handler.c
+27 −0 matter/si91x/siwx917/BRD4325x/autogen/sl_iostream_handles.c
+19 −0 matter/si91x/siwx917/BRD4325x/autogen/sl_iostream_handles.h
+16 −0 matter/si91x/siwx917/BRD4325x/autogen/sl_iostream_init_instances.h
3 changes: 3 additions & 0 deletions third_party/silabs/silabs_board.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down