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
| Scenario | Fault injected | Assertion |
|---|---|---|
NMT boot & PDO exchange | None (nominal) | Master sees Node 2 Operational + RPDO updated |
Heartbeat timeout | Disconnect Node 2 CAN link at 500 ms | Master triggers EMCY 0x8130 heartbeat error |
Bus-off recovery | Inject consecutive TX ACK errors | Node enters bus-off, recovers cleanly after 128x11 recessive bits |
Mismatched bit timing | Alter prescaler on one node | Error frame counter increments and faults cleanly |
Local CLI workflow
ct scene run --json scenes/canopen-two-node.scene.json
ct test run --json --junit results/canopen.xml tests/canopen.suite.yamlSuite & fault configuration
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: 0CI pipeline integration
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.xmlCANopenNode 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
| Service | COB-ID range | Fault injected |
|---|---|---|
NMT Heartbeat | 0x700 + NodeID | Drop slave TX frames to verify master heartbeat consumer timeout |
SDO Client/Server | 0x600 / 0x580 + NodeID | Inject invalid object index to verify SDO abort code 0x06020000 |
TPDO / RPDO | 0x180..0x57F | Verify synchronous PDO update on SYNC (0x080) trigger |
ct scene run --json --junit results/canopen.xml scenes/canopen-two-node.scene.jsonversion: 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: 0Troubleshooting checklist
| Symptom | Fix |
|---|---|
| Nodes never see each other’s frames | Verify 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 mode | Clear MCR.SLEEP before setting MCR.INRQ and confirm GPIO AF9 CAN_RX/TX pins are enabled. |
| FDCAN message RAM corrupts RX FIFO | Check message RAM element offsets when mixing 8-byte classic CAN and 64-byte CAN-FD frames. |
| Bus-off node never rejoins | Enable ABOM (Automatic Bus-Off Management) or handle BOFF interrupt explicitly in your CANopen driver. |
| Nodes never exchange frames on virtual CAN bus | Confirm both binaries program the exact same bitrate in CAN_BTR / FDCAN_NBTP using the CAN Bit Timing Calculator. |
| Controller stays stuck in INIT mode | Verify CAN1 clock is enabled before CAN2 on dual-CAN STM32F4/F7 chips. |
Frequently asked questions
| Question | Answer |
|---|---|
| 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. |