Skip to content

Commit 439de24

Browse files
[Silabs] Silabs Uart Shell fixes (#36667)
* [SL-UP] Bugfix/silabs out rtt removal (#142) * [SL-UP] Bugfix/matter shell crash nullptr (#125) * Added checks on null ptr to prevent uart shell crash and modified ICD shell commands to be compatible with our internal structure
1 parent a39c178 commit 439de24

File tree

7 files changed

+17
-22
lines changed

7 files changed

+17
-22
lines changed

examples/platform/silabs/shell/BUILD.gn

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ if (use_SiWx917) {
2323
shell_dependency_path = "${chip_root}/examples/platform/silabs/SiWx917"
2424
}
2525

26-
config("shell-config") {
27-
include_dirs = [ "." ]
26+
config("icd-shell-config") {
27+
include_dirs = [ "./icd/" ]
2828
}
2929

3030
source_set("icd") {
3131
sources = [
32-
"ICDShellCommands.cpp",
33-
"ICDShellCommands.h",
32+
"./icd/ICDShellCommands.cpp",
33+
"./icd/ICDShellCommands.h",
3434
]
3535

36-
public_configs = [ ":shell-config" ]
36+
public_configs = [ ":icd-shell-config" ]
3737

3838
deps = [ "${shell_dependency_path}:matter-shell" ]
3939
}

src/lib/shell/Engine.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ CHIP_ERROR Engine::ExecCommand(int argc, char * argv[])
8686
CHIP_ERROR retval = CHIP_ERROR_INVALID_ARGUMENT;
8787

8888
VerifyOrReturnError(argc > 0, retval);
89+
VerifyOrReturnError(nullptr != argv, retval);
90+
8991
// Find the command
9092
for (unsigned i = 0; i < _commandSetCount; i++)
9193
{

src/platform/silabs/Logging.cpp

+4-9
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,8 @@
5151
#include "uart.h"
5252
#endif
5353

54-
// Enable RTT by default
55-
#ifndef SILABS_LOG_OUT_RTT
56-
#define SILABS_LOG_OUT_RTT 1
57-
#endif
58-
5954
// SEGGER_RTT includes
60-
#if SILABS_LOG_OUT_RTT
55+
#if !SILABS_LOG_OUT_UART
6156
#include "SEGGER_RTT.h"
6257
#include "SEGGER_RTT_Conf.h"
6358
#endif
@@ -136,7 +131,7 @@ static void PrintLog(const char * msg)
136131
SEGGER_RTT_WriteNoLock(LOG_RTT_BUFFER_INDEX, msg, sz);
137132
#endif // SILABS_LOG_OUT_UART
138133

139-
#if SILABS_LOG_OUT_RTT || PW_RPC_ENABLED
134+
#if !SILABS_LOG_OUT_UART || PW_RPC_ENABLED
140135
const char * newline = "\r\n";
141136
sz = strlen(newline);
142137
#if PW_RPC_ENABLED
@@ -154,7 +149,7 @@ static void PrintLog(const char * msg)
154149
extern "C" void silabsInitLog(void)
155150
{
156151
#if SILABS_LOG_ENABLED
157-
#if SILABS_LOG_OUT_RTT
152+
#if !SILABS_LOG_OUT_UART
158153
#if LOG_RTT_BUFFER_INDEX != 0
159154
SEGGER_RTT_ConfigUpBuffer(LOG_RTT_BUFFER_INDEX, LOG_RTT_BUFFER_NAME, sLogBuffer, LOG_RTT_BUFFER_SIZE,
160155
SEGGER_RTT_MODE_NO_BLOCK_TRIM);
@@ -164,7 +159,7 @@ extern "C" void silabsInitLog(void)
164159
#else
165160
SEGGER_RTT_SetFlagsUpBuffer(LOG_RTT_BUFFER_INDEX, SEGGER_RTT_MODE_NO_BLOCK_TRIM);
166161
#endif
167-
#endif // SILABS_LOG_OUT_RTT
162+
#endif // !SILABS_LOG_OUT_UART
168163

169164
#ifdef PW_RPC_ENABLED
170165
PigweedLogger::init();

third_party/silabs/SiWx917_sdk.gni

+3-4
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,9 @@ template("siwx917_sdk") {
331331
}
332332

333333
if (sl_uart_log_output) {
334-
defines += [
335-
"SILABS_LOG_OUT_UART=1",
336-
"SILABS_LOG_OUT_RTT=0",
337-
]
334+
defines += [ "SILABS_LOG_OUT_UART=1" ]
335+
} else {
336+
defines += [ "SILABS_LOG_OUT_UART=0" ]
338337
}
339338

340339
if (chip_build_libshell) { # matter shell

third_party/silabs/efr32_sdk.gni

+3-4
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,9 @@ template("efr32_sdk") {
487487
}
488488

489489
if (sl_uart_log_output) {
490-
defines += [
491-
"SILABS_LOG_OUT_UART=1",
492-
"SILABS_LOG_OUT_RTT=0",
493-
]
490+
defines += [ "SILABS_LOG_OUT_UART=1" ]
491+
} else {
492+
defines += [ "SILABS_LOG_OUT_UART=0" ]
494493
}
495494

496495
if (use_silabs_thread_lib) {

0 commit comments

Comments
 (0)