Debian Codegraph @

docs/swo_swv.md

raw symbols SCIP
1 ---
2 title: SWO/SWV
3 ---
4
5 The Arm Cortex-M and CoreSight architectures support a single-wire trace output called Serial Wire Output (SWO).
6 This SWO trace feature can be used for everything from printf debugging to PC-sampling based profiling and various
7 performance measurements.
8
9 SWO supports two wire protocols, asynchronous UART and Manchester encoding, although in practise UART is used almost
10 exclusively. (SWO is also available as a standalone CoreSight component, but this is relatively rare.)
11
12 The Arm Cortex-M DWT and ITM core peripherals generate packets that can be output over SWO when a configurable set of
13 events occur. The combination of DWT/ITM packets transmitted via SWO is called the Serial Wire Viewer (SWV). A common
14 use case for SWV is printf-style log output, so much so that "SWV" has more or less come to mean exactly that.
15
16 The major features are:
17
18 - The gdbserver supports SWV printf-style log output to console or telnet, muxed with semihosting stdout.
19 - Raw SWO data can be served through a TCP port while the gdbserver is running, allowing other tools such as
20 [Orbuculum](https://github.com/orbcode/orbuculum) to process it.
21 - The Python API has a set of classes for building a trace event data flow graph.
22
23
24 ### SWO support
25
26 PyOCD supports SWO and SWV for those debug probes that support it. This includes CMSIS-DAP, J-Link, and STLink.
27
28 Be aware that even if a probe type supports SWO, the MCU (and its CPU) must also support SWO, and the board must route
29 the SWO signal from the MCU to the debug header. In a surprising number of cases, even for silicon vendor evaluation
30 kits, the probe and MCU support it but the signal simply wasn't routed.
31
32 Not all versions of the Arm M-profile architecture support SWO. The Arm v7-M and Arm v8-M Mainline architectures do
33 support SWO, while the Arm v6-M and Arm v8-M Baseline, architectures do not.
34
35
36 Core | Architecture | Supports SWO
37 ----------------|-------------------|--------------
38 Cortex-M0 | v6-M | -
39 Cortex-M0+ | v6-M | -
40 Cortex-M1 | v6-M | -
41 Cortex-M3 | v7-M | ✓
42 Cortex-M4 | v7-M | ✓
43 Cortex-M7 | v7-M | ✓
44 Cortex-M23 | v8.0-M Baseline | -
45 Cortex-M33 | v8.0-M Mainline | ✓
46 Cortex-M55 | v8.1-M Mainline | ✓
47 Cortex-M85 | v8.1-M Mainline | ✓
48
49
50
51 ### Configuration
52
53 If `enable_swv` is true, pyOCD will set up ITM and TPIU to output ITM stimulus ports over SWO at the specified baud
54 rate. Currently, [semihosting]({% link _docs/semihosting.md %}) must also be enabled for SWV to work, so the
55 `enable_semihosting` option must be on. A thread reads the data from the probe in the background and parses it.
56
57 The SWV stream from ITM port 0 will be output to the semihosting console (see the [Routing]({% link _docs/semihosting.md
58 %}#routing) section of the [semihosting documentation]({% link _docs/semihosting.md %})), which is either the telnet
59 server or stdout depending on the `semihost_console_type` option.
60
61
62
63
64 An example of running the gdbserver with SWV output is:
65
66 ```
67 pyocd gdb -S -Oenable_swv=1 -Oswv_system_clock=80000000 -Osemihost_console_type=console
68 ```
69
70 This will turn on semihosting and SWV with the default 1 MHz baud rate, an 80 MHz system clock, and output to stdout.
71
72
73 ### Session options
74
75 Several session options are used to control and configure SWV:
76
77 - `enable_swv` - Flag to enable SWV output.
78 - `swv_clock` - Optional baud rate for SWO, which defaults to 1 MHz if not set.
79 - `swv_system_clock` - Required system clock frequency. Used to compute TPIU baud rate divider.
80 - `swv_raw_enable` - Enable flag for the raw SWV stream server.
81 - `swv_raw_port` - TCP port number for the raw SWV stream server. The default port is 3443, which is the default port for the Orbuculum client.
82 - `swv_raw_file` - File path for the raw SWV stream output.