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 class | Why benches hide it | How --recheck catches it |
|---|---|---|
Missing .bss zero loop | Debugger pre-zeroes SRAM on load | Divergent state across clean twin boots |
ISR/main shared global | Slow manual stepping masks race | Exact instruction-level replay exposes race |
Unseeded PRNG in test | Passes 9 of 10 bench runs | Pinned 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.yamlSuite & 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: 0CI 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
| Symptom | Fix |
|---|---|
| Firmware reads garbage after soft reset | Verify Reset_Handler zeroes the full range from _sbss to _ebss before calling main(). |
| ISR counter skips increments occasionally | Use atomic LDREX/STREX or critical-section PRIMASK guards around read-modify-write counters. |
Frequently asked questions
| Question | Answer |
|---|---|
| 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. |