Fault Injection & Debugging

Catching uninitialized SRAM and nondeterminism with --recheck

Flaky firmware tests hide real silicon bugs. Run --recheck in CI to verify every test trace is bit-for-bit reproducible.

A local variable left uninitialized on the stack or a buffer outside .bss often happens to read zero on one debugger session and crashes in production after a warm reset.

CircuitTwin runs with deterministic virtual clocks and provides --recheck to execute your suite twice and fail immediately if console output or exit state diverges.

Nondeterminism bugs caught by --recheck

Bug classWhy benches hide itHow --recheck catches it
Missing .bss zero loopDebugger pre-zeroes SRAM on loadDivergent state across clean twin boots
ISR/main shared globalSlow manual stepping masks raceExact instruction-level replay exposes race
Unseeded PRNG in testPasses 9 of 10 bench runsPinned seed vs --recheck flags drift immediately

Local CLI workflow

Shell - run deterministic double-check
ct test run --json --recheck --junit results/det.xml tests/app.suite.yaml

Suite & fault configuration

tests/app.suite.yaml
version: 1
board: nucleo-f767zi
firmware: build/app.elf
tests:
  - name: deterministic-control-loop
    seed: 1337
    timeout_ms: 2500
    expect:
      console_contains: "LOOP_CHECKSUM_OK"
      exit_code: 0

CI pipeline integration

.github/workflows/determinism-ci.yml
name: Determinism Recheck CI
on: [push, pull_request]
jobs:
  recheck:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: make -j
      - uses: circuittwin/action@v1
        with:
          suite: tests/app.suite.yaml
          args: "--recheck"

Troubleshooting checklist

SymptomFix
Firmware reads garbage after soft resetVerify Reset_Handler zeroes the full range from _sbss to _ebss before calling main().
ISR counter skips increments occasionallyUse atomic LDREX/STREX or critical-section PRIMASK guards around read-modify-write counters.

Frequently asked questions

QuestionAnswer
What does ct test run --recheck do?It executes the test suite twice and compares verdicts and deterministic outputs to guarantee your test does not depend on host scheduling or uninitialized state.

Related boards & component twins

More in Fault Injection & Debugging