Jetson nano and mcp2515 can module

Okay it’s the same as me, I Will share tomorrow when I have the Jetson in front of me 😄

Hey, I have make more tests but I don’t found the reason for the half bitrate.
Example:
Set Jetson Nano to 500000
$ sudo ip link set can0 up type can bitrate 500000
Then I must set the the second CAN member to 250000 an everything is working fine.

I use the .ko with the patch from shgarg.

Hi denis
This is for dtb and dts

and this is for .ko

and try to follow these steps again

Hi shgarg,
One update more
Actually I think the problem that I can’t send mostly happens with can0, most of the time im able to send with can1 and receive on can0, but not to send with can0.
Thanks

Thanks very much for sharing. It’s now working to the point where the interface is appearing. I still have a lot of testing to do but it’s a big step up from yesterday.

Hi shgarg
Is there any updates 😄

Hi everyone,
I used .dtbo and .dtb files of @jetson_spi. And i also wrote my own driver file like this http://www.macs.hw.ac.uk/~hwloidl/hackspace/linux/drivers/net/can/spi/mcp251x.c

  • I followed these steps:

Jetson nano and mcp2515 can module - #24 by shgarg

$ dmesg | grep mcp
[ 0.562011] GPIO line 200 (mcp2515_int) hogged as input
[ 8.786868] mcp251x: loading out-of-tree module taints kernel.
[ 70.862175] mcp251x spi0.0: failed to acquire irq 0

I have some questions. Hope you help me solve these

  1. I want to add some debug statements (printk or
    dev_dbg) to the MCP251x driver’s “mcp251x_can_probe” function. But I never see any of the debug prints from the MCP251x’s probe function on dmesg . Why? I can’t figure out why this probe function isn’t being called
  2. Why do i always get message “mcp251x: loading out-of-tree module taints kernel” ?
    Thank you very much.

Hi jetson_spi,
Our offices are still closed. Am unable to setup MCP. ALthough am trying to make changes I have shared here so that all the changes are in our next release.
I need help from you.
I would like to know if mcp251x driver needs this change:
+gpio_direction_output(gpio,1)
if you remove this line, can you let me know if communication still works?

Thanks
Shubhi

Hi shgarg
So I removed the line gpio_direction_output(gpio,1) from the driver and recompiled. Now its not possible to send but only receive :)
So Yes I think gpio_direction_output(gpio,1) needs to be in the driver.
Okay I will wait, but is it possible for you to help me to get the number 3 mcp up and running until you have a solution for the other issue. So I can use 3 mcp to receive from can :)
Thanks!

Hi jetson_spi,
I believe if you are able to receive wthout gpio_direction_output(gpio,1), you must be able to send also. Otherwise, it is some other issue, not related to gpio. When you send, are you getting any interrupts in cat /proc/interrupts | grep mcp?
For 3rd MCP, I have not tried this but you can try by adding CS1 of SPI0. I will share dtb for you to try out by end of the day.

Thanks,
Shubhi

Hi nobby42,
Which is the second CAN member are you using?
is it the same MCP on Nano which is connected to another SPI on Nano ?
can you share below outputs:
ip -d -s link show can0
ip -d -s link show can1

Thanks,
Shubhi

Hi shgarg
Im sorry unluckly in that moment I was not able to send with the can, as you know sometimes its work and sometimes not. but yes sometimes im able to send when I have removed the gpio_direction_output(gpio,1) from the driver.
Thank you so much for you will share new the dtb and is there other steps to do.
Thanks!

Hi shgarg,

I have fix the problem.
First I set the clockrate to <0x7A1200> in the dts file.
But then, when I set the bit rate to 1000000 and I get this.
$ sudo ip link set can0 up type can bitrate 1000000
$ RTNETLINK answers: Numerical argument out of domain
I change the oscillator on the MCP2515 board from 8Mhz to 16Mhz and set the can clock frequenz and the SPI max frequenz in the dts file to <0xf42400>.
Everthing work fine. I have different CAN member (Raspberry with MCP2515, BananaPI with intern CAN controller, STM32F103 Controller with intern CAN controller) on the bus.

Thanks
Norbert

Hi shgarg
Any updates on the new dtb, so I can bring the can3 interface up and use the 3rd MCP
Thanks!

Hi,
Please try with the attached dtb:
tegra210-p3448-0000-p3449-0000-a02-mcp251x.zip (1.1 KB)

Connect 1st MCP to SPI1 CS0
2nd MCP to SPI1 CS1
3rd MCP to SPI2 CS0

Thanks,
Shubhi

Thanks shgarg what is the interrupt pin 😄

INT pin is Pin 15 on 40-pin.

1 Like

Hi shgarg
Thanks for sharing the new dtbo for the 3rd mcp, but it dont seems to work and im not able to either convert the dtbo to dts, Maybe because my board is b00 and the file you shared is a02, I dont know if it matter. Maybe if you can copy paste the code I need to add in the dtbo I already have on my system and show me where to add

And one more thing as it is now INT pin is on pin 32 and 31, is there any documentiation on how to know the pins, because in the dtbo you shared it is interrupt = <0xffffffff 0xa8 0x1>; I dont understand this is either pin 31 or 32
Thanks😄

Hi, thanks for these steps. I faced some problems down here, hope that you could help:

  1. I am pretty new to Jetson Nano and just installed the fresh Ubuntu. I have not /boot/dtb folder
  2. I also do not have the /opt/nvidia/jetson-io folder but /jetson-gpio. I also miss the jetson-io.py file in these subfolders
  3. I run only 1 MCP2515 chip, is it okay?

Thanks,
Regards.

Hello all, I have been trying to figure out how to get the one MCP2515 working, but trying to follow this post as lead to me losing my mind. The files that Jetson_SPI uploaded are no longer available. I have the B00 board with Jetpack 4.4. Does anyone have the DTB and .ko to make the MCP work still?
Thank you