Skip to content

Commit

Permalink
Silabs: RTT I/O stream support added.
Browse files Browse the repository at this point in the history
  • Loading branch information
rcasallas-silabs committed Sep 26, 2023
1 parent 6bb0b71 commit 66cd992
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 2 deletions.
13 changes: 12 additions & 1 deletion examples/platform/silabs/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,20 @@ standard names. */
(configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS + configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS)
#endif
#else /* PERFORMANCE_TEST_ENABLED */

#ifndef configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS
#define configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS 1
#endif

/* Thread local storage pointers used by the SDK */
#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__)
Expand Down
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
35 changes: 35 additions & 0 deletions src/platform/silabs/SilabsConfig.cpp
Original file line number Diff line number Diff line change
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 @@ -24,6 +24,7 @@

#pragma once

#include <lib/core/CHIPError.h>
#include <functional>

#include "nvm3.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
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

0 comments on commit 66cd992

Please sign in to comment.