跳到主要内容

USB桥接CAN固件编译与烧录

使用前确认

CANHAT 已停产
  • Gemini V2 没有板载 CAN 收发芯片,需要搭配 CANHAT 才能使用 USB 桥接 CAN。
  • CANHAT 已经停产。若手上没有 CANHAT 模块,请不要按本页配置 CAN 桥接。
  • 使用 CAN 工具板时,请确认上位机 can0 速率、Gemini V2 桥接固件速率、CAN 工具板固件速率一致。

安装 CANHAT 并检查拨码

断电操作

开始前请完全关闭打印机并断开电源供应。不要在通电状态下插拔线束、整理接口线序或触碰端子。

  • CANHAT 的红色排针对应 Gemini V2 的红色排母,黑色排针对应黑色排母。方向错误可能损坏设备。
  • 安装 CANHAT 后,打开拨码 1256,其余拨码保持关闭。
Loading...
Loading...

CAN 接线

断电操作

开始前请完全关闭打印机并断开电源供应。不要在通电状态下插拔线束、整理接口线序或触碰端子。

  • CANHAT 连接 CAN 工具板时,请按工具板文档核对 CANHCANL、电源正负极。
  • CAN 总线两端需要按实际设备要求设置终端电阻。
  • 若需要刷写 CAN 工具板固件,请查看对应工具板产品文档。
Loading...

SSH 连接到上位机

注意
  • 固件编译前需要先连接 Gemini V2 上位机 SSH。
  • 建议通过 WiFi 或网线连接 SSH 后再编译固件。
  • 首先请:连接 Gemini V2 上位机 SSH

编译 USB 桥接 CAN 固件

固件编译简明指南

注意事项

  • 网络: 确保上位机(树莓派等)已联网
  • 登录方式: 必须使用 SSH 通过网络登录,禁用串口
  • 输入法: 保持键盘为英文半角模式

SSH登录与用户切换

使用 MobaXterm、PuTTY 等工具 SSH 登录上位机。

切换用户:

  • 普通系统(树莓派官方系统等)
    禁止使用 root,需切换到普通用户:
    su <用户名>
  • FLY上位机(FlyOS-FAST系统)
    仅支持 root 用户登录(密码: mellow)

固件编译操作指南

在 Klipper 固件配置界面中仅支持键盘操作,无法使用鼠标。

按键功能
↑ / ↓上下移动光标,选择菜单项
Enter / 空格确认选择、勾选选项或进入子菜单
ESC返回上一级菜单
Q退出配置界面
Y退出时,如有提示则按 Y 保存配置

开始固件编译

