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
For targets with Arm CoreSight (e.g. Cortex-M3 and Cortex-M4) the Instrumented Trace Macrocell provides a lightweight, non-intrusive way for collecting debug trace output.
4
+
5
+
#### Assumptions
6
+
7
+
* The target supports Arm CoreSight.
8
+
* The target has SWO connected either to a compatible interface chip or exposed as a debug pin.
9
+
10
+
##### Defined behavior
11
+
12
+
* Targets must implement the function `void itm_init(void)` and add `ITM` to the `device_has` section in `target.json`.
13
+
* When `void itm_init(void)` is called, the debug clock for the ITM must be initialized and the SWO pin configured for debug output.
14
+
*`void itm_init(void)` should only have to modify the clock pre-scaler in the generic register `TPI->ACPR`. The generic ITM registers will be initialized by the helper function `mbed_itm_init`.
15
+
*`void itm_init(void)` will only be called once during startup and doesn't have to be protected for multiple calls.
16
+
17
+
##### Undefined behavior
18
+
19
+
* The debug clock frequency is left undefined since the most optimal frequency will vary from target to target. It is up to each target's owner to pick a frequency that (a) doesn't interfere with normal operation and (b) is supported by the owner's preferred debug monitor.
20
+
21
+
#### Testing
22
+
23
+
The `SerialWireOutput` class can be used for sending `stdout` to the SWO stimulus port on the ITM by including this override function:
24
+
25
+
```
26
+
#include "SerialWireOutput.h"
27
+
28
+
FileHandle* mbed::mbed_override_console(int fd) {
29
+
static SerialWireOutput swo;
30
+
return &swo;
31
+
}
32
+
```
33
+
34
+
The function can be placed in any C++ compilation unit, including `main.cpp`.
0 commit comments