Jetson Nano and MCP2515 Can Module

Hi,

I upgrade my jetson nano to jetpack 4.5 today. I need to use MCP2515 CanBus module for some automotive projects. My mcp2515 is china version and the oscillator clock frequency is 8MHz. There is already an MCP2515 driver in /boot/ file. Which file I should configure and how? I have a Jetson Nano b00 version. Can you please guide me? I don’t know what to do.

Regards,

I converted kernel_tegra.dtb file to kernel_tegra.dts file. Do I need to change the below line to use MCP2515 with 8mhz clock frequency?

can_clock {
phandle = <0x136>;
linux,phandle = <0x136>;
clock-accuracy = <0x64>;
clock-frequency = <0x1312d00>; //should equal to clock-frequency=<0xf42400>;
#clock-cells = <0x0>;
compatible = “fixed-clock”;
};

Then after changing the line, Converting kernel_tegra.dts file to kernel_tegra.dtb file. After that what should I do?
Which pin number I need to connect on Jetson nano?

Sorry for the late response, is this still an issue to support?

Hi kayccc,

Thanks for reply. Forget about the above mentioned I will tell you what I did step by step.
I have followed andrew_h’s mentions to enable mcp2515 on jetson nano. I am using Jetpack 4.4.1 now.

MCP2515 Jetson Nano
INT Pin22
SCK Pin23
SI Pin19
SO Pin21
CS Pin24
GND GND
Vcc 3.3V

  1. Here is my dts file: MCP251x.dts.txt (3.0 KB)
  2. I converted this dts file to dtbo file and copy mcp2515.dtbo file to /boot/
    2.1 I copy andrew_h’s mcp251x.ko.txt file to /lib/modules/4.9.140-tegra/kernel/drivers/net/can/spi/ mcp251x.ko.txt (500.9 KB)
  3. run jetson-io.py >> Configure jetson for compatible hardware >> MCP2515x Controller and save reboot
  4. Setup can interface >> sudo ip link set can0 up type can bitrate 125000
  5. ifconfig:

can0: flags=193<UP,RUNNING,NOARP> 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

6.dmesg | grep spi

[ 0.465100] iommu: Adding device 7000d400.spi to group 7
[ 0.465412] iommu: Adding device 7000d600.spi to group 8
[ 0.465752] iommu: Adding device 70410000.spi to group 9
[ 4.312330] spi-tegra114 7000d400.spi: chipselect 0 already in use
[ 4.312337] spi_master spi0: spi_device register error /spi@7000d400/spi@0
[ 4.312347] spi_master spi0: Failed to create SPI device for /spi@7000d400/spi@0
[ 4.314365] tegra-qspi 70410000.spi: Prod settings list not found
[ 4.315589] qspi_mtd spi32766.0: MX25U3235F (4096 Kbytes)
[ 4.315597] qspi_mtd spi32766.0: mtd .name = spi32766.0, .size = 0x400000 (4MiB) .erasesize = 0x00001000 (4KiB) .numeraseregions = 0
[ 8.857234] mcp251x spi0.0: GPIO from device tree: 13
[ 8.862556] mcp251x spi0.0: request GPIO: 0
[ 8.871401] mcp251x spi0.0: export GPIO: 0
[ 8.880623] mcp251x spi0.0: input state of pin: 0
[ 8.886372] mcp251x spi0.0: map GPIO to IRQ: 112
[ 8.913993] mcp251x spi0.0 can0: MCP2515 successfully initialized.

  1. lsmod

    Module Size Used by
    fuse 103841 2
    zram 26166 4
    overlay 48691 0
    bnep 16562 2
    iwlmvm 368205 0
    mac80211 719792 1 iwlmvm
    btusb 40213 0
    btrtl 7318 1 btusb
    btbcm 8808 1 btusb
    btintel 10771 1 btusb
    iwlwifi 167043 1 iwlmvm
    cfg80211 589351 3 iwlmvm,iwlwifi,mac80211
    mcp251x 15575 0
    can_dev 13306 1 mcp251x
    spidev 13282 0
    userspace_alert 5665 0
    nvgpu 1580772 25
    bluedroid_pm 13912 0
    ip_tables 19441 0
    x_tables 28951 1 ip_tables

  2. cat /proc/interrupts | grep mcp
    112: 0 0 0 0 GPIO 13 Edge mcp251x

  3. cansend can0 01a#23223344AABBCCDD message have not seen by otherside

  4. For some reason spi0.cs0 causes RX errors and when I try to transmit the bus turns off.

    ip -details -statistics link show can0
    4: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 10
    link/can promiscuity 0
    can state ERROR-ACTIVE 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 0 0 0 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
    RX: bytes packets errors dropped overrun mcast
    2 3 0 3 0 0
    TX: bytes packets errors dropped carrier collsns
    18446744073709551615 1 0 0 0 0
    Regards,

On the other hand I have also tried on Jetpack 4.5 version.

There is already MCP2515 files in /boot/. So I connected 2 mcp2515 each other according to the pin numbers in dtbo file. But oscillator_clock_frequency set to 20 mhz because of that my mcp2515(8mhz) couldn’t read any message. What fixes do I need to make in Jetson Nano?

Hi.
The link I provide below for this issue does not working. Any updates?