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

ChannelMCU overheadBest use
UART consoleLow (baud limited)Standard printf, Zephyr shell, NSH
SEGGER RTTMicrosecond SRAM ring writeRust defmt, high-rate ISR logging
ITM / SWO Port 0Single register write to 0xE0000000Minimal-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

SymptomFix
ITM writes silently drop charactersEnable CoreDebug->DEMCR |= TRCENA, ITM->LAR = 0xC5ACCE55 and ITM->TER |= 1.
RTT buffer overflows on burst logsIncrease BUFFER_SIZE_UP in SEGGER_RTT_Conf.h from 1024 to 4096 bytes.

Frequently asked questions

QuestionAnswer
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

More in Fault Injection & Debugging