🛠 Bus CAN : exploiter les deux contrôleurs DCAN avec can-utils

BeagleBone Black (TI Sitara AM3358) · avance · Schéma : IMG-beaglebone-black-avance-3-bus-can-dcan-candump.svg — deux BeagleBone Black reliées par un bus CAN différentiel (CAN_H, CAN_L, résistance de terminaison 120 Ω de chaque côté), transceivers SN65HVD230 sur les broches P8_17/P8_18.

Objectives

The AM335x embeds TWO CAN controllers (DCAN) — a massive industrial argument compared to consumer-grade boards. You will expose CAN0 on pins P8_17/P8_18 (the MCASP0 pins muxed to DCAN by the community overlay KCP-0001), configure the interface with ip link, and exchange frames using can-utils between two nodes.

Hardware

Complete code

sudo apt install can-utils device-tree-compiler

# Exposer CAN0 sur P8_17/P8_18 :
# - ancienne image : overlay KCP-0001 via le capemanager
echo cape_can | sudo tee /sys/devices/platform/bone_capemanager/slots
# - image récente : l'overlay est embarqué (KCP-0001) ou chargé via configfs
ls /sys/class/net/          # can0 doit apparaître

# Configurer l'interface (impérativement interface DOWN pour changer le débit)
sudo ip link set can0 down
sudo ip link set can0 type can bitrate 500000
sudo ip link set can0 up
ip -details link show can0

# Émettre / écouter
candump can0 &
cansend can0 123#DEADBEEF

# Test seul sur une carte : activer le loopback interne
sudo ip link set can0 down
sudo ip link set can0 type can bitrate 500000 loopback true
sudo ip link set can0 up
cansend can0 321#CAFEBABE && candump -n 1 can0

Expected verification

In loopback mode, candump receives the frame 321#CAFEBABE sent by cansend. On a two-board bus, cansend on one board makes the frame appear in candump on the other; ip -details shows the active bitrate of 500000 and the interface in UP state.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials