Jump to content
Chridster1

Tinker OS and Microchip MCP2515 over I2C

Recommended Posts

Morning Forum!

I have the Tinkerboard 2S and am running Tinker OS v2.0.4. We have a Microchip MCP2515 SPI ( https://ww1.microchip.com/downloads/en/DeviceDoc/MCP2515-Stand-Alone-CAN-Controller-with-SPI-20001801J.pdf ).

I've recompiled the kernel and enabled CAN over SPI

linaro@linaro-alip:~$ dmesg | grep -i can:
[    2.368374] vcan: Virtual CAN interface driver
[    4.476074] can: controller area network core (rev 20120528 abi 9)
[    4.486845] can: raw protocol (rev 20120528)
[    4.491137] can: broadcast manager protocol (rev 20120528 t)
[    4.496819] can: netlink gateway (rev 20130117) max_hops=1

Has anyone got this working? Everything I see seems to be for the Raspberry pi and doesn't work on TB2S

Many thanks

 

Share this post


Link to post
Share on other sites

hello @Chridster1

i'm a little confused with the title -- i2c is not supported for the mcp2515. are you trying to enable mcp2515 with spi interface?

Share this post


Link to post
Share on other sites

hello @Chridster1

got it, the overlay.dts can be downloaded here: https://www.asuswebstorage.com/navigate/a/#/s/725148C84DAD433198389FD8685713564 

please use the 4 SPI1 pins and one GPIO pin (GP3D4) for interrupts and and follow along:

1. sudo vi /boot/config.txt

intf:spi1=on

overlay=mcp2515-can0

 

 

2. dtc -O dtb -o mcp2515-can0.dtbo -b 0 -@ mcp2515-can0-overlay.dts

    sudo cp mcp2515-can0.dtbo /boot/overlays/mcp2515-can0.dtbo

 

3. Make kernel modules and add the below kernel configs, and then reboot the device

CONFIG_CAN=y

CONFIG_CAN_MCP251X=y

tinkerboard2s_can.png

Share this post


Link to post
Share on other sites

Fantastic tooz,

Sorry for the confusion. I'll give the above a go now. I2C does work fine on the TB so if I can get SPI then you've made my weekend.

 

Share this post


Link to post
Share on other sites

Hi @tooz,

It's done something cause when I run the following

linaro@linaro-alip:/sys/bus$ dmesg|egrep -i 'can0|can1|mcp'
[    2.381288] mcp251x spi1.0: Looking up vdd-supply from device tree
[    2.381301] mcp251x spi1.0: Looking up vdd-supply property in node /spi@ff1d0000/mcp2515@0 failed
[    2.381328] mcp251x spi1.0: Looking up xceiver-supply from device tree
[    2.381339] mcp251x spi1.0: Looking up xceiver-supply property in node /spi@ff1d0000/mcp2515@0 failed

I can see the mcp251x output which it hasn't done before. I'll ask our hardware guys to check the pins are wired as above and let you know.

Thanks again for the help

Chris

Share this post


Link to post
Share on other sites

Hi @tooz

Sorry for the late reply, I've been on holiday and only just got back to this now.

I've noticed that the new version of Tinker OS https://dlcdnets.asus.com/pub/ASUS/Embedded_IPC/Tinker Board 2/Tinker_Board_2-Debian-Buster-v2.1.6-20220503.zip won't boot once we've made the changes to the kernel as above and flashed. I haven't tried compiling on the Tinkerboard which is my next move. The older version of Tinker OS
https://dlcdnets.asus.com/pub/ASUS/Embedded_IPC/Tinker Board 2/Tinker_Board_2-Debian-Buster-v2.0.4-20211222.zip will allow me to update the kernel.

I'll let you know how compiling on the TB works out

Thanks

 

Share this post


Link to post
Share on other sites
Hello, 

Did you manage to prepare the os to communicate with mcp2515?
I tried to configure the os for mcp2515 on kernel version 4.4.194 but the system does not boot after uploading mcp2515-can0.dtbo to /boot/overlays/

Share this post


Link to post
Share on other sites

Hello @tooz

Thank you for answer but the downloaded image is not boot on my Tb.

Is the shared image for the TinkerBoard S R2.0 model?

I try burn to SD Card and eMMC.

Share this post


Link to post
Share on other sites

hello @M@riusz

for tinker board s r2.0 debian os (kernel 4.4, debian 10) v.3.0.18, can related modules are included by default, all you need to do to get waveshare can working is to modify the dts and /boot/config.txt

i've uploaded the dtbo and dts, along with config.txt here: https://www.asuswebstorage.com/navigate/a/#/s/077D58B319314CA9AB298E8F012540C04

 

--

Step 0:

# dtc -@ -b 0 -Wno-unit_address_vs_reg -I dts -O dtb -o mcp2515-can0.dtbo mcp2515-can0.dts

# cp mcp2515-can0.dtbo /boot/overlay/

 

Step 1:

Change the file “/boot/config.txt” in the Debian OS as below:

< #intf:spi1=off

---

> intf:spi2=on

60c60

< overlay=

---

> overlay=mcp2515-can0

 

Step 2: reboot

$ sudo reboot

 

Step 3: CAN Loopback Self-Test

$ sudo apt-get update

$ sudo apt-get install can-utils

linaro@linaro-alip:~$ sudo ip link set can0 up type can bitrate 125000 loopback on

linaro@linaro-alip:~$ sudo candump can0 &

[1] 2500

linaro@linaro-alip:~$ sudo cansend can0 abc#1122334455

  can0  2BC   [5]  11 22 33 44 55

  can0  2BC   [5]  11 22 33 44 55

--

Share this post


Link to post
Share on other sites

hello @tooz

It works, thanks a lot for your help 😀 I suppose I had a bad dtbo file.

linaro@linaro-alip:~$ sudo ip link set can0 up type can bitrate 125000 loopback on
linaro@linaro-alip:~$ sudo candump can0 &
[1] 1822
linaro@linaro-alip:~$ sudo cansend can0 abc#1122334455
  can0  2BC   [5]  11 22 33 44 55
  can0  2BC   [5]  11 22 33 44 55
Running on the version: Linux version 4.4.194 (leslie_yu@asus-docker-env) (gcc version 6.3.1 20170404 (Linaro GCC 6.3-2017.05) ) #52 SMP Tue Oct 26 08:35:58

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...