From 093fd0621c3ce6c584acd49d8936e6a6802b9108 Mon Sep 17 00:00:00 2001 From: Matthew Albert Date: Thu, 30 Oct 2025 14:07:29 -0400 Subject: [PATCH 1/4] Initial implementation --- examples/platform/silabs/MatterConfig.cpp | 1 + .../shell/tracing/TracingShellCommands.cpp | 6 ++ src/platform/silabs/tracing/BUILD.gn | 5 ++ src/platform/silabs/tracing/BackendImpl.cpp | 5 ++ src/platform/silabs/tracing/BackendImpl.h | 2 + src/platform/silabs/tracing/SilabsTracing.cpp | 73 +++++++++++++++++++ src/platform/silabs/tracing/SilabsTracing.h | 29 ++++++++ 7 files changed, 121 insertions(+) diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp index 78792cc8643..4f18a72a6f6 100644 --- a/examples/platform/silabs/MatterConfig.cpp +++ b/examples/platform/silabs/MatterConfig.cpp @@ -363,6 +363,7 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName) #if MATTER_TRACING_ENABLED static Tracing::Silabs::BackendImpl backend; Tracing::Register(backend); + backend.RegisterPowerManagerTracing(); #endif // MATTER_TRACING_ENABLED chip::DeviceLayer::PlatformMgr().UnlockChipStack(); diff --git a/examples/platform/silabs/shell/tracing/TracingShellCommands.cpp b/examples/platform/silabs/shell/tracing/TracingShellCommands.cpp index c76cd247a32..c2b9af5e31b 100644 --- a/examples/platform/silabs/shell/tracing/TracingShellCommands.cpp +++ b/examples/platform/silabs/shell/tracing/TracingShellCommands.cpp @@ -99,6 +99,11 @@ CHIP_ERROR TasksCommandHandler(int argc, char ** argv) return SilabsTracer::Instance().OutputTaskStatistics(); } +CHIP_ERROR EnergyCommandHandler(int argc, char ** argv) +{ + return SilabsTracer::Instance().OutputPowerManagerStatistics(); +} + } // namespace namespace TracingCommands { @@ -111,6 +116,7 @@ void RegisterCommands() { &MetricsCommandHandler, "metrics", "Display runtime metrics. Usage: metrics " }, { &FlushCommandHandler, "flush", "Display buffered traces. Usage: flush " }, { &TasksCommandHandler, "tasks", "Display FreeRTOS task statistics." }, + { &EnergyCommandHandler, "energy", "Display energy mode statistics." }, }; static const Shell::Command cmds_silabs_tracing = { &TracingCommandHandler, "tracing", "Dispatch Silicon Labs Tracing command" }; diff --git a/src/platform/silabs/tracing/BUILD.gn b/src/platform/silabs/tracing/BUILD.gn index dc596d53571..3dd3b99a39b 100644 --- a/src/platform/silabs/tracing/BUILD.gn +++ b/src/platform/silabs/tracing/BUILD.gn @@ -26,6 +26,7 @@ declare_args() { # - Runtime statistics timer configuration # - Task switching hooks for statistics collection silabs_tracing_runtime_stats = false + silabs_tracing_energy_stats = false } buildconfig_header("silabs_tracing_config") { @@ -34,6 +35,10 @@ buildconfig_header("silabs_tracing_config") { defines = [] + if (silabs_tracing_energy_stats == true) { + defines += [ "SILABS_TRACING_ENERGY_STATS=1" ] + } + if (silabs_tracing_runtime_stats == true) { defines += [ "TRACING_RUNTIME_STATS=1", diff --git a/src/platform/silabs/tracing/BackendImpl.cpp b/src/platform/silabs/tracing/BackendImpl.cpp index 24cf65daf30..7a2719b4ed4 100644 --- a/src/platform/silabs/tracing/BackendImpl.cpp +++ b/src/platform/silabs/tracing/BackendImpl.cpp @@ -96,6 +96,11 @@ void BackendImpl::LogMetricEvent(const MetricEvent & event) } } +void BackendImpl::RegisterPowerManagerTracing() +{ + SilabsTracer::Instance().RegisterPowerManagerTracing(); +} + } // namespace Silabs } // namespace Tracing } // namespace chip diff --git a/src/platform/silabs/tracing/BackendImpl.h b/src/platform/silabs/tracing/BackendImpl.h index 0594e78bc46..bdb909843cb 100644 --- a/src/platform/silabs/tracing/BackendImpl.h +++ b/src/platform/silabs/tracing/BackendImpl.h @@ -52,6 +52,8 @@ class BackendImpl : public ::chip::Tracing::Backend * SilabsTracer.Init() needs to be called before this is called. */ void LogMetricEvent(const MetricEvent &) override; + + void RegisterPowerManagerTracing(); }; } // namespace Silabs diff --git a/src/platform/silabs/tracing/SilabsTracing.cpp b/src/platform/silabs/tracing/SilabsTracing.cpp index fcf1aa7489c..d41e5f58764 100644 --- a/src/platform/silabs/tracing/SilabsTracing.cpp +++ b/src/platform/silabs/tracing/SilabsTracing.cpp @@ -883,6 +883,79 @@ CHIP_ERROR SilabsTracer::OutputTaskStatistics() #endif // configGENERATE_RUN_TIME_STATS == 1 +#if defined(SILABS_TRACING_ENERGY_STATS) && SILABS_TRACING_ENERGY_STATS == 1 + +void SilabsTracer::PowerManagerTransitionCallback(sl_power_manager_em_t from, sl_power_manager_em_t to) +{ + if (from == mCurrentEnergyMode) + { + auto currentTime = SILABS_GET_TIME(); + auto timeDiff = currentTime - mLastEnergyStateTransitionTime; + mTimeInEnergyState[from] += timeDiff; + } + else + { + ChipLogError(DeviceLayer, "Unexpected power manager transition from EM%d to EM%d (expected EM%d to EM%d)", from, to, + mCurrentEnergyMode, to); + } + + // Update time spent in previous energy mode + mCurrentEnergyMode = to; + mLastEnergyStateTransitionTime = SILABS_GET_TIME(); +} + +void SilabsTracer::StaticPowerManagerTransitionCallback(sl_power_manager_em_t from, sl_power_manager_em_t to) +{ + Instance().PowerManagerTransitionCallback(from, to); +} + +#endif // SILABS_TRACING_ENERGY_STATS + +void SilabsTracer::RegisterPowerManagerTracing() +{ +#if defined(SILABS_TRACING_ENERGY_STATS) && SILABS_TRACING_ENERGY_STATS == 1 + memset(mTimeInEnergyState, 0, sizeof(mTimeInEnergyState)); + sl_power_manager_subscribe_em_transition_event(&power_manager_em_transition_event_handle, + &power_manager_em_transition_event_info); +#endif // SILABS_TRACING_ENERGY_STATS +} + +CHIP_ERROR SilabsTracer::OutputPowerManagerStatistics() +{ +#if defined(SILABS_TRACING_ENERGY_STATS) && SILABS_TRACING_ENERGY_STATS != 1 + VerifyOrReturnError(isLogInitialized(), CHIP_ERROR_UNINITIALIZED); + + auto currentTime = SILABS_GET_TIME(); + + ChipLogProgress(DeviceLayer, "=== Power Manager Energy Mode Statistics ==="); + ChipLogProgress(DeviceLayer, "Total Runtime: %lu ms", currentTime.count()); + + // Table header + ChipLogProgress(DeviceLayer, "| %-12s| %-12s | %-10s |", "Energy Mode", "Time (ms)", "Percentage"); + ChipLogProgress(DeviceLayer, "|%-13s|%-14s|%-12s|", "-------------", "--------------", "------------"); + + for (size_t em = 0; em <= SL_POWER_MANAGER_EM2; em++) + { + auto currentTime = SILABS_GET_TIME(); + System::Clock::Milliseconds32 totalTimeInMode = mTimeInEnergyState[em]; + if (mCurrentEnergyMode == static_cast(em)) + { + totalTimeInMode += currentTime - mLastEnergyStateTransitionTime; + } + // Use 64-bit arithmetic to avoid overflow, then calculate percentage with 4 decimal places + uint64_t percentage = + currentTime.count() > 0 ? (static_cast(totalTimeInMode.count()) * 1000000) / currentTime.count() : 0; + ChipLogProgress(DeviceLayer, "| EM%-10d| %-12lu | %3lu.%04lu%% |", static_cast(em), totalTimeInMode.count(), + static_cast(percentage / 10000), static_cast(percentage % 10000)); + } + + return CHIP_NO_ERROR; +#else // SILABS_TRACING_ENERGY_STATS != 1 + ChipLogError(DeviceLayer, "Power Manager statistics not available - SILABS_TRACING_ENERGY_STATS not enabled"); + return CHIP_ERROR_UNINITIALIZED; +#endif // SILABS_TRACING_ENERGY_STATS +} + } // namespace Silabs } // namespace Tracing } // namespace chip diff --git a/src/platform/silabs/tracing/SilabsTracing.h b/src/platform/silabs/tracing/SilabsTracing.h index 4b73911629c..8da2e3d3b8d 100644 --- a/src/platform/silabs/tracing/SilabsTracing.h +++ b/src/platform/silabs/tracing/SilabsTracing.h @@ -24,6 +24,12 @@ #include #include #include +#if defined(SILABS_TRACING_ENERGY_STATS) && SILABS_TRACING_ENERGY_STATS == 1 +#include +#define SLEEP_EM_EVENT_MASK \ + (SL_POWER_MANAGER_EVENT_TRANSITION_ENTERING_EM0 | SL_POWER_MANAGER_EVENT_TRANSITION_ENTERING_EM1 | \ + SL_POWER_MANAGER_EVENT_TRANSITION_ENTERING_EM2) +#endif // SILABS_TRACING_ENERGY_STATS #include #include @@ -283,6 +289,14 @@ class SilabsTracer */ CHIP_ERROR OutputTaskStatistics(); + /** + * @brief Registers the power manager tracing functionnality with the power manager to receive notifications when the devices + * changes its power state. + */ + void RegisterPowerManagerTracing(); + + CHIP_ERROR OutputPowerManagerStatistics(); + private: struct TimeTrackerList { @@ -358,6 +372,16 @@ class SilabsTracer PersistentStorageDelegate * mStorage = nullptr; size_t mBufferedTrackerCount = 0; +#if defined(SILABS_TRACING_ENERGY_STATS) && SILABS_TRACING_ENERGY_STATS == 1 + + System::Clock::Milliseconds32 mTimeInEnergyState[SL_POWER_MANAGER_EM2 + 1]; + System::Clock::Milliseconds32 mLastEnergyStateTransitionTime; + sl_power_manager_em_t mCurrentEnergyMode; + sl_power_manager_em_transition_event_handle_t power_manager_em_transition_event_handle; + sl_power_manager_em_transition_event_info_t power_manager_em_transition_event_info = { + .event_mask = SLEEP_EM_EVENT_MASK, .on_event = StaticPowerManagerTransitionCallback + }; +#endif // SILABS_TRACING_ENERGY_STATS /** @brief Clear the trace buffer */ void TraceBufferClear(); @@ -397,6 +421,11 @@ class SilabsTracer * @return CHIP_ERROR, returns CHIP_ERROR_INVALID_ARGUMENT if the format is not respected. */ CHIP_ERROR SplitNamedTraceString(CharSpan appOperationKey, CharSpan & groupSpan, CharSpan & labelSpan) const; + +#if defined(SILABS_TRACING_ENERGY_STATS) && SILABS_TRACING_ENERGY_STATS == 1 + void PowerManagerTransitionCallback(sl_power_manager_em_t from, sl_power_manager_em_t to); + static void StaticPowerManagerTransitionCallback(sl_power_manager_em_t from, sl_power_manager_em_t to); +#endif // SILABS_TRACING_ENERGY_STATS }; } // namespace Silabs From 955aa6a5f93df8e2e68a48b6896b2d5f1ef4ba1f Mon Sep 17 00:00:00 2001 From: Matthew Albert Date: Thu, 30 Oct 2025 14:58:34 -0400 Subject: [PATCH 2/4] Polish --- src/platform/silabs/tracing/SilabsTracing.cpp | 9 ++++--- src/platform/silabs/tracing/SilabsTracing.h | 27 +++++++++++++++---- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/platform/silabs/tracing/SilabsTracing.cpp b/src/platform/silabs/tracing/SilabsTracing.cpp index d41e5f58764..52977b105c8 100644 --- a/src/platform/silabs/tracing/SilabsTracing.cpp +++ b/src/platform/silabs/tracing/SilabsTracing.cpp @@ -915,14 +915,15 @@ void SilabsTracer::RegisterPowerManagerTracing() { #if defined(SILABS_TRACING_ENERGY_STATS) && SILABS_TRACING_ENERGY_STATS == 1 memset(mTimeInEnergyState, 0, sizeof(mTimeInEnergyState)); - sl_power_manager_subscribe_em_transition_event(&power_manager_em_transition_event_handle, - &power_manager_em_transition_event_info); + mCurrentEnergyMode = static_cast(0); + mLastEnergyStateTransitionTime = SILABS_GET_TIME(); + sl_power_manager_subscribe_em_transition_event(&mPowerManagerEmTransitionEventHandle, &mPowerManagerEmTransitionEventInfo); #endif // SILABS_TRACING_ENERGY_STATS } CHIP_ERROR SilabsTracer::OutputPowerManagerStatistics() { -#if defined(SILABS_TRACING_ENERGY_STATS) && SILABS_TRACING_ENERGY_STATS != 1 +#if defined(SILABS_TRACING_ENERGY_STATS) && SILABS_TRACING_ENERGY_STATS == 1 VerifyOrReturnError(isLogInitialized(), CHIP_ERROR_UNINITIALIZED); auto currentTime = SILABS_GET_TIME(); @@ -934,9 +935,9 @@ CHIP_ERROR SilabsTracer::OutputPowerManagerStatistics() ChipLogProgress(DeviceLayer, "| %-12s| %-12s | %-10s |", "Energy Mode", "Time (ms)", "Percentage"); ChipLogProgress(DeviceLayer, "|%-13s|%-14s|%-12s|", "-------------", "--------------", "------------"); + auto currentTime = SILABS_GET_TIME(); for (size_t em = 0; em <= SL_POWER_MANAGER_EM2; em++) { - auto currentTime = SILABS_GET_TIME(); System::Clock::Milliseconds32 totalTimeInMode = mTimeInEnergyState[em]; if (mCurrentEnergyMode == static_cast(em)) { diff --git a/src/platform/silabs/tracing/SilabsTracing.h b/src/platform/silabs/tracing/SilabsTracing.h index 8da2e3d3b8d..39423f84952 100644 --- a/src/platform/silabs/tracing/SilabsTracing.h +++ b/src/platform/silabs/tracing/SilabsTracing.h @@ -290,11 +290,15 @@ class SilabsTracer CHIP_ERROR OutputTaskStatistics(); /** - * @brief Registers the power manager tracing functionnality with the power manager to receive notifications when the devices + * @brief Registers the power manager tracing functionality with the power manager to receive notifications when the device * changes its power state. */ void RegisterPowerManagerTracing(); + /** @brief Output power manager energy mode statistics + * This function outputs the total time spent in each energy mode and the percentage of total time. + * @return CHIP_ERROR, returns CHIP_ERROR_UNINITIALIZED if the feature or logs are not initialized + */ CHIP_ERROR OutputPowerManagerStatistics(); private: @@ -377,10 +381,10 @@ class SilabsTracer System::Clock::Milliseconds32 mTimeInEnergyState[SL_POWER_MANAGER_EM2 + 1]; System::Clock::Milliseconds32 mLastEnergyStateTransitionTime; sl_power_manager_em_t mCurrentEnergyMode; - sl_power_manager_em_transition_event_handle_t power_manager_em_transition_event_handle; - sl_power_manager_em_transition_event_info_t power_manager_em_transition_event_info = { - .event_mask = SLEEP_EM_EVENT_MASK, .on_event = StaticPowerManagerTransitionCallback - }; + sl_power_manager_em_transition_event_handle_t mPowerManagerEmTransitionEventHandle; + sl_power_manager_em_transition_event_info_t mPowerManagerEmTransitionEventInfo = { .event_mask = SLEEP_EM_EVENT_MASK, + .on_event = + StaticPowerManagerTransitionCallback }; #endif // SILABS_TRACING_ENERGY_STATS /** @brief Clear the trace buffer */ @@ -423,7 +427,20 @@ class SilabsTracer CHIP_ERROR SplitNamedTraceString(CharSpan appOperationKey, CharSpan & groupSpan, CharSpan & labelSpan) const; #if defined(SILABS_TRACING_ENERGY_STATS) && SILABS_TRACING_ENERGY_STATS == 1 + + /** @brief Callback for power manager energy mode transitions + * This function is called by the power manager when the device transitions between energy modes. + * It updates the time spent in each energy mode. + * @param from The energy mode the device is transitioning from + * @param to The energy mode the device is transitioning to + */ void PowerManagerTransitionCallback(sl_power_manager_em_t from, sl_power_manager_em_t to); + + /** @brief Static callback for power manager energy mode transitions + * This function is a static wrapper that calls the instance method PowerManagerTransitionCallback. + * @param from The energy mode the device is transitioning from + * @param to The energy mode the device is transitioning to + */ static void StaticPowerManagerTransitionCallback(sl_power_manager_em_t from, sl_power_manager_em_t to); #endif // SILABS_TRACING_ENERGY_STATS }; From 35668cbdcf6f237622d6d73b5fd5f87a6870b936 Mon Sep 17 00:00:00 2001 From: Matthew Albert Date: Thu, 30 Oct 2025 15:34:55 -0400 Subject: [PATCH 3/4] Remove total tasks --- examples/platform/silabs/FreeRTOSRuntimeStats.c | 1 - examples/platform/silabs/FreeRTOSRuntimeStats.h | 1 - src/platform/silabs/tracing/SilabsTracing.cpp | 4 ++-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/platform/silabs/FreeRTOSRuntimeStats.c b/examples/platform/silabs/FreeRTOSRuntimeStats.c index a2b7d10ff71..7962b15a63e 100644 --- a/examples/platform/silabs/FreeRTOSRuntimeStats.c +++ b/examples/platform/silabs/FreeRTOSRuntimeStats.c @@ -308,7 +308,6 @@ uint32_t ulGetAllTaskInfo(TaskInfo * taskInfoArray, uint32_t taskInfoArraySize, if (systemStats != NULL) { systemStats->terminatedTaskCount = deletedCount; - systemStats->totalTaskCount = systemStats->activeTaskCount + deletedCount; systemStats->activeTaskCount = actualTasks; } diff --git a/examples/platform/silabs/FreeRTOSRuntimeStats.h b/examples/platform/silabs/FreeRTOSRuntimeStats.h index e521f6b6886..942d0ca7b93 100644 --- a/examples/platform/silabs/FreeRTOSRuntimeStats.h +++ b/examples/platform/silabs/FreeRTOSRuntimeStats.h @@ -64,7 +64,6 @@ typedef struct uint32_t systemPreemptionRatio; uint32_t activeTaskCount; uint32_t terminatedTaskCount; - uint32_t totalTaskCount; } SystemTaskStats; /** diff --git a/src/platform/silabs/tracing/SilabsTracing.cpp b/src/platform/silabs/tracing/SilabsTracing.cpp index 52977b105c8..e61a44623f9 100644 --- a/src/platform/silabs/tracing/SilabsTracing.cpp +++ b/src/platform/silabs/tracing/SilabsTracing.cpp @@ -821,8 +821,8 @@ CHIP_ERROR SilabsTracer::OutputTaskStatistics() VerifyOrReturnError(taskCount > 0, CHIP_ERROR_INTERNAL, ChipLogError(DeviceLayer, "Failed to get task information")); ChipLogProgress(DeviceLayer, "=== Task Statistics ==="); - ChipLogProgress(DeviceLayer, "Active tasks: %lu | Terminated tasks: %lu | Total tasks: %lu", systemStats.activeTaskCount, - systemStats.terminatedTaskCount, systemStats.totalTaskCount); + ChipLogProgress(DeviceLayer, "Active tasks: %lu | Terminated tasks: %lu", systemStats.activeTaskCount, + systemStats.terminatedTaskCount); ChipLogProgress(DeviceLayer, "Total Runtime: %lu ms", systemStats.totalRunTime); ChipLogProgress(DeviceLayer, "System Preemption Ratio: %lu.%02lu%% (%lu/%lu switches)", (systemStats.systemPreemptionRatio / 100), (systemStats.systemPreemptionRatio % 100), From 6bb65a9b2845eb74b691eed8fce72ecdbad4c6e8 Mon Sep 17 00:00:00 2001 From: Matthew Albert Date: Mon, 3 Nov 2025 13:08:54 -0500 Subject: [PATCH 4/4] add debug for transitions and em reqs --- src/platform/silabs/tracing/SilabsTracing.cpp | 23 +++++++++++++++---- src/platform/silabs/tracing/SilabsTracing.h | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/platform/silabs/tracing/SilabsTracing.cpp b/src/platform/silabs/tracing/SilabsTracing.cpp index e61a44623f9..8701a25b66d 100644 --- a/src/platform/silabs/tracing/SilabsTracing.cpp +++ b/src/platform/silabs/tracing/SilabsTracing.cpp @@ -21,6 +21,8 @@ #include #include // Include the necessary header for std::string +#include "sl_power_manager_debug.h" + // Include FreeRTOS configuration first #if defined(TRACING_RUNTIME_STATS) && TRACING_RUNTIME_STATS extern "C" { @@ -892,6 +894,7 @@ void SilabsTracer::PowerManagerTransitionCallback(sl_power_manager_em_t from, sl auto currentTime = SILABS_GET_TIME(); auto timeDiff = currentTime - mLastEnergyStateTransitionTime; mTimeInEnergyState[from] += timeDiff; + mTransitionCountToEnergyState[to]++; } else { @@ -902,6 +905,11 @@ void SilabsTracer::PowerManagerTransitionCallback(sl_power_manager_em_t from, sl // Update time spent in previous energy mode mCurrentEnergyMode = to; mLastEnergyStateTransitionTime = SILABS_GET_TIME(); + + if (mCurrentEnergyMode == SL_POWER_MANAGER_EM1) + { + OutputPowerManagerStatistics(); + } } void SilabsTracer::StaticPowerManagerTransitionCallback(sl_power_manager_em_t from, sl_power_manager_em_t to) @@ -915,8 +923,11 @@ void SilabsTracer::RegisterPowerManagerTracing() { #if defined(SILABS_TRACING_ENERGY_STATS) && SILABS_TRACING_ENERGY_STATS == 1 memset(mTimeInEnergyState, 0, sizeof(mTimeInEnergyState)); + memset(mTransitionCountToEnergyState, 0, sizeof(mTransitionCountToEnergyState)); mCurrentEnergyMode = static_cast(0); mLastEnergyStateTransitionTime = SILABS_GET_TIME(); + + sl_power_manager_init(); sl_power_manager_subscribe_em_transition_event(&mPowerManagerEmTransitionEventHandle, &mPowerManagerEmTransitionEventInfo); #endif // SILABS_TRACING_ENERGY_STATS } @@ -932,10 +943,9 @@ CHIP_ERROR SilabsTracer::OutputPowerManagerStatistics() ChipLogProgress(DeviceLayer, "Total Runtime: %lu ms", currentTime.count()); // Table header - ChipLogProgress(DeviceLayer, "| %-12s| %-12s | %-10s |", "Energy Mode", "Time (ms)", "Percentage"); - ChipLogProgress(DeviceLayer, "|%-13s|%-14s|%-12s|", "-------------", "--------------", "------------"); + ChipLogProgress(DeviceLayer, "| %-12s| %-12s | %-10s | %-10s |", "Energy Mode", "Time (ms)", "Percentage", "Transitions"); + ChipLogProgress(DeviceLayer, "|%-13s|%-14s|%-12s|%-12s|", "-------------", "--------------", "------------", "------------"); - auto currentTime = SILABS_GET_TIME(); for (size_t em = 0; em <= SL_POWER_MANAGER_EM2; em++) { System::Clock::Milliseconds32 totalTimeInMode = mTimeInEnergyState[em]; @@ -946,10 +956,13 @@ CHIP_ERROR SilabsTracer::OutputPowerManagerStatistics() // Use 64-bit arithmetic to avoid overflow, then calculate percentage with 4 decimal places uint64_t percentage = currentTime.count() > 0 ? (static_cast(totalTimeInMode.count()) * 1000000) / currentTime.count() : 0; - ChipLogProgress(DeviceLayer, "| EM%-10d| %-12lu | %3lu.%04lu%% |", static_cast(em), totalTimeInMode.count(), - static_cast(percentage / 10000), static_cast(percentage % 10000)); + ChipLogProgress(DeviceLayer, "| EM%-10d| %-12lu | %3lu.%04lu%% | %-10u |", static_cast(em), totalTimeInMode.count(), + static_cast(percentage / 10000), static_cast(percentage % 10000), + mTransitionCountToEnergyState[em]); } + sl_power_manager_debug_print_em_requirements(); + return CHIP_NO_ERROR; #else // SILABS_TRACING_ENERGY_STATS != 1 ChipLogError(DeviceLayer, "Power Manager statistics not available - SILABS_TRACING_ENERGY_STATS not enabled"); diff --git a/src/platform/silabs/tracing/SilabsTracing.h b/src/platform/silabs/tracing/SilabsTracing.h index 39423f84952..59284f311bb 100644 --- a/src/platform/silabs/tracing/SilabsTracing.h +++ b/src/platform/silabs/tracing/SilabsTracing.h @@ -379,6 +379,7 @@ class SilabsTracer #if defined(SILABS_TRACING_ENERGY_STATS) && SILABS_TRACING_ENERGY_STATS == 1 System::Clock::Milliseconds32 mTimeInEnergyState[SL_POWER_MANAGER_EM2 + 1]; + uint16_t mTransitionCountToEnergyState[SL_POWER_MANAGER_EM2 + 1]; System::Clock::Milliseconds32 mLastEnergyStateTransitionTime; sl_power_manager_em_t mCurrentEnergyMode; sl_power_manager_em_transition_event_handle_t mPowerManagerEmTransitionEventHandle;