Skip to content

Commit b5406f4

Browse files
committed
Add section for sleep tracing
1 parent 637105a commit b5406f4

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

docs/reference/api/platform/PowerManagement.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,39 @@ These Mbed OS drivers can lock the deep sleep:
4444

4545
[![View code](https://www.mbed.com/embed/?url=https://os.mbed.com/teams/mbed_example/code/SleepManager_Example_1/)](https://os.mbed.com/teams/mbed_example/code/SleepManager_Example_1/file/e85412b4147e/main.cpp)
4646

47+
#### Sleep tracing
48+
49+
Mbed OS can help you to understand the sleep patterns of your device, specifically who is holding a sleep locks preventing your board to enter the deep sleep. To enable the tracing, all you need to do is to define `MBED_SLEEP_TRACING_ENABLED` macro. You can do it by modifying your `mbed_app.json` config file or appending `-DMBED_SLEEP_TRACING_ENABLED` to `mbed compile` command.
50+
51+
Mbed OS will print sleep traces on the standard output, which by default is UART. Some of the events that we track:
52+
53+
* Locking deep sleep: `LOCK: <file name>, ln: <line in file>, lock count: <number of locks held>`
54+
* Unlocking deep sleep: `UNLOCK: <file name>, ln: <line in file>, lock count: <number of locks held>`
55+
* Entering sleep: Mbed OS will print a list of locks preventing the board from entering a deep sleep:
56+
57+
```
58+
Sleep locks held:
59+
[id: <file name 1>, count: <number of locks>]
60+
[id: <file name 2>, count: <number of locks>]
61+
```
62+
63+
Example trace can look like:
64+
65+
```
66+
LOCK: mbed_rtx_idle.cpp, ln: 129, lock count: 2
67+
Sleep locks held:
68+
[id: mbed_wait_api_, count: 1]
69+
[id: mbed_rtx_idle., count: 1]
70+
UNLOCK: mbed_rtx_idle.cpp, ln: 131, lock count: 1
71+
LOCK: mbed_rtx_idle.cpp, ln: 129, lock count: 2
72+
Sleep locks held:
73+
[id: mbed_wait_api_, count: 1]
74+
[id: mbed_rtx_idle., count: 1]
75+
UNLOCK: mbed_rtx_idle.cpp, ln: 131, lock count: 1
76+
```
77+
78+
<span class="notes">**Note:** Sleep tracing is a debug feature and should only be enabled during development cycle. Its heavy use of UART can affect the device performance.</span>
79+
4780
### Function reference
4881

4982
[![View code](https://www.mbed.com/embed/?type=library)](http://os-doc-builder.test.mbed.com/docs/v5.7/mbed-os-api-doxy/mbed__sleep_8h_source.html)

0 commit comments

Comments
 (0)