Jetson nano and mcp2515 can module

GPIO07(168) and GPIO11(200) are just the names of pins on SODIMM connector.

If you do not have oscilloscope but have some other device (ex. multimeter), can you tell me if INT pin is going low on the MCP chip when you send the message from MCP?

Hi shgarg,
I will measure and inform you. But for god result I don’t have analog multimeter.
The other situation is I download the source code for JP4.5 and check the mcp251x.c file.The patches which you give us was not implement on the driver file. I change the source code according your patch file and compile it.
With these change I got additional this error on bellow. When I check this error from source code this is added by us it could be happen only gpio tag assigned value smaller than 0. I know no need to make any change in kernel dr

[ 8.654066] mcp251x spi0.0: failed to get GPIO from device tree
/* If GPIO based interrupt is passed in device tree */
gpio = of_get_named_gpio(np, “interrupts”, 0);
if (gpio < 0) {
dev_err(&spi->dev, “failed to get GPIO from device tree\n”);
}

else {
	ret = gpio_request(gpio, "mcp251x-gpio");
	if (ret) {
		dev_err(&spi->dev, "failed to request GPIO %d\n", gpio);
		return ret;
	}

	ret = gpio_export(gpio, false);
	if (ret) {
		dev_err(&spi->dev, "failed to export GPIO %d\n", gpio);
		return ret;
	}

	ret = gpio_direction_input(gpio);
if (ret) {
		dev_err(&spi->dev, "failed to set pin to input state\n");
		return -EINVAL;
	}

	/* IRQ setup */
	ret = gpio_to_irq(gpio);
	if (ret < 0) {
		dev_err(&spi->dev, "failed to map GPIO to IRQ: %d\n", ret);
		return -EINVAL;
	}

	spi->irq = ret;
}

Why are you applying the patches? You do not need to modify driver.
DTB is already present , just run with jetson-io

The new develeoper kit is not same as previous one. https://developer.download.nvidia.com/embedded/L4T/r32-3-1_Release_v1.0/Jetson_Nano_Developer_Kit_User_Guide.pdf?nxWSAnHlLttZWf06L5-hfMiBj4S4fXAnLsigT4QCsuoYV_OXLAIIj8NbFvzxYbaYGxKX5K5QuqupPE8zFkpRfPlXuADjlbzr63-WxVVrnce5yq71G61uuuQP4DkxWBUjFjc1wHqb6gZo58FwBmbCPcnj0M54k6S5YVk74na5PjhxtkAMQSrW63E in this manual you can see the previous carrier board . Does this dtb files work both carrier board.

Yes works for both A02 and B00

According to new manual my carrier board is B01. It is not A02 or B00.
Jetson Nano User Manual

When I save the configuration on jetson-io it return me with B00 .

 Configuration saved to file                
     /boot/kernel_tegra210-p3448-0000-p3449-0000-b00-mcp251x-can-controller.dtb.

yes still it will work.

Hi Shgarg ,
Ther is no activitty on CAN H and L pins. It is always 2.65 V . I also check PIN31 interrupt pin and it is always 5.1 V

@ Hi all, with all of your discussion below, i was able to understand some of steps and able to see CAN0 in my network. However, when i run command, ‘cansend can0 123#xyz’ or ‘candump can0’. I do not see any activity.

I am sending data continuously through can on Jetson nano. and running candump can0 but it doesn’t display anything, I am unable to find the reason what cause this happen. Also, when i am running cansend command, no data coming on other side node.

can someone guide me? Also, As you are not sending any more queries, are you able to send/receive data successfully now?

1 Like

hello baris, do you solve the problem, I have the same problem. Could you give me a help

1 Like

hi shgarg, my MCP nitialized successfully and interrupts assigned correctly under /proc/interrupts but no communication. (1) . I am sure 120 ohm termination is there on the bus (2) There is no activity on CAN H and L pins.
But it is ok on respberry pi

1 Like

Hi xudonglei2020, I have a working dts file modified from Linux_for_Tegra and Seed-Studio’s MCP implementation. I got it working on my Jetson Nano with an MCP2515 board from Joy-It (SBC-CAN01) running a 16 MHz oscillator. Feel free to try it.

To use:

  1. Clone the Seeed-Studio github repository as stated by andrew_h above from GitHub - Seeed-Studio/seeed-linux-dtoverlays: Device Tree Overlays for Seeed boards
  2. Download the dts file here and save it to seeed-linux-dtoverlays-master/overlays/jetsonnano
  3. In the folder seeed-linux-dtoverlays-master run “make all_jetsonnano”
  4. Remove the existing overlays in /boot - I got a conflict that prevented me from running jetson-io when both files were still present
    “sudo rm /boot/tegra210-p3448-0000-p3449-0000-a01-mcp251x.dtbo”
    “sudo rm /boot/tegra210-p3448-0000-p3449-0000-a02-mcp251x.dtbo”
  5. Copy the generated jetson-mcp251x.dtbo file from seeed-linux-dtoverlays-master/overlays/jetsonnano into /boot/
  6. Run jetson-io and configure for MCP251x