下面介绍如何编译固件:

  1. 连接到 SSH,输入下面的命令并按 Enter

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

    其中,rm -rf ~/klipper/.config && rm -rf ~/klipper/out 用于清除之前的编译配置与固件; make menuconfig 用于打开 Klipper 固件配置界面。

  2. 按照下方顺序逐项设置,每完成一项再继续下一项。

    1启用 Enable extra low-level configuration options
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (STMicroelectronics STM32) --->
    Processor model (STM32F405) --->
    Bootloader offset (32KiB bootloader) --->
    Clock Reference (8 MHz crystal) --->
    Communication interface (USB to CAN bus bridge (USB on PA11/PA12)) --->
    CAN bus interface (CAN bus (on PB8/PB9)) --->
    USB ids --->
    (1000000) CAN bus speed
    [*] Optimize stepper code for 'step on both edges'
    () GPIO pins to set at micro-controller startup
    GPIO state at micro-controller startup (Not set) --->
    2Micro-controller Architecture 选择 STMicroelectronics STM32
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (STMicroelectronics STM32) --->
    Processor model (STM32F405) --->
    Bootloader offset (32KiB bootloader) --->
    Clock Reference (8 MHz crystal) --->
    Communication interface (USB to CAN bus bridge (USB on PA11/PA12)) --->
    CAN bus interface (CAN bus (on PB8/PB9)) --->
    USB ids --->
    (1000000) CAN bus speed
    [*] Optimize stepper code for 'step on both edges'
    () GPIO pins to set at micro-controller startup
    GPIO state at micro-controller startup (Not set) --->
    3Processor model 选择 STM32F405
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (STMicroelectronics STM32) --->
    Processor model (STM32F405) --->
    Bootloader offset (32KiB bootloader) --->
    Clock Reference (8 MHz crystal) --->
    Communication interface (USB to CAN bus bridge (USB on PA11/PA12)) --->
    CAN bus interface (CAN bus (on PB8/PB9)) --->
    USB ids --->
    (1000000) CAN bus speed
    [*] Optimize stepper code for 'step on both edges'
    () GPIO pins to set at micro-controller startup
    GPIO state at micro-controller startup (Not set) --->
    4Bootloader offset 选择 32KiB bootloader
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (STMicroelectronics STM32) --->
    Processor model (STM32F405) --->
    Bootloader offset (32KiB bootloader) --->
    Clock Reference (8 MHz crystal) --->
    Communication interface (USB to CAN bus bridge (USB on PA11/PA12)) --->
    CAN bus interface (CAN bus (on PB8/PB9)) --->
    USB ids --->
    (1000000) CAN bus speed
    [*] Optimize stepper code for 'step on both edges'
    () GPIO pins to set at micro-controller startup
    GPIO state at micro-controller startup (Not set) --->
    5Clock Reference 选择 8 MHz crystal
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (STMicroelectronics STM32) --->
    Processor model (STM32F405) --->
    Bootloader offset (32KiB bootloader) --->
    Clock Reference (8 MHz crystal) --->
    Communication interface (USB to CAN bus bridge (USB on PA11/PA12)) --->
    CAN bus interface (CAN bus (on PB8/PB9)) --->
    USB ids --->
    (1000000) CAN bus speed
    [*] Optimize stepper code for 'step on both edges'
    () GPIO pins to set at micro-controller startup
    GPIO state at micro-controller startup (Not set) --->
    6Communication interface 选择 USB to CAN bus bridge (USB on PA11/PA12)
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (STMicroelectronics STM32) --->
    Processor model (STM32F405) --->
    Bootloader offset (32KiB bootloader) --->
    Clock Reference (8 MHz crystal) --->
    Communication interface (USB to CAN bus bridge (USB on PA11/PA12)) --->
    CAN bus interface (CAN bus (on PB8/PB9)) --->
    USB ids --->
    (1000000) CAN bus speed
    [*] Optimize stepper code for 'step on both edges'
    () GPIO pins to set at micro-controller startup
    GPIO state at micro-controller startup (Not set) --->
    7CAN bus interface 选择 CAN bus (on PB8/PB9)
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (STMicroelectronics STM32) --->
    Processor model (STM32F405) --->
    Bootloader offset (32KiB bootloader) --->
    Clock Reference (8 MHz crystal) --->
    Communication interface (USB to CAN bus bridge (USB on PA11/PA12)) --->
    CAN bus interface (CAN bus (on PB8/PB9)) --->
    USB ids --->
    (1000000) CAN bus speed
    [*] Optimize stepper code for 'step on both edges'
    () GPIO pins to set at micro-controller startup
    GPIO state at micro-controller startup (Not set) --->
    8USB ids 保持默认,无需进入
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (STMicroelectronics STM32) --->
    Processor model (STM32F405) --->
    Bootloader offset (32KiB bootloader) --->
    Clock Reference (8 MHz crystal) --->
    Communication interface (USB to CAN bus bridge (USB on PA11/PA12)) --->
    CAN bus interface (CAN bus (on PB8/PB9)) --->
    USB ids --->
    (1000000) CAN bus speed
    [*] Optimize stepper code for 'step on both edges'
    () GPIO pins to set at micro-controller startup
    GPIO state at micro-controller startup (Not set) --->
    9CAN bus speed 设置为 1000000
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (STMicroelectronics STM32) --->
    Processor model (STM32F405) --->
    Bootloader offset (32KiB bootloader) --->
    Clock Reference (8 MHz crystal) --->
    Communication interface (USB to CAN bus bridge (USB on PA11/PA12)) --->
    CAN bus interface (CAN bus (on PB8/PB9)) --->
    USB ids --->
    (1000000) CAN bus speed
    [*] Optimize stepper code for 'step on both edges'
    () GPIO pins to set at micro-controller startup
    GPIO state at micro-controller startup (Not set) --->
    10启用 Optimize stepper code for 'step on both edges'
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (STMicroelectronics STM32) --->
    Processor model (STM32F405) --->
    Bootloader offset (32KiB bootloader) --->
    Clock Reference (8 MHz crystal) --->
    Communication interface (USB to CAN bus bridge (USB on PA11/PA12)) --->
    CAN bus interface (CAN bus (on PB8/PB9)) --->
    USB ids --->
    (1000000) CAN bus speed
    [*] Optimize stepper code for 'step on both edges'
    () GPIO pins to set at micro-controller startup
    GPIO state at micro-controller startup (Not set) --->
    11GPIO pins to set at micro-controller startup 保持为空
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (STMicroelectronics STM32) --->
    Processor model (STM32F405) --->
    Bootloader offset (32KiB bootloader) --->
    Clock Reference (8 MHz crystal) --->
    Communication interface (USB to CAN bus bridge (USB on PA11/PA12)) --->
    CAN bus interface (CAN bus (on PB8/PB9)) --->
    USB ids --->
    (1000000) CAN bus speed
    [*] Optimize stepper code for 'step on both edges'
    () GPIO pins to set at micro-controller startup
    GPIO state at micro-controller startup (Not set) --->
    12GPIO state at micro-controller startup 选择 Not set

    此项是 FLYOS-Klipper 功能。通常保持 Not set;如需设置全部 GPIO 的启动状态,请先阅读 GPIO 启动状态使用说明

    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (STMicroelectronics STM32) --->
    Processor model (STM32F405) --->
    Bootloader offset (32KiB bootloader) --->
    Clock Reference (8 MHz crystal) --->
    Communication interface (USB to CAN bus bridge (USB on PA11/PA12)) --->
    CAN bus interface (CAN bus (on PB8/PB9)) --->
    USB ids --->
    (1000000) CAN bus speed
    [*] Optimize stepper code for 'step on both edges'
    () GPIO pins to set at micro-controller startup
    GPIO state at micro-controller startup (Not set) --->
    13Q 键退出配置界面
    (Top)
    Klipper Firmware Configuration
    [*] Enable extra low-level configuration options
    Micro-controller Architecture (STMicroelectronics STM32) --->
    Processor model (STM32F405) --->
    Bootloader offset (32KiB bootloader) --->
    Clock Reference (8 MHz crystal) --->
    Communication interface (USB to CAN bus bridge (USB on PA11/PA12)) --->
    CAN bus interface (CAN bus (on PB8/PB9)) --->
    USB ids --->
    (1000000) CAN bus speed
    [*] Optimize stepper code for 'step on both edges'
    () GPIO pins to set at micro-controller startup
    GPIO state at micro-controller startup (Not set) --->
    14出现 Save configuration 时按 Y 保存配置
    Quit
    Save configuration?
    (Y)es(N)o(C)ancel
  3. 完成上方最后两个步骤,按 Q 退出配置界面,再按 Y 保存配置。

  4. 返回命令行后输入下面的命令并按 Enter 开始编译:

    make -j4
    root@flyos-11e5f8 ~/klipper # make -j4
    Compiling out/src/generic/canserial.o
    Compiling out/src/../lib/fast-hash/fasthash.o
    Compiling out/src/stm32/can.o
    Compiling out/src/stm32/chipid.o
    Compiling out/src/generic/usb_canbus.o
    Compiling out/src/stm32/hard_pwm.o
    Compiling out/src/stm32/sdio.o
    Preprocessing out/src/generic/armcm_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 与系统版本变化。

