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

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

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

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

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

## Related boards & component twins

[Board: nucleo-f767zi](https://circuittwin.ai/boards/nucleo-f767zi) [Board: nucleo-h743zi2](https://circuittwin.ai/boards/nucleo-h743zi2) [Board: nucleo-f446re](https://circuittwin.ai/boards/nucleo-f446re) [Board: teensy-4-1](https://circuittwin.ai/boards/teensy-4-1) [Board: s32k144-evb](https://circuittwin.ai/boards/s32k144-evb) [Board: s32k344-evb](https://circuittwin.ai/boards/s32k344-evb) [Twin: INA226](https://circuittwin.ai/twins/ina226) [Twin: BMI088](https://circuittwin.ai/twins/bmi088) [Twin: MCP2515](https://circuittwin.ai/twins/mcp2515) [Twin: TJA1051](https://circuittwin.ai/twins/tja1051) [Twin: SN65HVD230](https://circuittwin.ai/twins/sn65hvd230) [Multi-board scenes](https://circuittwin.ai/docs/scenes) [Scene format reference](https://circuittwin.ai/docs/scene-sections)

## More in RTOS & Firmware Stacks

[Zephyr RTOS CI without hardware benches](https://circuittwin.ai/guides/zephyr-rtos-ci-without-hardware) [FreeRTOS headless testing in CI](https://circuittwin.ai/guides/freertos-headless-testing) [ESP-IDF CI simulation for ESP32, S3 & C3](https://circuittwin.ai/guides/esp-idf-ci-simulation) [PX4 Pixhawk 6C simulation on real ARM ELF](https://circuittwin.ai/guides/px4-pixhawk-6c-simulation)

> ## Run this workflow on your own ELF
>
> Start free on CircuitTwin to run local board twins, fault matrices and CI checks with zero per-run credits.
>
> [Start now](https://app.circuittwin.ai/try) [Read the quickstart](https://circuittwin.ai/docs/quickstart) [Connect a coding agent](https://circuittwin.ai/docs/agents)
