Jetson nano and mcp2515 can module

Hi,
Actually because of working remotely, am stuck with mcp. But the steps i used before to get it working, will share those steps again in detail soon (in 1-2 days). Please wait for a day or two max, i will share.

Thanks,
Shubhi

1 Like

Hi shgarg,
What is the last condition about the detailed documentation.
Thanks,
Baris

1 Like

Hi Everyone,
I am attaching updated mcp driver and dtb having the changes. Please follow below steps:

  1. Connect first MCP251x chip to SPI1 on 40-pin, use CS0 pin, connect INT on Pin 31 (GPIO Z.0)
  2. Connect second MCP251x chip to SPI2 on 40-pin, use CS0 pin, connect INT on Pin 32 (GPIO V.0)
  3. Copy mcp251x.ko on target under /lib/modules/4.9.140-tegra/kernel/drivers/net/can/spi/
  4. Copy tegra210-p3448-0000-p3449-0000-a02-mcp251x.dtbo under /boot/
  5. Copy tegra210-p3448-0000-p3449-0000-a02.dtb under /boot/dtb/
  6. Run /opt/nvidia/jetson-io/jetson-io.py
  7. Select Configure Jetson for compatible hardware
  8. Select MCP251x CAN Controller
  9. Save and reboot
  10. Make CAN0 and CAN1 inerface up on network:
    ip link set can0 up type can bitrate 500000
    ip link set can1 up type can bitrate 500000

Let me know if you are stuck somewhere.mcp.zip (206.1 KB)

Hi shgarg ,
Thank you for share. I do everything successfully. This command “ip link set can0 up type can bitrate 500000” successfully. But I get error with “ip link set can0 up”. The fault is “RTNETLINK answers: Invalid argument”. I thin the reason is oscillator clock frequency . My mcp2515 is china version and oscillator clock frequency is 8MHz. I think your setup is for 20Mhz. I recompile the dtb file and change clock-frequency from <0x1312d00> to <0x7a1200> but know I get this message “Cannot initialize MCP2515. Wrong wiring?”.

Hi,
if you want to use 8MHz, Please use <0xf42400> which is actually 16Mhz. MCP driver divides frequency to half so we use double frequency. Please try and let me know, also make sure 200 ohm resistance is present between CAN Bus.

Thanks,
Shubhi

I tried stil same I get the RTNETLINK answers: Invalid argument. When I checked this link my problem is exactly same. About GPIO interrupt issues - NXP Community I have same issue with this documentation. It looks problem with the interrupt pin . When I convert the dtbo file to dts the interrupt pin is <0xffffffff 0xc8 0x1>, but when I checked the assigned dtb file from extlinux.conf it is <0x56 0xc8 0x1>, I could not understood the pin mapping. How it is assigned to pin 31.
P.S my mcp2515 is working with rpi3 and aurdino board.