Loading...

TF 卡烧录固件

断电操作

开始前请完全关闭打印机并断开电源供应。不要在通电状态下插拔线束、整理接口线序或触碰端子。

烧录说明
  • Gemini V2 下位机固件使用 TF 卡烧录。
  • 编译完成后,将 klipper.bin 下载到 TF 卡并重命名为 firmware.bin
  • 上电烧录完成后,TF 卡中 firmware.bin 消失并出现 FLY.CUR 即代表烧录成功。

准备工作

  • 开始烧录固件前,请先使用网络连接SSH
  • 杂牌内存卡可能导致烧录失败,请尽量使用下方推荐的内存卡进行更新固件
  • 需要准备一张容量不超过32G的TF卡,并且建议TF卡的传输速度必须为class10级或class10级以上,建议使用闪迪等品牌的TF卡

下载固件

  1. 使用之前准备好的TF卡

  2. 使用SDFormatter格式化

    Loading...
  3. 使用MobaXterm_Personal左边文件目录找到klipper选择然后找到out打开

    注意
    • 普通系统注意事项
      • 树莓派、FLY派等普通上位机系统都看此类
      • 编译完成的固件在/home/<您的上位机用户名>/klipper/out/目录下
      Loading...
  4. 并且将klipper.bin下载到TF卡里面,并且重命名为firmware.bin

    firmware.bin
    Loading...
Windows 文件后缀显示

Windows 默认可能隐藏文件扩展名,容易把文件实际保存成 firmware.bin.txtfirmware.bin.bin。重命名固件前请在文件资源管理器中打开后缀显示:

  1. 打开任意文件夹。
  2. 点击顶部 查看
  3. 勾选 文件扩展名
  4. 重命名文件时确认完整文件名为 firmware.bin
  1. 主板断电,将TF卡插入主板
  2. 给主板上电,等待10秒
  3. 取下TF卡,插入电脑,如果SD卡中的firmware.bin消失,出现FLY.CUR就是烧录成功了
    Loading...

烧录后搜索 CAN UUID

固件烧录完成并给 Gemini V2 重新上电后,请先不要连接 CAN 工具板,优先搜索 Gemini V2 主板自身的 CAN UUID。确认主板 UUID 后,再连接并刷写对应 CAN 工具板固件。

查看 CANBus UUID 获取方法

Loading...