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
- Connect the UTOC or the motherboard flashed with CAN bridge firmware to the host machine via USB.
- Log in to the host machine's backend via the network, not via serial port.
- The FlyOS-FAST system presets CAN0 with a 1M rate and 1024 buffer; manual configuration of CAN0 is generally not required.
- The CAN rate in the toolboard and motherboard firmware must match the CAN0 rate of the host machine.
- 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.
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
- After power-off, confirm that CAN-H is connected to CAN-H and CAN-L is connected to CAN-L.
- After power-off, inspect the CAN wires, connectors, and crimping positions to ensure there are no broken wires, loose connections, or poor contact.
- If using a UTOC, use a functional USB data cable to connect it to the host machine.
- If using a USB-to-CAN bridge motherboard, confirm that the motherboard has been flashed with the USB-to-CAN bridge firmware.
- 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 Value | Diagnosis |
|---|---|
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 |
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
usbutilsfirst. - Not seeing
1d50:606f: Check the USB cable, UTOC, USB-to-CAN bridge firmware, and power supply. - Multiple
1d50:606fentries: 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
Only after the system recognizes the CAN bridge device will subsequent CAN0 configuration and CAN ID searches be meaningful.
Configure CAN0
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 Result | Description | Recommended Choice |
|---|---|---|
networking shows active, and /etc/network/interfaces.d/ exists | Common in Debian, Armbian, etc. | Use ifupdown |
systemd-networkd shows active, networkctl list shows network devices | Network managed by systemd-networkd | Use systemd-networkd |
NetworkManager shows active, nmcli device status shows network devices | Network managed by NetworkManager | Prioritize the NetworkManager method of the current system; do not directly mix the two configurations below |
Multiple services show active | System may have mixed network management | First 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
- systemd-networkd
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.
systemd-networkd
Applicable to systems using systemd-networkd for network management. Configuration for 1M rate:
Create the network configuration file:
sudo tee /etc/systemd/network/99-can.network > /dev/null <<'EOF'
[Match]
Name=can*
[CAN]
BitRate=1000000
RestartSec=100ms
EOF
Create the link configuration file:
sudo tee /etc/systemd/network/99-can.link > /dev/null <<'EOF'
[Match]
OriginalName=can*
[Link]
TxQueueLength=1024
EOF
For 500K rate, change BitRate=1000000 to BitRate=500000.
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.,1000000indicates 1M.qlenortxqueuelen: Transmit queue length, recommended to be1024.
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:
- If the device's UUID is already written in
printer.cfgand actively connected by Klipper, the search command may not list it again. - Before searching, temporarily comment out the corresponding
[mcu]configuration section, save, and restart Klipper. - 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 intoprinter.cfgfor use.Application: CANBOOTorApplication: 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.
Method for Filling in CAN ID
- Open the printer's web interface and find
printer.cfgin the configuration section on the left. - Paste the found UUID after
canbus_uuid:in the corresponding[mcu]configuration section. - When using a CAN connection, do not keep both
serial:andcanbus_uuid:in the same[mcu]section. - 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:.
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.