> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# ITM and SWO

> Read Cortex-M ITM stimulus output over SWO with OpenOCD and a supported ST-Link, DAPLink, LPC-Link2, or MCU-Link probe.

Use ITM over SWO to read software stimulus messages from a Cortex-M target. This connection is read-only: it shows firmware output and doesn't send input to the target. Use [UART](/docs/debug-mode/uart.md) or [RTT](/docs/debug-mode/rtt.md) when you also need to send commands.

## Prepare

1. Confirm that the MCU exposes ITM/SWO and that the board routes SWO to the probe connector.
2. Connect target ground, the debug interface, and SWO using the board and probe pinouts. A working SWD connection doesn't show that SWO is wired.
3. Install [OpenOCD](/docs/debug-mode/openocd.md) on the computer running Inlay.
4. Connect a supported SWO probe to that computer: ST-Link/V1, ST-Link/V2, ST-Link/V2-1, ST-Link/V3, DAPLink, NXP LPC-Link2, or NXP MCU-Link.
5. Build firmware that enables the trace path and writes to the ITM stimulus ports you plan to read. End each channel 0 text line with `\n`.
6. Note the CPU clock while the firmware logs, and the SWO rate it configures.

The ITM entry appears in the **Port** list only when OpenOCD is installed and one of these probes is connected. The entry shows the probe name followed by **ITM**, such as **ST-Link/V2-1 ITM**. A listed entry doesn't confirm the board's SWO wiring or the firmware's trace setup.

## Configure and connect

In the terminal UI, run `/monitor` to follow these steps in a browser, or use the serial sidebar. See [Use the terminal UI](/docs/debug-mode/serial-transports.md#use-the-terminal-ui).

1. Open a **Serial Monitor** tab. See [Open a Serial Monitor tab](/docs/debug-mode/serial-transports.md#open-a-serial-monitor-tab).
2. Select the port chip at the start of the toolbar, then choose the ITM entry under **Port**. The **SWO trace** settings appear below the list.
3. Select **Target** and choose the OpenOCD target configuration for your MCU, such as `stm32f4x`. A star marks the suggested target.
4. Enter the CPU clock in MHz in **CPU**. It has no default.
5. Enter the SWO rate in MHz in **SWO**. The default is 2.
6. Select **Connect**.

Both clock values must be greater than 0, and the SWO rate can't exceed the CPU clock. Use the clocks the firmware actually runs at.

If no debugger server is running, connecting starts OpenOCD with ITM enabled, and the tab shows `Starting OpenOCD with ITM...`. If a debugger server is already running without ITM, the connection fails; stop that server and connect again. Review the [attachment precautions](/docs/debug-mode/gdb.md#attach-to-a-running-target) when target state matters.

You can also ask Inlay to capture ITM output. Give the clocks and target that match your firmware:

```text theme={"theme":"css-variables"}
Monitor the ITM port for five seconds using a 168 MHz CPU clock, 2 MHz SWO,
and the stm32f4x OpenOCD target. Report the captured stimulus output.
```

To capture boot output, give Inlay a probe reset command. DTR and RTS resets don't apply to ITM.

## Interpret the output

| Stimulus port | How it appears |
| - | - |
| Channel 0 | Text lines prefixed with `ch0: `. A line appears only after the firmware sends `\n`. |
| Channels 1 to 31 | Uppercase hexadecimal bytes with the channel number, such as `ch1: DE AD BE EF`. Message boundaries aren't preserved, so use your firmware's channel definitions to reassemble them. |

The view shows only software stimulus output. It doesn't show ITM timestamps or hardware trace, such as DWT event counters, exception trace, PC sampling, or data trace, so it isn't a complete event or instruction trace. See [Coverage and trace](/docs/debug-mode/coverage-and-trace.md) for the trace workflows Inlay supports.

## Troubleshoot

* **No ITM entry in Port:** install OpenOCD and connect a supported probe to the computer running Inlay.
* **Target can't be selected:** no supported SWO probe is detected.
* **`Configure OpenOCD target to use ITM`:** choose a **Target** before you connect.
* **`Enter CPU frequency to use ITM`:** enter the active CPU clock in **CPU**.
* **`SWO must not exceed CPU frequency`:** lower **SWO** or correct **CPU**.
* **`ITM port not available. Ensure OpenOCD is configured for ITM.`:** a debugger server is running without ITM. Stop it, then connect again.
* **Connected but silent:** check SWO wiring, trace initialization, enabled stimulus ports, and that the firmware is producing output.
* **Channel 0 text is missing its last line:** the firmware hasn't sent the final `\n`.
* **Text is corrupt after a clock change:** update **CPU** and **SWO** to match the firmware.
* **No send box:** ITM is read-only. Use [UART](/docs/debug-mode/uart.md) or [RTT](/docs/debug-mode/rtt.md) for firmware input.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.