Skip to main content

CAN Network Configuration and ID Search

This article covers CAN network configuration, CAN0 status confirmation, CAN UUID search, and common CAN error troubleshooting.

Applicable Scenarios:

  • Connecting a CAN toolboard using a USB-to-CAN module like UTOC.
  • Connecting a CAN toolboard using a motherboard flashed with USB-to-CAN bridge firmware.
  • Searching for a CAN UUID after the motherboard or toolboard has been flashed with CAN firmware.
  • Klipper reporting errors related to CAN0, CAN UUID, or the CAN network.

Precautions Before Use

  1. Connect the UTOC or the motherboard flashed with CAN bridge firmware to the host machine via USB.
  2. Log in to the host machine's backend via the network, not via serial port.
  3. The FlyOS-FAST system presets CAN0 with a 1M rate and 1024 buffer; manual configuration of CAN0 is generally not required.
  4. The CAN rate in the toolboard and motherboard firmware must match the CAN0 rate of the host machine.
  5. Termination resistors are required at both ends of the CAN bus. Issues with wiring sequence, resistors, and power supply can all prevent ID searches.

CAN Wiring and Termination Resistors

Wiring and termination resistors are the most common sources of problems in a CAN network.

Power Off Before Operation

Before checking the CAN-H/CAN-L wiring sequence, connectors, crimping, termination resistor jumpers, or DIP switches, completely shut down the printer and disconnect the power supply. Do not plug or unplug CAN wires, adjust jumper caps, or measure resistance while the device is powered on.

Wiring Check

  1. After power-off, confirm that CAN-H is connected to CAN-H and CAN-L is connected to CAN-L.
  2. After power-off, inspect the CAN wires, connectors, and crimping positions to ensure there are no broken wires, loose connections, or poor contact.
  3. If using a UTOC, use a functional USB data cable to connect it to the host machine.
  4. If using a USB-to-CAN bridge motherboard, confirm that the motherboard has been flashed with the USB-to-CAN bridge firmware.
  5. Reassemble the wiring harness and casing before powering on to confirm whether the CAN device is recognized by the system.

Termination Resistor Check

A 120Ω termination resistor is required at each end of the CAN bus. With the entire machine completely powered off, use a multimeter to measure the resistance between CAN-H and CAN-L.

Measured ValueDiagnosis
Approximately 60ΩNormal, both termination resistors are correctly connected
Approximately 120ΩUsually indicates only one end has a termination resistor, or there is a broken wire
Approximately 40ΩPossible extra termination resistor; check intermediate nodes
Approximately 140ΩPossible CAN-H / CAN-L reversed or line anomaly
Note

Measurement of termination resistors must be performed with the device completely powered off. Operating without complete power-off may lead to inaccurate readings and could potentially damage the equipment.

Check if the Host Machine Supports CAN

FLY host machines can skip this step.

Execute the following command to check kernel CAN support:

sudo modprobe can && echo "Kernel supports CAN" || echo "Kernel does not support CAN"

If "Kernel supports CAN" is displayed, you can proceed with configuration. If it shows unsupported, it is recommended to switch to a system image that supports SocketCAN first.

Check if the CAN Device is Recognized

Before configuring or searching for a CAN ID, it is recommended to first confirm that the host machine has recognized the UTOC or USB-to-CAN bridge device.

Execute:

lsusb

Result Interpretation:

  • Seeing 1d50:606f: The device is recognized by the system. You can proceed to configure or search for the CAN ID.
  • Prompt "lsusb" not found: Install usbutils first.
  • Not seeing 1d50:606f: Check the USB cable, UTOC, USB-to-CAN bridge firmware, and power supply.
  • Multiple 1d50:606f entries: It is recommended to keep only one CAN bridge device active to avoid multiple CAN0 sources.

Install usbutils:

sudo apt-get update
sudo apt-get install usbutils
Note

Only after the system recognizes the CAN bridge device will subsequent CAN0 configuration and CAN ID searches be meaningful.

Configure CAN0

Note

This operation will overwrite the existing CAN0 configuration. A system reboot is required after completion. FlyOS-FAST system users do not need to perform this step.

Determine Network Management Method

Different systems use different network management methods. Before configuring CAN0, you should first confirm which service manages the network on the current system. Do not use multiple methods simultaneously to configure the same can0, as this may lead to configuration not taking effect, loss after reboot, or abnormal CAN0 status.

