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

StateCounter thresholdDriver behavior tested
Error ActiveTEC/REC < 96Normal frame transmission and ACK
Error Warning / PassiveTEC >= 96 / 128Warning interrupt fires; telemetry flags degraded link
Bus-OffTEC > 255Controller 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.yaml

Suite & 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: 0

CI 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.yaml

Troubleshooting checklist

SymptomFix
STM32H7 FDCAN never recovers from bus-offFDCAN has no hardware ABOM bit like bxCAN; firmware must detect PSR.BO=1 and clear CCCR.INIT explicitly.
Stale frames flood the bus after reconnectAbort pending TX mailboxes on bus-off before restarting transmission.

Frequently asked questions

QuestionAnswer
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.

Related boards & component twins

More in Fault Injection & Debugging