Skip to content

Commit

Permalink
[Silabs] Silabs Uart Shell fixes (project-chip#36667)
Browse files Browse the repository at this point in the history
* [SL-UP] Bugfix/silabs out rtt removal (project-chip#142)

* [SL-UP] Bugfix/matter shell crash nullptr (project-chip#125)

* Added checks on null ptr to prevent uart shell crash and modified ICD shell commands to be compatible with our internal structure
  • Loading branch information
lpbeliveau-silabs authored and yyzhong-g committed Dec 11, 2024
1 parent 41d2720 commit 9a9ff6b
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 22 deletions.
10 changes: 5 additions & 5 deletions examples/platform/silabs/shell/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ if (use_SiWx917) {
shell_dependency_path = "${chip_root}/examples/platform/silabs/SiWx917"
}

config("shell-config") {
include_dirs = [ "." ]
config("icd-shell-config") {
include_dirs = [ "./icd/" ]
}

source_set("icd") {
sources = [
"ICDShellCommands.cpp",
"ICDShellCommands.h",
"./icd/ICDShellCommands.cpp",
"./icd/ICDShellCommands.h",
]

public_configs = [ ":shell-config" ]
public_configs = [ ":icd-shell-config" ]

deps = [ "${shell_dependency_path}:matter-shell" ]
}
2 changes: 2 additions & 0 deletions src/lib/shell/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ CHIP_ERROR Engine::ExecCommand(int argc, char * argv[])
CHIP_ERROR retval = CHIP_ERROR_INVALID_ARGUMENT;

VerifyOrReturnError(argc > 0, retval);
VerifyOrReturnError(nullptr != argv, retval);

// Find the command
for (unsigned i = 0; i < _commandSetCount; i++)
{
Expand Down
13 changes: 4 additions & 9 deletions src/platform/silabs/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,8 @@
#include "uart.h"
#endif

// Enable RTT by default
#ifndef SILABS_LOG_OUT_RTT
#define SILABS_LOG_OUT_RTT 1
#endif

// SEGGER_RTT includes
#if SILABS_LOG_OUT_RTT
#if !SILABS_LOG_OUT_UART
#include "SEGGER_RTT.h"
#include "SEGGER_RTT_Conf.h"
#endif
Expand Down Expand Up @@ -136,7 +131,7 @@ static void PrintLog(const char * msg)
SEGGER_RTT_WriteNoLock(LOG_RTT_BUFFER_INDEX, msg, sz);
#endif // SILABS_LOG_OUT_UART

#if SILABS_LOG_OUT_RTT || PW_RPC_ENABLED
#if !SILABS_LOG_OUT_UART || PW_RPC_ENABLED
const char * newline = "\r\n";
sz = strlen(newline);
#if PW_RPC_ENABLED
Expand All @@ -154,7 +149,7 @@ static void PrintLog(const char * msg)
extern "C" void silabsInitLog(void)
{
#if SILABS_LOG_ENABLED
#if SILABS_LOG_OUT_RTT
#if !SILABS_LOG_OUT_UART
#if LOG_RTT_BUFFER_INDEX != 0
SEGGER_RTT_ConfigUpBuffer(LOG_RTT_BUFFER_INDEX, LOG_RTT_BUFFER_NAME, sLogBuffer, LOG_RTT_BUFFER_SIZE,
SEGGER_RTT_MODE_NO_BLOCK_TRIM);
Expand All @@ -164,7 +159,7 @@ extern "C" void silabsInitLog(void)
#else
SEGGER_RTT_SetFlagsUpBuffer(LOG_RTT_BUFFER_INDEX, SEGGER_RTT_MODE_NO_BLOCK_TRIM);
#endif
#endif // SILABS_LOG_OUT_RTT
#endif // !SILABS_LOG_OUT_UART

#ifdef PW_RPC_ENABLED
PigweedLogger::init();
Expand Down
7 changes: 3 additions & 4 deletions third_party/silabs/SiWx917_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,9 @@ template("siwx917_sdk") {
}

if (sl_uart_log_output) {
defines += [
"SILABS_LOG_OUT_UART=1",
"SILABS_LOG_OUT_RTT=0",
]
defines += [ "SILABS_LOG_OUT_UART=1" ]
} else {
defines += [ "SILABS_LOG_OUT_UART=0" ]
}

if (chip_build_libshell) { # matter shell
Expand Down
7 changes: 3 additions & 4 deletions third_party/silabs/efr32_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,9 @@ template("efr32_sdk") {
}

if (sl_uart_log_output) {
defines += [
"SILABS_LOG_OUT_UART=1",
"SILABS_LOG_OUT_RTT=0",
]
defines += [ "SILABS_LOG_OUT_UART=1" ]
} else {
defines += [ "SILABS_LOG_OUT_UART=0" ]
}

if (use_silabs_thread_lib) {
Expand Down

0 comments on commit 9a9ff6b

Please sign in to comment.