-
Notifications
You must be signed in to change notification settings - Fork 30
[SL-ONLY] [Cherry-Pick] Tracing: Energy state stats (#699) #728
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
Conversation
* Initial implementation * Polish * Remove total tasks * add debug for transitions and em reqs * power stats "lite" * power tracing with GN * Optimize imports * update unit tests * Add stubs * Restyled by whitespace * Restyled by clang-format * Restyled by gn * remove debug include * update printing * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update headers * avoid size_t for printing * rework init functino * Restyled by whitespace * Restyled by clang-format * add casting for unit tests * Restyled by clang-format * Rename defines * Review comments * Review comments again * Review comments * Use macro * Remove unchanged things * Restyled by whitespace * Restyled by clang-format --------- Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds energy state tracing capabilities to the Silicon Labs platform, enabling developers to monitor device energy mode transitions and statistics. The implementation includes two optional features: real-time energy state statistics accessible via the "tracing energy" CLI command, and detailed transition traces for external analysis.
- New
SilabsPowerTracingclass for recording energy mode transitions with timestamp tracking - Statistics collection for time spent in each energy mode (EM0-EM2) with percentage calculations
- Unit tests with stub implementations for PowerManager and CMSIS OS2 APIs
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/platform/silabs/tracing/tests/mocks/sl_power_manager_stub.h |
Stub header defining PowerManager types and functions for unit tests |
src/platform/silabs/tracing/tests/mocks/sl_power_manager_stub.cpp |
No-op stub implementations of PowerManager functions |
src/platform/silabs/tracing/tests/mocks/cmsis_os2_stub.h |
Stub header defining CMSIS-OS2 timer types and functions for unit tests |
src/platform/silabs/tracing/tests/mocks/cmsis_os2_stub.cpp |
Minimal stub implementations returning success/dummy values |
src/platform/silabs/tracing/tests/TestSilabsPowerTracing.cpp |
Unit tests covering basic functionality, buffer overflow handling, and initialization failures |
src/platform/silabs/tracing/tests/BUILD.gn |
Build configuration for tracing unit tests |
src/platform/silabs/tracing/args.gni |
Build arguments for enabling energy stats and traces features |
src/platform/silabs/tracing/SilabsTracingMacros.h |
Macro for obtaining sleeptimer-based timestamps |
src/platform/silabs/tracing/SilabsTracing.h |
Extended tracer with PowerManager statistics tracking members and methods |
src/platform/silabs/tracing/SilabsTracing.cpp |
Implemented PowerManager transition callbacks and statistics output logic |
src/platform/silabs/tracing/SilabsPowerTracing.h |
Header defining the power tracing singleton class interface |
src/platform/silabs/tracing/SilabsPowerTracing.cpp |
Implementation of power tracing with trace buffer and timer management |
src/platform/silabs/tracing/BUILD.gn |
Build configuration adding power tracing library |
src/platform/silabs/tests/BUILD.gn |
Added tracing tests to platform test group |
src/platform/silabs/efr32/BUILD.gn |
Conditional dependency on power tracing library |
examples/platform/silabs/shell/tracing/TracingShellCommands.cpp |
Added "energy" CLI command handler |
examples/platform/silabs/MatterConfig.cpp |
Initialize power tracing singleton during Matter setup |
examples/platform/silabs/FreeRTOSRuntimeStats.h |
Removed unused totalTaskCount field from SystemTaskStats |
examples/platform/silabs/FreeRTOSRuntimeStats.c |
Removed calculation of unused totalTaskCount field |
Comments suppressed due to low confidence (2)
src/platform/silabs/tracing/SilabsTracing.cpp:836
- The removal of
totalTaskCountfrom the log output appears unrelated to energy tracing functionality. This change modifies task statistics logging behavior and should either be documented in the PR description or moved to a separate commit, as it's not part of the energy state tracing feature being added.
ChipLogProgress(DeviceLayer, "Active tasks: %lu | Terminated tasks: %lu", systemStats.activeTaskCount,
systemStats.terminatedTaskCount);
examples/platform/silabs/FreeRTOSRuntimeStats.h:1
- The removal of
totalTaskCountfromSystemTaskStatsis unrelated to energy tracing and could break existing code that depends on this field. This change should be in a separate PR or clearly documented as a related cleanup with justification for why it's being removed.
/***************************************************************************
Cherry Pick #699
This is a cherry pick of #699 for release 2.8. The rest of the description body is from the original PR
Summary
This PR add two new features.
WIP Confluence page: https://confluence.silabs.com/spaces/MATTER/pages/745094873/Energy+Mode+Tracing+and+Statistics
Related issues
Closes: https://jira.silabs.com/browse/MATTER-5331
-->
Testing
Added unit tests for the energy tracing feature. Uses stubs for PowerManager and CMSIS.
Tested feature on LIT-ICD app and Lighting app on series 2 and 3.
Tested on UART and RTT for the transition traces.
Readability checklist
The checklist below will help the reviewer finish PR review in time and keep the
code readable:
descriptive
“When in Rome…”
rule (coding style)
See: Pull Request Guidelines
Note
Adds optional energy mode statistics and transition tracing on Silabs, wired via GN args, exposed via
tracing energyCLI, initialized behind flags, and covered by unit tests; also dropstotalTaskCountfrom FreeRTOS stats.SilabsTracing(OutputPowerManagerStatistics), enabled bySL_TRACING_ENERGY_STATSand accessible viatracing energy.SilabsPowerTracingcomponent to record EM transitions over time and log them after a timer; initialized inMatterConfig.cppwhenSL_TRACING_ENERGY_TRACES==1.src/platform/silabs/tracing/args.gni; config header defines (SL_TRACING_ENERGY_STATS,SL_TRACING_ENERGY_TRACES, periods/max); newSilabsPowerTracingtarget and deps; EFR32BUILD.gnwires in tracing libs and tests.tracing energycommand to print energy mode statistics.SL_GET_SLEEPTIMER_TIMEfor EM2-safe timestamps.totalTaskCountfromSystemTaskStatsand associated log output.silabs_platform_tests.Written by Cursor Bugbot for commit 5cb7b5d. This will update automatically on new commits. Configure here.