Fault Injection & Debugging

# Capturing SEGGER RTT and ITM/SWO logs in headless CI

Read SEGGER RTT and ARM ITM/SWO telemetry directly from twin SRAM and core trace registers in CI.

Low-pin-count boards often lack a spare UART for debug logging, so firmware writes logs into a SEGGER RTT control block in SRAM or Cortex-M ITM->PORT\[0\].

CircuitTwin reads UART consoles alongside RTT/ITM streams so your Rust defmt or C SEGGER\_RTT\_printf() assertions gate pull requests with zero pin overhead.

## Logging channels compared

| Channel          | MCU overhead                        | Best use                                         |
| ---------------- | ----------------------------------- | ------------------------------------------------ |
| UART console     | Low (baud limited)                  | Standard printf, Zephyr shell, NSH               |
| SEGGER RTT       | Microsecond SRAM ring write         | Rust defmt, high-rate ISR logging                |
| ITM / SWO Port 0 | Single register write to 0xE0000000 | Minimal-footprint Cortex-M3/M4/M7/M33 debug logs |

## Local CLI workflow

Shell - run ELF and capture console / RTT logs

```
ct run --json --board nrf52840-dk build/defmt_app.elf
```

## Suite & fault configuration

tests/rtt-logging.suite.yaml

```
version: 1
board: nrf52840-dk
firmware: build/rtt_app.elf
tests:
  - name: rtt-boot-marker-check
    timeout_ms: 2000
    expect:
      console_contains: "RTT_BOOT_OK"
      exit_code: 0
```

## CI pipeline integration

.github/workflows/rtt-ci.yml

```
name: RTT Logging CI
on: [push, pull_request]
jobs:
  rtt:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: circuittwin/action@v1
        with:
          suite: tests/rtt-logging.suite.yaml
```

## Troubleshooting checklist

| Symptom                             | Fix                                                                         |
| ----------------------------------- | --------------------------------------------------------------------------- |
| ITM writes silently drop characters | Enable CoreDebug->DEMCR \|= TRCENA, ITM->LAR = 0xC5ACCE55 and ITM->TER \|= 1. |
| RTT buffer overflows on burst logs  | Increase BUFFER\_SIZE\_UP in SEGGER\_RTT\_Conf.h from 1024 to 4096 bytes.   |

## Frequently asked questions

| Question                               | Answer                                                                                                                              |
| -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| Does Cortex-M0 or M0+ support ITM/SWO? | No. ITM/SWO exists only on Cortex-M3, M4, M7 and M33\. Use UART or SEGGER RTT on Cortex-M0/M0+ boards like NUCLEO-F091RC or RP2040. |

## Related boards & component twins

[Board: nrf52840-dk](https://circuittwin.ai/boards/nrf52840-dk) [Board: nucleo-f767zi](https://circuittwin.ai/boards/nucleo-f767zi) [Board: nucleo-l552ze](https://circuittwin.ai/boards/nucleo-l552ze) [Twin: BME280](https://circuittwin.ai/twins/bme280) [Twin: SHT40](https://circuittwin.ai/twins/sht40) [ct CLI options](https://circuittwin.ai/docs/cli)

## More in Fault Injection & Debugging

[I2C NACK and stuck-bus fault injection in CI](https://circuittwin.ai/guides/i2c-nack-fault-injection) [SPI bus fault testing and chip-select verification](https://circuittwin.ai/guides/spi-bus-fault-testing) [Debugging UART baud mismatches and framing errors](https://circuittwin.ai/guides/uart-baud-mismatch-debugging) [Cortex-M HardFault triage in CI and reverse GDB](https://circuittwin.ai/guides/cortex-m-hardfault-ci-triage)

> ## Run this workflow on your own ELF
>
> Start free on CircuitTwin to run local board twins, fault matrices and CI checks with zero per-run credits.
>
> [Start now](https://app.circuittwin.ai/try) [Read the quickstart](https://circuittwin.ai/docs/quickstart) [Connect a coding agent](https://circuittwin.ai/docs/agents)
