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
| Cause | Diagnostic clue | Clean resolution |
|---|---|---|
Unused init peripheral | Access inside MX_USB_OTG_Init() during sensor test | Guard unused USB/Wi-Fi init out of non-RF test build |
Missing SVD companion | Register exists in datasheet but omitted from minimal SVD | Regenerate MCU twin with vendor CMSIS header or RM companion |
Out-of-bounds pointer | Random address in peripheral space | Real 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: 0CI 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.yamlTroubleshooting checklist
| Symptom | Fix |
|---|---|
| Exit code 4 points to a strange address like 0x4002FFFF | Resolve the reported PC with arm-none-eabi-addr2line -e build/app.elf to check for a wild pointer bug. |
Frequently asked questions
| Question | Answer |
|---|---|
| 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. |