You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/api/platform/PowerManagement.md
+33Lines changed: 33 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,39 @@ These Mbed OS drivers can lock the deep sleep:
40
40
-`CAN`.
41
41
-`SerialBase`.
42
42
43
+
#### Sleep tracing
44
+
45
+
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.
46
+
47
+
Mbed OS will print sleep traces on the standard output, which by default is UART. Some of the events that we track:
48
+
49
+
* Locking deep sleep: `LOCK: <file name>, ln: <line in file>, lock count: <number of locks held>`
50
+
* Unlocking deep sleep: `UNLOCK: <file name>, ln: <line in file>, lock count: <number of locks held>`
51
+
* Entering sleep: Mbed OS will print a list of locks preventing the board from entering a deep sleep:
52
+
53
+
```
54
+
Sleep locks held:
55
+
[id: <file name 1>, count: <number of locks>]
56
+
[id: <file name 2>, count: <number of locks>]
57
+
```
58
+
59
+
Example trace can look like:
60
+
61
+
```
62
+
LOCK: mbed_rtx_idle.cpp, ln: 129, lock count: 2
63
+
Sleep locks held:
64
+
[id: mbed_wait_api_, count: 1]
65
+
[id: mbed_rtx_idle., count: 1]
66
+
UNLOCK: mbed_rtx_idle.cpp, ln: 131, lock count: 1
67
+
LOCK: mbed_rtx_idle.cpp, ln: 129, lock count: 2
68
+
Sleep locks held:
69
+
[id: mbed_wait_api_, count: 1]
70
+
[id: mbed_rtx_idle., count: 1]
71
+
UNLOCK: mbed_rtx_idle.cpp, ln: 131, lock count: 1
72
+
```
73
+
74
+
<spanclass="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>
0 commit comments