Skip to content

Commit 7c216f8

Browse files
Silabs: RTT I/O stream support added. (project-chip#29452)
1 parent 199b155 commit 7c216f8

File tree

10 files changed

+81
-22
lines changed

10 files changed

+81
-22
lines changed

examples/platform/silabs/FreeRTOSConfig.h

+13-9
Original file line numberDiff line numberDiff line change
@@ -291,25 +291,29 @@ standard names. */
291291
#define SysTick_Handler xPortSysTickHandler
292292

293293
/* Thread local storage pointers used by the SDK */
294-
#ifdef PERFORMANCE_TEST_ENABLED
295-
// ot_debug_channel component uses thread-local storage
296-
#define configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS 2
294+
297295
#ifndef configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS
298-
#define configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS 0
299-
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS \
300-
(configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS + configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS)
296+
#define configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS 2
301297
#endif
302-
#else /* PERFORMANCE_TEST_ENABLED */
298+
303299
#ifndef configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS
304-
#define configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS 0
300+
#define configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS 2
301+
#endif
302+
303+
#ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS
304+
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS \
305+
(configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS + configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS + 1)
305306
#endif
306-
#endif /* PERFORMANCE_TEST_ENABLED */
307307

308308
#if defined(__GNUC__)
309309
/* For the linker. */
310310
#define fabs __builtin_fabs
311311
#endif
312312

313+
#ifndef configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS
314+
#error RC-FRTOS
315+
#endif
316+
313317
#ifdef __cplusplus
314318
}
315319
#endif

examples/platform/silabs/args.gni

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ chip_project_config_include = "<CHIPProjectConfig.h>"
2020
chip_inet_project_config_include = "<CHIPProjectConfig.h>"
2121
chip_system_project_config_include = "<CHIPProjectConfig.h>"
2222

23+
segger_rtt_buffer_size_up = 1024
24+
segger_rtt_buffer_size_down = 1024
25+
2326
declare_args() {
2427
app_data_model = ""
2528
}

examples/platform/silabs/matter-platform.slcp

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ component:
6363
- {id: mbedtls_base64}
6464
- {id: ot_psa_crypto}
6565
- {id: bluetooth_crypto}
66+
- {id: iostream_rtt}
6667
# Necessary componenets for ot coap cert lib
6768
# - {id: mbedtls_dtls} # Requried by COAP lib
6869
# - {id: mbedtls_tls_server} # Requried by COAP lib

src/platform/silabs/Logging.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@
1313
#endif
1414

1515
#include "AppConfig.h"
16-
#include <FreeRTOS.h>
17-
#include <queue.h>
1816
#include <stdio.h>
1917
#include <string.h>
20-
#include <task.h>
2118

2219
#ifndef BRD4325A
23-
#include "rail_types.h"
2420

2521
#ifdef RAIL_ASSERT_DEBUG_STRING
2622
#include "rail_assert_error_codes.h"

src/platform/silabs/SilabsConfig.cpp

+42-7
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@
2121
* Utilities for accessing persisted device configuration on
2222
* platforms based on the Silicon Labs SDK.
2323
*/
24-
/* this file behaves like a config.h, comes first */
25-
#include <platform/internal/CHIPDeviceLayerInternal.h>
26-
2724
#include <platform/silabs/SilabsConfig.h>
2825

2926
#include <lib/core/CHIPEncoding.h>
27+
#include <lib/support/CodeUtils.h>
3028
#include <platform/internal/testing/ConfigUnitTest.h>
29+
#include <platform/silabs/CHIPDevicePlatformConfig.h>
3130

32-
#include "FreeRTOS.h"
33-
#include "nvm3.h"
34-
#include "nvm3_default.h"
35-
#include "nvm3_hal_flash.h"
31+
#include <nvm3.h>
32+
#include <nvm3_default.h>
33+
#include <nvm3_hal_flash.h>
3634
#include <nvm3_lock.h>
3735

3836
#ifndef BRD4325A // TODO: fix semaphore usage in nvm3_lock for siwx917. use weak implementation for that board instead
37+
#include <FreeRTOS.h>
38+
#include <semphr.h>
3939
// Substitute the GSDK weak nvm3_lockBegin and nvm3_lockEnd
4040
// for an application controlled re-entrance protection
4141
static SemaphoreHandle_t nvm3_Sem;
@@ -106,6 +106,28 @@ CHIP_ERROR SilabsConfig::ReadConfigValue(Key key, bool & val)
106106
return err;
107107
}
108108

109+
CHIP_ERROR SilabsConfig::ReadConfigValue(Key key, uint16_t & val)
110+
{
111+
CHIP_ERROR err;
112+
uint32_t objectType;
113+
size_t dataLen;
114+
uint16_t tmpVal = 0;
115+
116+
VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id.
117+
118+
// Get nvm3 object info.
119+
err = MapNvm3Error(nvm3_getObjectInfo(nvm3_defaultHandle, key, &objectType, &dataLen));
120+
SuccessOrExit(err);
121+
122+
// Read nvm3 bytes into tmp.
123+
err = MapNvm3Error(nvm3_readData(nvm3_defaultHandle, key, &tmpVal, dataLen));
124+
SuccessOrExit(err);
125+
val = tmpVal;
126+
127+
exit:
128+
return err;
129+
}
130+
109131
CHIP_ERROR SilabsConfig::ReadConfigValue(Key key, uint32_t & val)
110132
{
111133
CHIP_ERROR err;
@@ -296,6 +318,19 @@ CHIP_ERROR SilabsConfig::WriteConfigValue(Key key, bool val)
296318
return err;
297319
}
298320

