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

[SL-ONLY] Silabs tracing integration #122

Merged
merged 12 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions examples/lighting-app/silabs/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ CHIP_ERROR AppTask::Init()
#endif // QR_CODE_ENABLED
#endif

BaseApplication::InitCompleteCallback(err);
return err;
}

Expand Down
23 changes: 23 additions & 0 deletions examples/platform/silabs/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@
#include "sl_cmp_config.h"
#endif

// Tracing
#include <matter/tracing/build_config.h>
#if MATTER_TRACING_ENABLED
lpbeliveau-silabs marked this conversation as resolved.
Show resolved Hide resolved
#include <TracingShellCommands.h>
#include <platform/silabs/tracing/SilabsTracing.h>
#endif // MATTER_TRACING_ENABLED

/**********************************************************
* Defines and Constants
*********************************************************/
Expand All @@ -113,6 +120,11 @@ using namespace chip::app;
using namespace ::chip::DeviceLayer;
using namespace ::chip::DeviceLayer::Silabs;

#if MATTER_TRACING_ENABLED
using TimeTraceOperation = chip::Tracing::Silabs::TimeTraceOperation;
using SilabsTracer = chip::Tracing::Silabs::SilabsTracer;
#endif // MATTER_TRACING_ENABLED

namespace {

/**********************************************************
Expand Down Expand Up @@ -322,6 +334,9 @@ CHIP_ERROR BaseApplication::Init()
#if CHIP_CONFIG_ENABLE_ICD_SERVER
ICDCommands::RegisterCommands();
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
#if MATTER_TRACING_ENABLED
TracingCommands::RegisterCommands();
#endif // MATTER_TRACING_ENABLED
#endif // ENABLE_CHIP_SHELL

#ifdef PERFORMANCE_TEST_ENABLED
Expand All @@ -340,6 +355,14 @@ CHIP_ERROR BaseApplication::Init()
return err;
}

void BaseApplication::InitCompleteCallback(CHIP_ERROR err)
{
#if MATTER_TRACING_ENABLED
SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kAppInit);
SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kBootup);
#endif // MATTER_TRACING_ENABLED
}

void BaseApplication::FunctionTimerEventHandler(void * timerCbArg)
{
AppEvent event;
Expand Down
11 changes: 10 additions & 1 deletion examples/platform/silabs/BaseApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class BaseApplication

public:
BaseApplication() = default;
virtual ~BaseApplication() {};
virtual ~BaseApplication(){};
static bool sIsProvisioned;
static bool sIsFactoryResetTriggered;
static LEDWidget * sAppActionLed;
Expand Down Expand Up @@ -122,6 +122,7 @@ class BaseApplication
*
* @param event AppEvent to post
*/

static void PostEvent(const AppEvent * event);

/**
Expand Down Expand Up @@ -176,6 +177,14 @@ class BaseApplication
protected:
CHIP_ERROR Init();

/** @brief
* Function to be called at the end of Init to indicate that the application has completed its initialization.
* Currently only used for tracing, might want to move logging here as well in the future
* @param err CHIP_NO_ERROR on success, corresponding error code on Init failure, note that Init failure leeds to app error so
lpbeliveau-silabs marked this conversation as resolved.
Show resolved Hide resolved
* this is purely to have a trace logged with the error code
*/
void InitCompleteCallback(CHIP_ERROR err);
lpbeliveau-silabs marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief Function called to start the function timer
*
Expand Down
26 changes: 26 additions & 0 deletions examples/platform/silabs/MatterConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ static chip::DeviceLayer::Internal::Efr32PsaOperationalKeystore gOperationalKeys
#include "sl_power_manager.h"
#endif

#include <matter/tracing/build_config.h>
#if MATTER_TRACING_ENABLED
#include <platform/silabs/tracing/BackendImpl.h>
#include <platform/silabs/tracing/SilabsTracing.h>
#include <tracing/registry.h>
#endif // MATTER_TRACING_ENABLED

/**********************************************************
* Defines
*********************************************************/
Expand All @@ -101,6 +108,11 @@ using namespace ::chip::DeviceLayer;
using namespace ::chip::Credentials;
using namespace chip::DeviceLayer::Silabs;

#if MATTER_TRACING_ENABLED
using TimeTraceOperation = chip::Tracing::Silabs::TimeTraceOperation;
using SilabsTracer = chip::Tracing::Silabs::SilabsTracer;
#endif // MATTER_TRACING_ENABLED

#if CHIP_ENABLE_OPENTHREAD
#include <inet/EndPointStateOpenThread.h>
#include <openthread/cli.h>
Expand Down Expand Up @@ -175,6 +187,11 @@ void ApplicationStart(void * unused)
if (err != CHIP_NO_ERROR)
appError(err);

#if MATTER_TRACING_ENABLED
SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kMatterInit);
SilabsTracer::Instance().TimeTraceBegin(TimeTraceOperation::kAppInit);
#endif // MATTER_TRACING_ENABLED

gExampleDeviceInfoProvider.SetStorageDelegate(&chip::Server::GetInstance().GetPersistentStorage());
chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);

Expand Down Expand Up @@ -205,6 +222,10 @@ void SilabsMatterConfig::AppInit()
sMainTaskHandle = osThreadNew(ApplicationStart, nullptr, &kMainTaskAttr);
ChipLogProgress(DeviceLayer, "Starting scheduler");
VerifyOrDie(sMainTaskHandle); // We can't proceed if the Main Task creation failed.

#if MATTER_TRACING_ENABLED
SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kBootup);
#endif // MATTER_TRACING_ENABLED
GetPlatform().StartScheduler();

// Should never get here.
Expand Down Expand Up @@ -312,6 +333,11 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName)
// Init Matter Server and Start Event Loop
err = chip::Server::GetInstance().Init(initParams);

#if MATTER_TRACING_ENABLED
static Tracing::Silabs::BackendImpl backend;
Tracing::Register(backend);
#endif // MATTER_TRACING_ENABLED

chip::DeviceLayer::PlatformMgr().UnlockChipStack();

ReturnErrorOnFailure(err);
Expand Down
1 change: 1 addition & 0 deletions examples/platform/silabs/MatterShell.cpp
lpbeliveau-silabs marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <cmsis_os2.h>
#include <lib/core/CHIPCore.h>
#include <lib/shell/Engine.h>
#include <matter/tracing/build_config.h>
mkardous-silabs marked this conversation as resolved.
Show resolved Hide resolved
#include <sl_cmsis_os2_common.h>
#ifdef SL_CATALOG_CLI_PRESENT
#include "sl_cli.h"
Expand Down
16 changes: 15 additions & 1 deletion examples/platform/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/src/app/icd/icd.gni")
import("${chip_root}/src/lib/lib.gni")
import("${chip_root}/src/platform/device.gni")
import("${chip_root}/src/tracing/tracing_args.gni")
import("${silabs_sdk_build_root}/efr32_sdk.gni")
import("${silabs_sdk_build_root}/silabs_board.gni")

Expand Down Expand Up @@ -110,6 +111,9 @@ source_set("matter-shell") {
"${chip_root}/src/lib/shell:shell",
"${chip_root}/src/lib/shell:shell_core",
]
if (matter_enable_tracing_support) {
public_deps += [ "${chip_root}/src/platform/silabs/tracing:SilabsTracing" ]
}
}

config("efr32-common-config") {
Expand Down Expand Up @@ -141,7 +145,10 @@ config("efr32-common-config") {
}

source_set("efr32-common") {
deps = [ "${silabs_common_plat_dir}/provision:storage" ]
deps = [
"${chip_root}/src/tracing",
lpbeliveau-silabs marked this conversation as resolved.
Show resolved Hide resolved
"${silabs_common_plat_dir}/provision:storage",
]
defines = []
public_deps = []
public_configs = [
Expand Down Expand Up @@ -210,6 +217,9 @@ source_set("efr32-common") {
if (chip_enable_icd_server) {
deps += [ "${silabs_common_plat_dir}/shell:icd" ]
}
if (matter_enable_tracing_support) {
public_deps += [ "${silabs_common_plat_dir}/shell:tracing" ]
}
}

public_deps += [
Expand All @@ -233,4 +243,8 @@ source_set("efr32-common") {
if (app_data_model != "") {
public_deps += [ app_data_model ]
}

if (matter_enable_tracing_support) {
public_deps += [ "${chip_root}/src/platform/silabs/tracing:SilabsTracing" ]
}
}
23 changes: 22 additions & 1 deletion examples/platform/silabs/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,31 @@
#include "sl_system_kernel.h"
#include <MatterConfig.h>

#include <matter/tracing/build_config.h>
#if MATTER_TRACING_ENABLED
#include <platform/silabs/tracing/SilabsTracing.h>
#endif // MATTER_TRACING_ENABLED

#if MATTER_TRACING_ENABLED
using TimeTraceOperation = chip::Tracing::Silabs::TimeTraceOperation;
using SilabsTracer = chip::Tracing::Silabs::SilabsTracer;
#endif // MATTER_TRACING_ENABLED

int main(void)
{
#if MATTER_TRACING_ENABLED
SilabsTracer::Instance().TimeTraceBegin(TimeTraceOperation::kBootup);
#endif // MATTER_TRACING_ENABLED
lpbeliveau-silabs marked this conversation as resolved.
Show resolved Hide resolved
#if MATTER_TRACING_ENABLED
lpbeliveau-silabs marked this conversation as resolved.
Show resolved Hide resolved
SilabsTracer::Instance().TimeTraceBegin(TimeTraceOperation::kSilabsInit);
#endif // MATTER_TRACING_ENABLED
sl_system_init();

#if MATTER_TRACING_ENABLED
SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kSilabsInit);
#endif // MATTER_TRACING_ENABLED
lpbeliveau-silabs marked this conversation as resolved.
Show resolved Hide resolved
#if MATTER_TRACING_ENABLED
lpbeliveau-silabs marked this conversation as resolved.
Show resolved Hide resolved
SilabsTracer::Instance().TimeTraceBegin(TimeTraceOperation::kMatterInit);
#endif // MATTER_TRACING_ENABLED
// Initialize the application. For example, create periodic timer(s) or
// task(s) if the kernel is present.
SilabsMatterConfig::AppInit();
Expand Down
25 changes: 20 additions & 5 deletions examples/platform/silabs/shell/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,32 @@ if (use_SiWx917) {
shell_dependency_path = "${chip_root}/examples/platform/silabs/SiWx917"
}

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

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

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

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

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

source_set("tracing") {
sources = [
"./tracing/TracingShellCommands.cpp",
"./tracing/TracingShellCommands.h",
]

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

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