Compliance & Verification
Pairing MISRA C static checks with runtime ELF fault CI
Static analysis checks C syntax and undefined behavior. Digital twin CI catches wrong register masks, unclocked buses and sensor hangs.
A 100% MISRA-clean C file can still write the wrong bit position to I2C1->CR1, omit an NVIC enable, or spin forever when a temperature sensor pulls a NACK.
Running static analysis and CircuitTwin ELF execution side by side in the same pull-request workflow covers both language safety and real hardware interaction.
Static analysis vs runtime twin coverage
| Bug class | MISRA C static check | CircuitTwin ELF run |
|---|---|---|
Implicit narrowing / null deref | Caught at compile time | Also traps if reached at runtime |
Wrong RCC clock or BRR divider | Invisible to static analyzer | Caught immediately on peripheral bus |
Sensor NACK infinite loop | Looks like valid while() loop | Caught deterministically by fault timeout |
Local CLI workflow
Shell - run static check then twin fault suite
cppcheck --addon=misra --error-exitcode=1 src/
make -j && ct test run --json --junit results/runtime.xml tests/faults.suite.yamlSuite & fault configuration
tests/faults.suite.yaml
version: 1
board: nucleo-f411re
firmware: build/app.elf
tests:
- name: misra-compliant-driver-nack-bound
timeout_ms: 2000
faults:
- at_ms: 50
bus: I2C1
kind: nack
address: 0x18
count: 10
expect:
console_contains: "BOUNDED_RETRY_EXIT"
exit_code: 0CI pipeline integration
.github/workflows/misra-plus-twin.yml
name: MISRA C + Twin Fault CI
on: [push, pull_request]
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cppcheck --addon=misra --error-exitcode=1 src/
- run: make -j
- uses: circuittwin/action@v1
with:
suite: tests/faults.suite.yamlTroubleshooting checklist
| Symptom | Fix |
|---|---|
| Bounded retry loop still hangs in CI | Verify the loop counter increments on every I2C error flag and clears the peripheral AF/BERR status bit. |
Frequently asked questions
| Question | Answer |
|---|---|
| Does CircuitTwin require extra annotations in MISRA C code? | No. Compile your MISRA C codebase unmodified and run the resulting ELF directly. |