Fault Injection & Debugging
Testing CAN bus-off (TEC > 255) and unacked frames
Drive TEC past 255 deterministically and prove your CAN driver exits bus-off without rebooting the ECU.
A CAN controller enters bus-off after 32 unacknowledged transmit errors (TEC > 255). Unless ABOM is enabled or firmware clears FDCAN_CCCR.INIT, the node stays permanently silent even after the cable is plugged back in.
CircuitTwin injects exact drop_ack counts onto virtual CAN buses so CI verifies error-passive warnings, bus-off recovery timers and TX mailbox flushing on every commit.
CAN error states verified
| State | Counter threshold | Driver behavior tested |
|---|---|---|
Error Active | TEC/REC < 96 | Normal frame transmission and ACK |
Error Warning / Passive | TEC >= 96 / 128 | Warning interrupt fires; telemetry flags degraded link |
Bus-Off | TEC > 255 | Controller restarts cleanly after 128 x 11 recessive bits |
Local CLI workflow
Shell - run CAN bus-off recovery suite
ct test run --json --junit results/can-busoff.xml tests/can-busoff.suite.yamlSuite & fault configuration
tests/can-busoff.suite.yaml
version: 1
board: nucleo-h743zi2
firmware: build/can_ecu.elf
tests:
- name: fdcan-unacked-busoff-recovery
timeout_ms: 3000
faults:
- at_ms: 100
bus: FDCAN1
kind: drop_ack
count: 35
expect:
console_contains: "CAN_BUSOFF_RECOVERED"
exit_code: 0CI pipeline integration
.github/workflows/can-busoff.yml
name: CAN Bus-Off Recovery CI
on: [push, pull_request]
jobs:
can:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: circuittwin/action@v1
with:
suite: tests/can-busoff.suite.yamlTroubleshooting checklist
| Symptom | Fix |
|---|---|
| STM32H7 FDCAN never recovers from bus-off | FDCAN has no hardware ABOM bit like bxCAN; firmware must detect PSR.BO=1 and clear CCCR.INIT explicitly. |
| Stale frames flood the bus after reconnect | Abort pending TX mailboxes on bus-off before restarting transmission. |
Frequently asked questions
| Question | Answer |
|---|---|
| Does STM32H7 FDCAN have automatic bus-off recovery (ABOM) like bxCAN? | No. Unlike bxCAN (MCR.ABOM), Bosch M_CAN / STM32 FDCAN sets CCCR.INIT=1 on bus-off and requires software to clear INIT to start the 128x11 recessive-bit recovery sequence. |