IO2CAN
IO2CAN copied to clipboard
Hardware setting for MCP2515 SPI to CAN
As shown in the figure below, when used with raspberry pi or CM4, we need to push the switch to the top, and when used with CB1, we need to pull the switch to the bottom.

Software Settings
Work with raspberry pi
- Add the following to the raspberry pi
/boot/config.txtfile
and restart raspberry pidtparam=spi=on dtoverlay=mcp2515-can0,oscillator=12000000,interrupt=24,spimaxfrequency=10000000
Work with CB1
- If the OS image of v2.2.1 version is used, the following dtb files need to be updated for stable use. If the OS image after V2.2.1 is used, this operation is unnecessary.
- Download sun50i-h616-biqu.dtb
- Replace
/boot/dtb/allwinner/sun50i-h616-biqu.dtbin the OS with the downloaded sun50i-h616-biqu.dtb.
- Uncomment
overlays=mcp2515in/boot/BoardEnv.txt.

Getting started
-
Input the
dmesg | grep -i '\(can\|spi\)'command to test whether MCP2515 has been connected normally after the restart is completed.
The normal response should be as follows[ 8.680446] CAN device driver interface [ 8.697558] mcp251x spi0.0 can0: MCP2515 successfully initialized. [ 9.482332] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
-
Input
sudo nano /etc/network/interfaces.d/can0command to create a new file namedcan0, and write the following contentauto can0 iface can0 can static bitrate 500000 up ifconfig $IFACE txqueuelen 1024Set the Canbus speed to 500K (consistent with the speed set in klipper), and set the
txqueuelento 1024 bytes. Save(Ctrl + S) and Exit(Ctrl + X) after modification, inputsudo rebootto restart host -
Each micro-controller on the CAN bus is assigned a unique id based on the factory chip identifier encoded into each micro-controller. To find each micro-controller device id, make sure the hardware is powered and wired correctly, and then run:
~/klippy-env/bin/python ~/klipper/scripts/canbus_query.py can0
If uninitialized CAN devices are detected the above command will report lines like the following:
Found canbus_uuid=0e0d81e4210c
set the correct ID number inprinter.cfg[mcu EBB] canbus_uuid: 0e0d81e4210c