CANbus on Klipper
I’m no stranger to CANbus, having already done this modification on my Voron V0.2
This time I’m using a few different tools to get there, and an external USB driven CANbus driver
Using Esoterical’s CAN Bus Guide, this is how I went about upgrading
Install pre-requisites
1
sudo apt-get install git build-essentials pkg-config
Setup CAN Network
1
sudo vi /etc/systemd/network/00-canbus.network
1
2
3
4
5
6
7
8
9
[Match]
Name=can0
[CAN]
BitRate=1000000
[Link]
TransmitQueueLength=128
ActivationPolicy=up
Depending on the CAN module, you may need to set the Transmit Queue via udev rules:
1
sudo vi /etc/udev/rules.d/99-canbus.rules
1
2
# set tx queue size for canbus
SUBSYSTEM=="net", ACTION=="add|change", KERNEL=="can0" ATTR{tx_queue_len}="128"
Install Katapult on target devices
https://github.com/Arksine/Katapult
1
2
3
4
5
sudo su klipper -
git clone https://github.com/Arksine/katapult
cd katapult
make menuconfig
make
In the menu options, make sure the correct microcontroller architecture is set (e.g. rp2040) and processor model - this is the configuration I used for the BTT EBB2209 RP2040 CAN module:
- Micro-Controller Architecture: Raspberry Pi RP2040/RP235x
- Processor model: rp2040
- Flash chip: GENERIC_03H with CLKDIV 4
- Build Katapult deployment application: 16KiB Bootloader
- Communication Interface: CAN
- CAN Bus speed: 1000000
- Enable Status LED
- Status LED GPIO Pin: gpio26
Save and quit the config page. Run the make command to build the katapult bootloader
DFU Load Bootloader
Connect a USB cable to the USB-C port and bridge the USB_5V jumper before connecting the device the SBC. Press and hold the “Boot” button and hit the “Reset” button to put the board into DFU mode
Find the device information:
1
lsusb
Bus 001 Device 003: ID 2e8a:0003 Raspberry Pi RP2 Boot
Flash the boot loader to the board
1
make flash FLASH_DEVICE=2e8a:0003
If all has gone well, you should be able to remove the USB cable and USB_5V jumper before connecting the CANBUS cable and querying for a successful katapult bootloader
1
2
cd ~/katapult/scripts
python3 flash_can.py -i can0 -q
Detected UUID: d834a241419f, Application: Katapult
Flash Klipper
1
2
3
cd ~/klipper
make menuconfig
make
- [*] Enable extra low-level configuration options
- Micro-Controller Architecture: Raspberry Pi RP2040/RP235x
- Processor model: rp2040
- Bootloader offset: 16KiB Bootloader
- Communication Interface: CAN
- CAN Bus speed: 1000000
1
2
cd ~/katapult/scripts
python3 flash_can.py -i can0 -f ~/klipper/out/klipper.bin -u d834a241419f
Verify Klipper is connected:
1
~/klippy-venv/bin/python ~/klipper/scripts/canbus_query.py can0