Hi,
You can check interrupt assigned to mcp device using “cat /proc/interrupts | grep mcp”
Let me know if you are not seeing any interrupt for mcp using above command.
About interrupt pin mapping:
In final dtb, it is giving 0x56 because of gpio node pointer.
gpio@6000d000 {
compatible = “nvidia,tegra210-gpio”, “nvidia,tegra124-gpio”, “nvidia,tegra30-gpio”;
reg = <0x0 0x6000d000 0x0 0x1000>;
interrupts = <0x0 0x20 0x4 0x0 0x21 0x4 0x0 0x22 0x4 0x0 0x23 0x4 0x0 0x37 0x4 0x0 0x57 0x4 0x0 0x59 0x4 0x0 0x7d 0x4>;
#gpio-cells = <0x2>;
gpio-controller;
#interrupt-cells = <0x2>;
interrupt-controller;
gpio-ranges = <0x3b 0x0 0x0 0xf6>;
status = “okay”;
gpio-init-names = “default”;
gpio-init-0 = <0x3c>;
gpio-line-names = [00 00 00 00 00 00 00 00 00 00 00 00 53 50 49 31 5f 4d 4f 53 49 00 53 50 49 31 5f 4d 49 53 4f 00 53 50 49 31 5f 53 43 4b 00 53 50 49 31 5f 43 53 30 00 53 50 49 30 5f 4d 4f 53 49 00 53 50 49 30 5f 4d 49 53 4f 00 53 50 49 30 5f 53 43 4b 00 53 50 49 30 5f 43 53 30 00 53 50 49 30 5f 43 53 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 47 50 49 4f 31 33 00 00 00 00 00 00 00 00 00 00 00 00 55 41 52 54 31 5f 52 54 53 00 55 41 52 54 31 5f 43 54 53 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 49 32 53 30 5f 46 53 00 49 32 53 30 5f 44 49 4e 00 49 32 53 30 5f 44 4f 55 54 00 49 32 53 30 5f 53 43 4c 4b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 47 50 49 4f 30 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 47 50 49 4f 30 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 47 50 49 4f 31 32 00 00 00 00 00 00 47 50 49 4f 31 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 47 50 49 4f 30 39 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 53 50 49 31 5f 43 53 31 00 00 00 00 00 00 00 00];
linux,phandle = <0x56>;
** phandle = <0x56>;**
Here linux,phandle is 0x56, that’s why it got assigned.
Is the CAN not up in ifconfig?
Can you please check if can0 and can1 up in ifconfig?
Also, please provide result of “lsmod”

Thanks,
Shubhi

Hi shgarg
I followed your steps, but in step 9 when I want to save and reboot I get an error
FATAL ERROR!
Failed to overlay /boot/dtb/tegra210-p3448-0000-p3449-0000-b00.dtb
with /boot/tegra210-p3448-0000-p3449-0000-a02-mcp251x.dtbo!

Press any key to terminate
Thanks!

Hi,
Sorry for the mistake.
DTB should be copied to /boot/dtb/ , I have mentioned to copy in /boot/
Also, I shared A02 dtb, you can copy A02 dtb to B00 dtb or just rename A02 dtb to B00 dtb. Make sure, dtb I gave should be in /boot/dtb/tegra210-p3448-0000-p3449-0000-b00.dtb

  • "cat /proc/interrupts | grep mcp” I can not see any assigned interrupt.

  • lsmod
    bnep 16562 2
    fuse 103841 2
    xt_multiport 3269 6
    iptable_filter 2481 1
    ip6table_filter 2481 1
    ip6_tables 19493 1 ip6table_filter
    zram 26166 4
    overlay 48691 0
    spidev 13282 0
    can 46600 0
    mcp251x 12782 0
    can_dev 13306 1 mcp251x
    nvgpu 1575721 18
    bluedroid_pm 13912 0
    ip_tables 19441 1 iptable_filter
    x_tables 28951 5 xt_multiport,ip_tables,iptable_filter,ip6table_filter,ip6_tables

  • I just have one mcp2515 therefor just use can0 . ifconfig can0 result is
    can0: flags=128 mtu 16
    unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 10 (UNSPEC)
    RX packets 0 bytes 0 (0.0 B)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 0 bytes 0 (0.0 B)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

  • dmesg | grep spi
    [ 0.442101] iommu: Adding device 7000d400.spi to group 7
    [ 0.442375] iommu: Adding device 7000d600.spi to group 8
    [ 0.442681] iommu: Adding device 70410000.spi to group 9
    [ 4.165853] tegra-qspi 70410000.spi: Prod settings list not found
    [ 4.173187] qspi_mtd spi32766.0: MX25U3235F (4096 Kbytes)
    [ 4.178619] qspi_mtd spi32766.0: mtd .name = spi32766.0, .size = 0x400000 (4MiB) .erasesize = 0x00001000 (4KiB) .numeraseregions = 0
    [ 6.735407] mcp251x spi0.0 can0: MCP2515 successfully initialized.
    [ 6.752924] mcp251x spi1.0: Cannot initialize MCP2515. Wrong wiring?
    [ 6.761004] mcp251x spi1.0: Probe failed, err=19

Did you copy mcp251x.ko?

The file was already there . Therefore I did not copied.

I have updated mcp driver because it did not have gpio based interrupts. Please copy and check.

I copied. on lsmod I couldn’t see any more mcp251x loaded. When I tried to load with command sudo modprobe mcp251x the result is “modprobe: ERROR: could not insert ‘mcp251x’: Exec format error”. I think I have some compatibility issue with this kernel file which you upload .

You need to reboot system again after copying.

I already did it. What is difference between your mcp251x driver and preloaded driver.

Hi shgarg
When I rename it to tegra210-p3448-0000-p3449-0000-b00.dtb, then I cant run /opt/nvidia/jetson-io/jetson-io.py.

Its just open the gui and then close immediately

Thanks !

I already copied to /boot/dtb. Otherwise Run /opt/nvidia/jetson-io/jetson-io.py scirpt is not working.

Yes I did the same, but when I rename tegra210-p3448-0000-p3449-0000-a02.dtb to tegra210-p3448-0000-p3449-0000-b00.dtb in /boot/dtbthen I get a problem with the /opt/nvidia/jetson-io/jetson-io.py script does not work

I had same issue and I observe the extracted file was not correct . Try again to extract the .dtb file from mcp .