Fault Injection & Debugging

Triaging exit code 4 unmodelled-register diagnostics

Silent zero-reads turn real bugs into false green builds. Exit code 4 tells you the exact peripheral, register address and PC.

Many simulators return 0x00000000 for any peripheral register they have not implemented. Firmware then appears to pass in CI while failing on silicon.

CircuitTwin treats every unmodelled MMIO access as inconclusive (exit code 4) by default and prints the exact register name, address and program counter in JSON so you can resolve it explicitly.

Exit code 4 triage options

CauseDiagnostic clueClean resolution
Unused init peripheralAccess inside MX_USB_OTG_Init() during sensor testGuard unused USB/Wi-Fi init out of non-RF test build
Missing SVD companionRegister exists in datasheet but omitted from minimal SVDRegenerate MCU twin with vendor CMSIS header or RM companion
Out-of-bounds pointerRandom address in peripheral spaceReal firmware bug caught! Inspect PC in GDB

Local CLI workflow

Shell - inspect exact unmodelled register in JSON
ct run --json --board nucleo-f767zi build/app.elf | jq '.unmodelled'

Suite & fault configuration

tests/strict-mode.suite.yaml
version: 1
board: nucleo-f767zi
firmware: build/app.elf
tests:
  - name: zero-unmodelled-register-gate
    timeout_ms: 2500
    expect:
      console_contains: "APP_OK"
      exit_code: 0

CI pipeline integration

.github/workflows/strict-exit4.yml
name: Strict Unmodelled-Register Gate
on: [push, pull_request]
jobs:
  strict:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: circuittwin/action@v1
        with:
          suite: tests/strict-exit4.suite.yaml

Troubleshooting checklist

SymptomFix
Exit code 4 points to a strange address like 0x4002FFFFResolve the reported PC with arm-none-eabi-addr2line -e build/app.elf to check for a wild pointer bug.

Frequently asked questions

QuestionAnswer
Why does CircuitTwin fail with exit code 4 instead of returning zero for unmodelled registers?Returning zero silently creates false-positive CI passes. Failing explicitly with exit code 4 guarantees you always know the exact boundary of what was simulated.

Related boards & component twins

More in Fault Injection & Debugging