If you need to run a different oscillator frequency change it under clock-frequency on line 30 of the dts file
jetson-mcp251x.dts (3.8 KB)

I’ve been following this for a while because I too had some issues, and I would just put my 3½ cents worth of comments here. All of this was done with JetPack 4.5.1.

I have three MCP2515 modules: One from Mikroe, one that says NiRen on the pcb, and one with an identical board to the NiRen one, but it doesn’t have any other identifying print. Of those three, only one works, and it is the non-identifiable one. I tested 3 different NiRen ones, and as I mentioned, none of them worked. The Mikroe one had a 10 MHz oscillator, the other ones 8 MHz, so I updated the device tree, but it didn’t do anything. I tried with 2 different Mikroe boards.

The errors on the NiRen ones is, that they cannot receive at all. The Mikroe one will receive one frame, then the bus dies and the interface has to be restarted, after which it will be able to receive another frame. This would indicate that the 10 MHz change worked.

It seems absolutely arbitrary which things will work and which won’t.

Hi @shgarg ,

I have tried some solutions from the above thread but have not been able to send/receive any CAN data. Receiving data only one time when powering on jetson nano dev board with additional bytes, after receiving one data not able to receive it again.

cansend can0 123#ff
cansend can0 123#ff
cansend can0 123#ff

candump can0
can0 000 [2] 38 08
can0 123 [1] FF

  1. MCP2515 successfully initialized
    dmesg | grep mcp
    [ 7.833549] mcp251x spi0.0: failed to get GPIO from device tree
    [ 7.857741] mcp251x spi0.0 can0: MCP2515 successfully initialized.
    [ 7.872294] mcp251x spi1.0: failed to get GPIO from device tree
    [ 8.898680] mcp251x spi1.0: MCP251x didn’t enter in conf mode after reset
    [ 8.898694] mcp251x spi1.0: Probe failed, err=16
    [ 8.898709] mcp251x: probe of spi1.0 failed with error -16

  2. Interrupt
    cat /proc/interrupts | grep mcp
    299: 3 0 0 0 GPIO 200 Edge mcp251x

  3. ip -d -s link show can0
    4: can0: <NO-CARRIER,NOARP,UP,ECHO> mtu 16 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 10
    link/can promiscuity 0
    can state BUS-OFF restart-ms 0
    bitrate 500000 sample-point 0.750
    tq 250 prop-seg 2 phase-seg1 3 phase-seg2 2 sjw 1
    mcp251x: tseg1 3…16 tseg2 2…8 sjw 1…4 brp 1…64 brp-inc 1
    clock 4000000
    re-started bus-errors arbit-lost error-warn error-pass bus-off
    0 0 0 1 1 1 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
    RX: bytes packets errors dropped overrun mcast
    3 2 1 0 1 0
    TX: bytes packets errors dropped carrier collsns
    18446744073709551615 1 0 0 0 0

I am using jetpack4.5.1, I tried your dtb and dtbo and also complied new mcp251x.ko with patches that you have shared in above thread but its not working.
please help me.

Hi All
I am trying to interface mcp 2515 and tja1050 receiver (8Mhz)Crystal connected to Nano and one USB CAN Analyser connected to a windows machine. I first tried updating dtb with 8 Mhz crystal and was able to receive data using candump can0 command.But when I am using the command

cansend can0 123#FF

I am not getting any error but data is not being sent. please see the attached reply of command ip -d -s link show can0. At one time error frame with data 0 was sent.

ip -d -s link show can0
4: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
link/can promiscuity 0
can state ERROR-ACTIVE restart-ms 0
bitrate 1000000 sample-point 0.750
tq 125 prop-seg 2 phase-seg1 3 phase-seg2 2 sjw 1
mcp251x: tseg1 3…16 tseg2 2…8 sjw 1…4 brp 1…64 brp-inc 1
clock 8000000
re-started bus-errors arbit-lost error-warn error-pass bus-off
0 0 0 1 0 0 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
RX: bytes packets errors dropped overrun mcast
11 10 2 8 2 0
TX: bytes packets errors dropped carrier collsns
18446744073709551613 3 0 0 0 0

On issue i found is that whenever i try to send a data the can state changes to " BUS OFF" and i am not able to recieve any data on CAN_USB Analyser.
I also tried with changing dtb clock to 16Mhz and Tested bitrate 500kbps,250kbps but no results.
Someone please help me solve this issue.
Awaiting reply

Thanks in Advance

My jetson nano is jetpack4.51 version;
MCP251x.dtbo compiled by Seeed-Studio/seeed-linux-dtoverlays;

But when sudo ip link set can0 type can bitrate 500000 or sudo ip link set up can0, an error is reported: Cannot find device “can0”.

Excuse me, what’s the situation? And how to solve this problem?

I have followed your instructions, but in the end an error was reported: Cannot find device “can0”。

Please follow: