Skip to main content

CAN Firmware Compilation

Start Compilation​

Brief Guide to Firmware Compilation​

Notes​

  • Network: Ensure the host (Raspberry Pi, etc.) is connected to the internet.
  • Login Method: Must log in via SSH over the network; serial port access is disabled.
  • Input Method: Keep the keyboard in English half-width mode.

SSH Login and User Switching​

Use tools like MobaXterm, PuTTY, etc., to SSH into the host.

Switch User:​

  • Standard System (Official Raspberry Pi system, etc.)
    Do not use root; switch to a regular user:
    su <username>
  • FLY Host System (FlyOS-FAST system)
    Only supports login as root user (password: mellow)

Firmware Compilation Operation Guide​

In the Klipper firmware configuration interface, only keyboard operations are supported; the mouse cannot be used.

KeyFunction
↑ / ↓Move cursor up/down to select menu items
Enter / SpaceConfirm selection, check options, or enter submenus
ESCReturn to the previous menu
QExit the configuration interface
YIf prompted when exiting, press Y to save the configuration

Starting Firmware Compilation​

Below is an introduction on how to compile the firmware:

  1. Connect via SSH, enter the following command, and press Enter:

    cd ~/klipper && rm -rf ~/klipper/.config && rm -rf ~/klipper/out && make menuconfig

    Here, rm -rf ~/klipper/.config && rm -rf ~/klipper/out is used to clear previous compilation configurations and firmware; make menuconfig is used to open the Klipper firmware configuration interface.

  2. Follow the order below to set each item one by one, completing each before moving on to the next.

    1启用 Enable extra low-level configuration options
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    2Micro-controller Architecture 选择 Raspberry Pi RP2040/RP235x
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (Raspberry Pi RP2040/RP235x) --->
    3Processor model 选择 rp2040
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (Raspberry Pi RP2040/RP235x) --->
    Processor model (rp2040) --->
    4Bootloader offset 选择 16KiB bootloader
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (Raspberry Pi RP2040/RP235x) --->
    Processor model (rp2040) --->
    Bootloader offset (16KiB bootloader) --->
    5Communication Interface 选择 CAN bus
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (Raspberry Pi RP2040/RP235x) --->
    Processor model (rp2040) --->
    Bootloader offset (16KiB bootloader) --->
    Communication Interface (CAN bus) --->
    6CAN RX gpio number 设置为 1
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (Raspberry Pi RP2040/RP235x) --->
    Processor model (rp2040) --->
    Bootloader offset (16KiB bootloader) --->
    Communication Interface (CAN bus) --->
    (1) CAN RX gpio number
    7CAN TX gpio number 设置为 0
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (Raspberry Pi RP2040/RP235x) --->
    Processor model (rp2040) --->
    Bootloader offset (16KiB bootloader) --->
    Communication Interface (CAN bus) --->
    (1) CAN RX gpio number
    (0) CAN TX gpio number
    8CAN bus speed 默认使用 1M(1000000),无需修改

    默认 CAN 速率为 1M,对应值 1000000,使用 1M 时无需修改。

    • 1M:1000000
    • 500K:500000
    • 250K:250000

    请根据上位机的 CAN 网络速率选择;上位机、主板与同一总线上的所有 CAN 设备必须使用相同速率。

    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (Raspberry Pi RP2040/RP235x) --->
    Processor model (rp2040) --->
    Bootloader offset (16KiB bootloader) --->
    Communication Interface (CAN bus) --->
    (1) CAN RX gpio number
    (0) CAN TX gpio number
    (1000000) CAN bus speed
    9启用 Optimize stepper code for 'step on both edges'
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (Raspberry Pi RP2040/RP235x) --->
    Processor model (rp2040) --->
    Bootloader offset (16KiB bootloader) --->
    Communication Interface (CAN bus) --->
    (1) CAN RX gpio number
    (0) CAN TX gpio number
    (1000000) CAN bus speed
    [*] Optimize stepper code for 'step on both edges'
    10GPIO pins to set at micro-controller startup 设置为以下内容
    Loading...
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (Raspberry Pi RP2040/RP235x) --->
    Processor model (rp2040) --->
    Bootloader offset (16KiB bootloader) --->
    Communication Interface (CAN bus) --->
    (1) CAN RX gpio number
    (0) CAN TX gpio number
    (1000000) CAN bus speed
    [*] Optimize stepper code for 'step on both edges'
    (!gpio18) GPIO pins to set at micro-controller startup
    11按 Q 键退出配置界面
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (Raspberry Pi RP2040/RP235x) --->
    Processor model (rp2040) --->
    Bootloader offset (16KiB bootloader) --->
    Communication Interface (CAN bus) --->
    (1) CAN RX gpio number
    (0) CAN TX gpio number
    (1000000) CAN bus speed
    [*] Optimize stepper code for 'step on both edges'
    (!gpio18) GPIO pins to set at micro-controller startup
    12出现 Save configuration 时按 Y 保存配置
    Quit
    Save configuration?
    (Y)es(N)o(C)ancel
  3. After completing the last two steps above, press Q to exit the configuration interface, then press Y to save the configuration.

  4. Return to the command line and enter the following command, then press Enter to start compiling:

    make -j4
    root@flyos-11e5f8 ~/klipper # make -j4
    Compiling out/src/../lib/can2040/can2040.o
    Compiling out/src/generic/canserial.o
    Compiling out/src/generic/canbus.o
    Compiling out/src/../lib/fast-hash/fasthash.o
    Compiling out/src/rp2040/hard_pwm.o
    Compiling out/src/rp2040/spi.o
    Compiling out/src/rp2040/i2c.o
    Preprocessing out/src/rp2040/rpxxxx_link.ld
    Building out/compile_time_request.o
    Version: XXXX
    Linking out/klipper.elf
    Creating bin file out/klipper.bin

    终端末尾出现 Linking out/klipper.elf 和 Creating bin file out/klipper.bin,即表示编译成功。 实际编译时,部分 Compiling 行和 Version 会随 Klipper 与系统版本变化。

Burn Firmware​

  • Before burning the firmware, use an XT30 cable to connect the toolboard to a UTOC or a motherboard with a bridging firmware installed. The reference wiring diagram is provided below.
  • Please ensure the toggle switches are set to the correct positions.

Schematic of the KF Interface​

Loading...
Power-off operation.

Before starting, completely turn off the printer and disconnect the power supply, and also disconnect any USB connections that may power the CAN nodes. Do not plug or unplug wiring harnesses, adjust the terminal resistors, or touch terminals while the power is on.

The “power-off measurement” here does not mean disconnecting the CAN wires. During measurement, the CAN wires and all nodes on the bus should remain connected in their normal operating configuration; otherwise, what is measured may only represent a single node or a single terminating resistor, which cannot represent the entire CAN bus.

Set the multimeter to the resistance range, and measure the resistance between CAN-H and CAN-L:

Reference ReadingJudgment and Handling
Approximately 60ΩNormal, usually indicating that there is one 120Ω termination resistor at each physical end of the bus
Approximately 120ΩUsually only one termination resistor is active; please enable the termination resistor at the other physical end according to the product wiring diagram
Approximately 40ΩUsually three termination resistors are active; please disable the redundant termination resistors according to the product wiring diagram

The above values are for reference only; multimeter accuracy, probe contact, and wiring harness condition can all cause measurement errors. The key to judgment is which range the reading is close to, as well as the trend of reading changes after adjusting the terminal resistor; it is not required to match the values in the table exactly.

Loading...

Query CANBus UUID​

Before You Begin
  • It is recommended to perform ID query and firmware flashing operations in a non-printing state to avoid interfering with the printing process.
  • The Katapult (CANBoot) firmware and Klipper firmware on the same mainboard/toolboard use the same CAN ID.
Prerequisites

Please ensure the following conditions are met; otherwise, the CAN ID may not be found properly:

  1. The host CAN network is correctly configured
  2. The toolboard CAN baud rate is exactly the same as the host (communication will fail if the baud rates differ)
  3. After running the lsusb command, the 1d50:606f device (USB-CAN adapter) is visible

Search Command (select based on your system)​

  • Standard host search command
    ~/klippy-env/bin/python ~/klipper/scripts/canbus_query.py can0
  • FLY host search command
    python3 ~/klipper/scripts/canbus_query.py can0

Search Result Description​

Case 1: Mainboard/Toolboard already flashed with Klipper firmware​

  • Display: Shows one CAN ID and indicates Application: Klipper
  • Description: The device is already running Klipper firmware and can be used directly. This ID may be the mainboard ID or the toolboard ID.
  • How to distinguish: First completely power off, disconnect the toolboard's CAN cable, then power on and search again. If the ID disappears, it belongs to the toolboard; if the ID remains, it belongs to the mainboard.
Loading...

Case 2: Mainboard + Toolboard awaiting flashing​

  • Display: Shows two CAN IDs
  • Description: The mainboard is running Klipper firmware, and the toolboard is running CanBoot firmware, awaiting flashing.
Loading...

Case 3: UTOC + Toolboard awaiting flashing​

  • Display: UTOC itself does not show an ID; only the toolboard ID is shown
  • Description: UTOC serves only as a bridge; ensure the toolboard is in CanBoot mode.
Loading...

Case 4: No ID displayed​

  • Display: No ID is shown at all
  • Possible causes:
    1. The CAN bus is occupied by Klipper
    2. The host CAN0 baud rate is configured incorrectly
    3. Physical wiring is abnormal
    4. The device has not entered CanBoot mode
Loading...

Important Notes
  • Awaiting flash state: When the toolboard is in CanBoot mode, it will show Application: CanBoot and the firmware LED will blink; firmware flashing can be performed at this time.
  • ID occupation handling: If the device is already running Klipper firmware and the ID has been entered into the configuration file, the ID will not be displayed (occupied by Klipper). To display it again, you need to comment out that ID in the configuration and completely power off and restart.
Troubleshooting

If the UUID cannot be queried, please refer to: CAN Troubleshooting Guide

Start Flashing​

After the CAN firmware compilation is complete, select the flashing method according to the current device status:

您的下位机现在是什么状态

Confirm if the Firmware is Running​

  • If the firmware starts properly, the LED will light up.
    Loading...
Loading...