aknigin Posted December 10, 2024 Posted December 10, 2024 Recently I tried to connect CAN bus adapter to my Orange Pi 3 LTS board and it happened that there is not so much information about it, it is outdated or related to other boards. So, after I spent a few days in trials and errors below is my recipe. 1. Connect a CAN interface board. Orange Pi pins are not 5V tolerant, so I decided to use a dedicated 2-channel board from Waveshare: https://www.waveshare.com/2-ch-can-hat.htm (only one channel for the start). You can modify a cheap board from AliExpress though; there are instructions in the Internet. I used the PL10 pin of Orange Pi 3 LTS board as INT pin. Actually first I tried to use the PD21 pin but it seems that this pin cannot generate interrupts for some reason and it took a few days to find the solution. Also note that in the overlay this pin bank is set as 0 (as if it would set for the PA10 pin). I have no idea why it should be set this way, maybe someone would explain. 2. Activate the SPI interface in the device tree (it is disabled by default). So, first decompile the device tree: mentioning that you are using the 3LTS board, you need the /boot/dtb/allwinner/sun50i-h6-orangepi-3-lts.dtb file. Decompile it with the following command: dtc -I dtb -O dts -o sun50i-h6-orangepi-3-lts.dts sun50i-h6-orangepi-3-lts.dtb . Edit the dts file a little: in the resulting text file sun8i-h3-orangepi-pc.dts find section named like spi@5011000 and change the status field value from “disabled” to “okay”. Then compile the dts file back to dtb: dtc -I dts -O dtb -o sun50i-h6-orangepi-3-lts.dtb sun50i-h6-orangepi-3-lts.dts . 3. Add an overlay file for the MCP25251 interface. Compile the attached overlay file sun50i-h6-spi-mcp2515.dts: dtc –I dts –O dtb –o sun50i-h6-spi-mcp2515.dtbo sun50i-h6- spi-mcp2515.dts . Copy the resulted .dtbo file into the /boot/overlay-user folder and add into the /boot/orangepiEnv.txt string user_overlays=sun50i-h6-spi-mcp2515 . 4. Install CAN tools: sudo apt-get install can-utils . 5. Restart your board. 6. Make sure that the CAN interface is initialized; run the following command: dmesg | grep spi||mcp . You will see a line like this: mcp251x spi1.0 can0: MCP2515 successfully initialized. 7. Activate the CAN bus; run the following command: ip link set can0 up type can bitrate 500000 . 8. Make sure that the CAN bus is active; run the following command: ip –det link show can0 . You should see that the bus has UP state now. Hope this helps and sorry if I missed something. sun50i-h6-spi-mcp2515.dts 0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.