RTOS & Firmware Stacks

Multi-node CANopen testing without a bus bench

Run two real MCU ELF images on a shared virtual CAN bus in one deterministic scene—then inject ACK errors, dropped heartbeats or bus-off states.

CANopen bugs rarely show up on a single node in loopback mode. Real failures happen between nodes: NMT boot-up races, SDO abort codes, heartbeat consumer timeouts and bus-off recovery after a shorted transceiver.

CircuitTwin scenes wire multiple compiled MCU binaries onto a shared CAN/CAN-FD link with bit-level arbitration and deterministic fault injection so your CI suite tests the full multi-ECU network.

Multi-node CANopen scene matrix

ScenarioFault injectedAssertion
NMT boot & PDO exchangeNone (nominal)Master sees Node 2 Operational + RPDO updated
Heartbeat timeoutDisconnect Node 2 CAN link at 500 msMaster triggers EMCY 0x8130 heartbeat error
Bus-off recoveryInject consecutive TX ACK errorsNode enters bus-off, recovers cleanly after 128x11 recessive bits
Mismatched bit timingAlter prescaler on one nodeError frame counter increments and faults cleanly

Local CLI workflow

Shell — run two-node CANopen scene
ct scene run --json scenes/canopen-two-node.scene.json
ct test run --json --junit results/canopen.xml tests/canopen.suite.yaml

Suite & fault configuration

tests/canopen.suite.yaml
version: 1
scene: scenes/canopen-two-node.scene.json
tests:
  - name: heartbeat-loss-emcy
    timeout_ms: 4000
    faults:
      - at_ms: 1200
        link: can0
        node: slave_ecu
        kind: disconnect
        duration_ms: 1500
    expect:
      node: master_ecu
      console_contains: "EMCY_HEARTBEAT_LOST"
      exit_code: 0

CI pipeline integration

.github/workflows/canopen-ci.yml
name: CANopen Multi-Node CI
on: [push, pull_request]
jobs:
  canopen:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: cmake --build build --target master_ecu slave_ecu
      - uses: circuittwin/action@v1
        with:
          suite: tests/canopen.suite.yaml
          junit-out: results/canopen.xml

CANopenNode PDO, SDO and NMT multi-node CI

Wire master and slave CANopenNode ELFs onto one virtual CAN bus and inject heartbeat drops or ACK errors without a bench.

Loopback mode validates one CAN controller talking to itself. Real CANopen bugs happen between two nodes: misaligned PDO COB-IDs, wrong sample points and missed NMT heartbeat guard timeouts.

CircuitTwin multi-board scenes run two compiled binaries (STM32 bxCAN/FDCAN or NXP FlexCAN) in lockstep virtual time on a shared CAN medium.

CANopenNode protocol checks

ServiceCOB-ID rangeFault injected
NMT Heartbeat0x700 + NodeIDDrop slave TX frames to verify master heartbeat consumer timeout
SDO Client/Server0x600 / 0x580 + NodeIDInject invalid object index to verify SDO abort code 0x06020000
TPDO / RPDO0x180..0x57FVerify synchronous PDO update on SYNC (0x080) trigger
Shell - run two-node CANopen scene
ct scene run --json --junit results/canopen.xml scenes/canopen-two-node.scene.json
tests/canopen-heartbeat.suite.yaml
version: 1
scene: scenes/canopen-two-node.scene.json
tests:
  - name: heartbeat-consumer-timeout
    timeout_ms: 4000
    faults:
      - at_ms: 1000
        bus: can0
        node: slave_ecu
        kind: mute_tx
        duration_ms: 1500
    expect:
      console_contains: "HB_TIMEOUT_NODE_2"
      exit_code: 0

Troubleshooting checklist

SymptomFix
Nodes never see each other’s framesVerify both ELFs agree on nominal bitrate and sample point (use the CAN Bit Timing Calculator) and check acceptance filter masks.
STM32 bxCAN stays in sleep/init modeClear MCR.SLEEP before setting MCR.INRQ and confirm GPIO AF9 CAN_RX/TX pins are enabled.
FDCAN message RAM corrupts RX FIFOCheck message RAM element offsets when mixing 8-byte classic CAN and 64-byte CAN-FD frames.
Bus-off node never rejoinsEnable ABOM (Automatic Bus-Off Management) or handle BOFF interrupt explicitly in your CANopen driver.
Nodes never exchange frames on virtual CAN busConfirm both binaries program the exact same bitrate in CAN_BTR / FDCAN_NBTP using the CAN Bit Timing Calculator.
Controller stays stuck in INIT modeVerify CAN1 clock is enabled before CAN2 on dual-CAN STM32F4/F7 chips.

Frequently asked questions

QuestionAnswer
Can a single scene mix an STM32H7 FDCAN node and an NXP S32K144 FlexCAN node?Yes. CircuitTwin scenes connect heterogeneous MCUs onto one virtual CAN or CAN-FD bus so mixed-vendor ECU networks run in CI.

Related boards & component twins

More in RTOS & Firmware Stacks