Execute the following command to check common network service statuses:

systemctl is-active NetworkManager
systemctl is-active systemd-networkd
systemctl is-active networking

You can also check configuration files and device status:

ls /etc/network/interfaces /etc/network/interfaces.d/ 2>/dev/null
networkctl list 2>/dev/null
nmcli device status 2>/dev/null

Choose the configuration method based on the results:

Check ResultDescriptionRecommended Choice
networking shows active, and /etc/network/interfaces.d/ existsCommon in Debian, Armbian, etc.Use ifupdown
systemd-networkd shows active, networkctl list shows network devicesNetwork managed by systemd-networkdUse systemd-networkd
NetworkManager shows active, nmcli device status shows network devicesNetwork managed by NetworkManagerPrioritize the NetworkManager method of the current system; do not directly mix the two configurations below
Multiple services show activeSystem may have mixed network managementFirst confirm which service actually manages can0, then choose the corresponding method

If you cannot determine the method used by the current system, it is recommended to refer to the system image or the host machine manufacturer's documentation. FLY host machines and FlyOS-FAST systems generally do not require manual CAN0 configuration.

Write CAN0 Configuration

After confirming the network management method, select the corresponding configuration based on the actual system.

ifupdown

Applicable to Debian, Armbian, etc., systems using /etc/network/interfaces.d/ for network management. Configuration for 1M rate:

sudo /bin/sh -c "cat > /etc/network/interfaces.d/can0" << EOF
allow-hotplug can0
iface can0 can static
bitrate 1000000
up ifconfig \$IFACE txqueuelen 1024
pre-up ip link set can0 type can bitrate 1000000
pre-up ip link set can0 txqueuelen 1024
EOF

For 500K rate, change 1000000 in the command above to 500000 before executing.

After configuration, reboot the device:

sudo reboot

Confirm CAN0 Status

After reboot, execute:

ip -details link show can0

Verify the following key parameters:

  • bitrate: CAN communication speed, e.g., 1000000 indicates 1M.
  • qlen or txqueuelen: Transmit queue length, recommended to be 1024.
Loading...

If can0 is not found, execute first:

ip link
lsusb
dmesg | grep -i can

Common causes:

  • UTOC not recognized by the system, or USB cable only supports power.
  • Motherboard not flashed with USB-to-CAN bridge firmware.
  • CAN0 configuration file not applied, or system not rebooted.
  • System image does not support SocketCAN.

Search for CAN ID

Before searching, ensure the device is in a searchable state:

  1. If the device's UUID is already written in printer.cfg and actively connected by Klipper, the search command may not list it again.
  2. Before searching, temporarily comment out the corresponding [mcu] configuration section, save, and restart Klipper.
  3. Power off the device for about 10 seconds, then power it back on before executing the search command.

For standard host machines, execute:

~/klippy-env/bin/python ~/klipper/scripts/canbus_query.py can0

For FLY host machines, execute:

python3 ~/klipper/scripts/canbus_query.py can0

Result Interpretation:

  • Application: Klipper: This ID can be directly written into printer.cfg for use.
  • Application: CANBOOT or Application: Katapult: The device is still in bootloader mode and needs to be flashed with Klipper firmware first.
  • No IDs found: Follow the "Troubleshooting Sequence for No IDs Found" below to check CAN0, wiring sequence, termination resistors, power supply, and firmware communication method.
Loading...

Method for Filling in CAN ID

  1. Open the printer's web interface and find printer.cfg in the configuration section on the left.
  2. Paste the found UUID after canbus_uuid: in the corresponding [mcu] configuration section.
  3. When using a CAN connection, do not keep both serial: and canbus_uuid: in the same [mcu] section.
  4. Save and restart Klipper.

Example of CAN firmware configuration:

[mcu]
canbus_uuid: xxxxxxxxxxxx

USB firmware uses serial:, CAN firmware uses canbus_uuid:. When switching from USB firmware to CAN firmware, delete or comment out the original serial:.

Note

The IDs in the documentation are examples. Each motherboard or toolboard has a unique ID; please fill in the actual ID found during the search.


CAN Error Troubleshooting: If CAN0 and the CAN ID are correctly configured but communication issues persist, please refer to CAN Error Troubleshooting.

Loading...