321+
CHIP_ERROR SilabsConfig::WriteConfigValue(Key key, uint16_t val)
322+
{
323+
CHIP_ERROR err;
324+
325+
VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id.
326+
327+
err = MapNvm3Error(nvm3_writeData(nvm3_defaultHandle, key, &val, sizeof(val)));
328+
SuccessOrExit(err);
329+
330+
exit:
331+
return err;
332+
}
333+
299334
CHIP_ERROR SilabsConfig::WriteConfigValue(Key key, uint32_t val)
300335
{
301336
CHIP_ERROR err;

src/platform/silabs/SilabsConfig.h

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#pragma once
2626

2727
#include <functional>
28+
#include <platform/CHIPDeviceError.h>
2829

2930
#include "nvm3.h"
3031
#include "nvm3_hal_flash.h"
@@ -176,13 +177,15 @@ class SilabsConfig
176177

177178
// Configuration methods used by the GenericConfigurationManagerImpl<> template.
178179
static CHIP_ERROR ReadConfigValue(Key key, bool & val);
180+
static CHIP_ERROR ReadConfigValue(Key key, uint16_t & val);
179181
static CHIP_ERROR ReadConfigValue(Key key, uint32_t & val);
180182
static CHIP_ERROR ReadConfigValue(Key key, uint64_t & val);
181183
static CHIP_ERROR ReadConfigValueStr(Key key, char * buf, size_t bufSize, size_t & outLen);
182184
static CHIP_ERROR ReadConfigValueBin(Key key, uint8_t * buf, size_t bufSize, size_t & outLen);
183185
static CHIP_ERROR ReadConfigValueBin(Key key, uint8_t * buf, size_t bufSize, size_t & outLen, size_t offset);
184186
static CHIP_ERROR ReadConfigValueCounter(uint8_t counterIdx, uint32_t & val);
185187
static CHIP_ERROR WriteConfigValue(Key key, bool val);
188+
static CHIP_ERROR WriteConfigValue(Key key, uint16_t val);
186189
static CHIP_ERROR WriteConfigValue(Key key, uint32_t val);
187190
static CHIP_ERROR WriteConfigValue(Key key, uint64_t val);
188191
static CHIP_ERROR WriteConfigValueStr(Key key, const char * str);

src/test_driver/efr32/include/FreeRTOSConfig.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,17 @@ standard names. */
285285
#define SysTick_Handler xPortSysTickHandler
286286

287287
/* Thread local storage pointers used by the SDK */
288+
#ifndef configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS
289+
#define configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS 2
290+
#endif
291+
288292
#ifndef configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS
289-
#define configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS 0
293+
#define configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS 2
294+
#endif
295+
296+
#ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS
297+
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS \
298+
(configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS + configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS + 1)
290299
#endif
291300

292301
#if defined(__GNUC__)

third_party/silabs/efr32_sdk.gni

+5
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ template("efr32_sdk") {
157157
"${efr32_sdk_root}/platform/service/device_init/inc",
158158
"${efr32_sdk_root}/platform/service/hfxo_manager/inc",
159159
"${efr32_sdk_root}/platform/service/hfxo_manager/src",
160+
"${efr32_sdk_root}/platform/service/iostream/inc",
160161
"${efr32_sdk_root}/platform/service/mpu/inc",
161162
"${efr32_sdk_root}/platform/service/power_manager/inc/",
162163
"${efr32_sdk_root}/platform/service/power_manager/src/",
@@ -584,6 +585,7 @@ template("efr32_sdk") {
584585
"${efr32_sdk_root}/platform/bootloader/api/btl_interface_storage.c",
585586
"${efr32_sdk_root}/platform/bootloader/security/sha/crypto_sha.c",
586587
"${efr32_sdk_root}/platform/common/src/sl_slist.c",
588+
"${efr32_sdk_root}/platform/common/src/sli_cmsis_os2_ext_task_register.c",
587589
"${efr32_sdk_root}/platform/emdrv/dmadrv/src/dmadrv.c",
588590
"${efr32_sdk_root}/platform/emdrv/gpiointerrupt/src/gpiointerrupt.c",
589591
"${efr32_sdk_root}/platform/emdrv/nvm3/src/nvm3_default.c",
@@ -626,6 +628,8 @@ template("efr32_sdk") {
626628
"${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_lfrco.c",
627629
"${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_nvic.c",
628630
"${efr32_sdk_root}/platform/service/hfxo_manager/src/sl_hfxo_manager.c",
631+
"${efr32_sdk_root}/platform/service/iostream/src/sl_iostream.c",
632+
"${efr32_sdk_root}/platform/service/iostream/src/sl_iostream_rtt.c",
629633
"${efr32_sdk_root}/platform/service/mpu/src/sl_mpu.c",
630634
"${efr32_sdk_root}/platform/service/power_manager/src/sl_power_manager.c",
631635
"${efr32_sdk_root}/platform/service/power_manager/src/sl_power_manager_debug.c",
@@ -711,6 +715,7 @@ template("efr32_sdk") {
711715
"${silabs_gen_folder}/autogen/sl_board_default_init.c",
712716
"${silabs_gen_folder}/autogen/sl_device_init_clocks.c",
713717
"${silabs_gen_folder}/autogen/sl_event_handler.c",
718+
"${silabs_gen_folder}/autogen/sl_iostream_handles.c",
714719
]
715720
if (enable_dic) {
716721
sources += [

third_party/silabs/matter_support

Submodule matter_support updated 56 files

third_party/silabs/silabs_board.gni

+3
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ declare_args() {
4848

4949
# Disable UART log forwarding by default
5050
sl_uart_log_output = false
51+
52+
# Self-provision enabled
53+
use_provision_channel = false
5154
}
5255

5356
declare_args() {

0 commit comments

Comments
 (0)