Skip to content

Stable CAN Channel Naming

Channel binding gives Linux CAN interfaces stable and predictable names after rebooting or reconnecting devices. The SDK supports driver-based naming, physical USB-port binding and device-ID binding.

Driver-Based Naming

Run:

bash
sudo ./build.sh -rules

The script creates /etc/udev/rules.d/99-kcan-driver.rules, matches DRIVERS=="kcan" and assigns names such as kcan0, kcan1 and so on. Reconnect the USB device after applying the rule.

bash
ip link show | grep kcan

Driver-based binding

Advantages: simple setup.
Best for: small installations without a fixed channel-to-device mapping.
Limitation: numbering can change with enumeration order.

Physical USB-Port Binding

This method uses the USB topology path to bind one physical port to a fixed interface name.

1. Find the Topology Path

bash
udevadm info -a -p /sys/class/net/can0

udevadm output

2. Create a udev Rule

bash
sudo vi /etc/udev/rules.d/99-kcan-usb.rules

Example:

udev
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="kcan", \
    KERNELS=="5-1.3:1.0", \
    ATTR{dev_id}=="0x0", \
    NAME="kcan0"

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="kcan", \
    KERNELS=="5-1.4:1.0", \
    ATTR{dev_id}=="0x0", \
    NAME="kcan1"
  • KERNELS is the physical USB path.
  • DRIVERS=="kcan" limits the rule to the KCAN driver.
  • NAME is the target network-interface name.

3. Reload and Verify

bash
sudo udevadm control --reload-rules
sudo udevadm trigger --subsystem-match=net --action=add
ip link show kcan0 kcan1

USB-port binding

This is reliable for fixed installations, but moving a device to another physical USB port requires a rule update.

Device-ID Binding

Device-ID binding stores a unique numeric ID in the hardware and lets the driver assign names from that ID. It is independent of USB position and enumeration order.

1. Assign IDs

bash
# First device
kcan-settings -f=/dev/kcanusbfd32 -d 66

# Second device
kcan-settings -f=/dev/kcanusbfd33 -d 67

Use IDs from 1 to 255, keep them unique within one system, and document the assignment.

2. Verify an ID

bash
kcan-settings -f=/dev/kcanusbfd32 -d

3. Enable ID-Based Assignment

Edit /etc/modprobe.d/kcan.conf:

text
options kcan assign=devid

Reload the module:

bash
sudo rmmod kcan
sudo modprobe kcan

Reconnect the devices and verify the resulting interfaces.

Device-ID binding

Driving Intelligent Connections, Empowering the Future