Skip to content

Commit

Permalink
Integrated in lighting app to have complete time to LIGHT-ON, will ap…
Browse files Browse the repository at this point in the history
…ply tracing to other apps as well after review of potential app refactor
  • Loading branch information
lpbeliveau-silabs committed Nov 22, 2024
1 parent a65940b commit 39f2244
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 5 deletions.
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
19 changes: 19 additions & 0 deletions examples/platform/silabs/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@
#include "sl_cmp_config.h"
#endif

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

/**********************************************************
* Defines and Constants
*********************************************************/
Expand All @@ -113,6 +119,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 @@ -340,6 +351,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
9 changes: 8 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,12 @@ 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
*/
void InitCompleteCallback(CHIP_ERROR err);

/**
* @brief Function called to start the function timer
*
Expand Down
8 changes: 5 additions & 3 deletions examples/platform/silabs/MatterConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,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 @@ -218,9 +223,6 @@ void SilabsMatterConfig::AppInit()
ChipLogProgress(DeviceLayer, "Starting scheduler");
VerifyOrDie(sMainTaskHandle); // We can't proceed if the Main Task creation failed.

#if MATTER_TRACING_ENABLED
SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kMatterInit);
#endif // MATTER_TRACING_ENABLED
#if MATTER_TRACING_ENABLED
SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kBootup);
#endif // MATTER_TRACING_ENABLED
Expand Down
8 changes: 7 additions & 1 deletion src/platform/silabs/efr32/OTAImageProcessorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,15 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context)
}
#endif // SL_BTLCTRL_MUX

ChipLogProgress(SoftwareUpdate, "Reboot and install new image...");
#if MATTER_TRACING_ENABLED
SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kImageVerification);
SilabsTracer::Instance().TimeTraceInstant(TimeTraceOperation::kAppApplyTime);
#endif // MATTER_TRACING_ENABLED
ChipLogProgress(SoftwareUpdate, "Reboot and install new image...");

#if MATTER_TRACING_ENABLED
// Flush all traces before reboot since we do not store them in NVM currently
SilabsTracer::Instance().TraceBufferFlushAll();
#endif // MATTER_TRACING_ENABLED
#if defined(_SILICON_LABS_32B_SERIES_3) && CHIP_PROGRESS_LOGGING
osDelay(100); // sl-temp: delay for uart print before reboot
Expand Down
2 changes: 2 additions & 0 deletions src/platform/silabs/tracing/SilabsTracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ const char * TimeTraceOperationToString(TimeTraceOperation operation)
return "SilabsInit";
case TimeTraceOperation::kMatterInit:
return "MatterInit";
case TimeTraceOperation::kAppInit:
return "AppInit";
case TimeTraceOperation::kNumTraces:
return "NumTraces";
case TimeTraceOperation::kBufferFull:
Expand Down
1 change: 1 addition & 0 deletions src/platform/silabs/tracing/SilabsTracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ enum class TimeTraceOperation : uint8_t
kBootup,
kSilabsInit,
kMatterInit,
kAppInit,
kBufferFull,
kNumTraces,
};
Expand Down

0 comments on commit 39f2244

Please sign in to comment.