Not able to interface MCP2515 PICtal plus daugher board SPI to Jetson orin nano 8GB SPI0 interface

Hi,
I am trying to interface the Jetson Orin Nano 8GB development kit with the MCP2515 PICtal Plus daughter board but cannot get the MISO data from the slave (MCP2515).

MCP2515 PICtail Plus Daughter Board User’s Guide

Below are the connections that I made between the Jetson and the MCP2515 daughter board.

MCP2515 - Jetson header

INT - 38
SCK - 23
SDI - 19
SDO - 21
CS - 24
VDD - 2
VSS - 6

Below are the pinmuxing and the device tree node for the MCP2515,

I verified SPI0, which is on the 40-pin header, with the spidev loopback test, and I can successfully loopback test the SPI,

root@jetson-orin-nano-devkit-nvme:/home/hunter# ./spidev_test -D /dev/spidev0.0 -s 100000 -v
spi mode: 0x0
bits per word: 8
max speed: 100000 Hz (100 kHz)
TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D |…@…|
RX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D |…@…|
root@jetson-orin-nano-devkit-nvme:/home/hunter#

But when I enable the MCP2515 node and load the driver using insmod, I get the below error,

[ 512.096225] mcp251x spi0.0: MCP251x didn’t enter in conf mode after reset
[ 512.097216] mcp251x spi0.0: Probe failed, err=110
[ 512.097227] mcp251x: probe of spi0.0 failed with error -110

I am not able to understand if my device tree node is incorrect or the pinmux is incorrect because I am not able to get anything on the SDO file from the slave. I can get the clock; the CS line is toggling, SDI has data, but the SDO has no signal.

If you could help me debug this it would be great.

Hello,

Thanks for visiting the NVIDIA Developer Forums.
To ensure better visibility and support, I’ve moved your post to the Jetson category where it’s more appropriate

Cheers,
Tom

Hi trezen.parmar,

What’s the Jetpack version in use?

Could you refer to https://elinux.org/Jetson/L4T/peripheral/#MCP2515_Verification for the steps to port MCP2515 on Orin Nano.

Hi KevinFFF,
The Jetpack version that I am using is 6.2.1

From the log you shared, it seems you configued something wrong so that the driver probed failed.

Hi KevinFFF,

The MCP2515 daughter board I was using had the MOSI and MISO cross-connected internally, so I had to connect the SO to MISO and the SI to MOSI directly.

This worked, and the driver probed successfully.

Now I am trying to test the CAN side.

I have connected a Waveshare USB CAN converter to the CAN side and I am trying to send the data to the CAN node but I think the node is not acknowledging the data.

root@jetson-orin-nano-devkit-nvme:/home/hunter# ip link set can1 type can bitrate 500000
root@jetson-orin-nano-devkit-nvme:/home/hunter#
root@jetson-orin-nano-devkit-nvme:/home/hunter#
root@jetson-orin-nano-devkit-nvme:/home/hunter# ip link set can1 up
root@jetson-orin-nano-devkit-nvme:/home/hunter#
root@jetson-orin-nano-devkit-nvme:/home/hunter# ip -details link show can1
5: can1: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
link/can promiscuity 0 minmtu 0 maxmtu 0
can state ERROR-ACTIVE restart-ms 0
bitrate 500000 sample-point 0.850
tq 100 prop-seg 8 phase-seg1 8 phase-seg2 3 sjw 1 brp 1
mcp251x: tseg1 3..16 tseg2 2..8 sjw 1..4 brp 1..64 brp_inc 1
clock 10000000 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 parentbus spi parentdev spi0.0
root@jetson-orin-nano-devkit-nvme:/home/hunter#
root@jetson-orin-nano-devkit-nvme:/home/hunter#
root@jetson-orin-nano-devkit-nvme:/home/hunter# cansend can1 123#AABBCCDD
root@jetson-orin-nano-devkit-nvme:/home/hunter#
root@jetson-orin-nano-devkit-nvme:/home/hunter# ip -details link show can1
5: can1: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
link/can promiscuity 0 minmtu 0 maxmtu 0
can state ERROR-PASSIVE restart-ms 0
bitrate 500000 sample-point 0.850
tq 100 prop-seg 8 phase-seg1 8 phase-seg2 3 sjw 1 brp 1
mcp251x: tseg1 3..16 tseg2 2..8 sjw 1..4 brp 1..64 brp_inc 1
clock 10000000 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 parentbus spi parentdev spi0.0
root@jetson-orin-nano-devkit-nvme:/home/hunter#

Can you help me debug this?

Hi KevinFFF,

Do you have any updates on this? We have a deadline to release this change.
We are blocked from enabling the additional CAN interface.

Good to hear that the driver is probed successfully now.

Is there any error in dmesg at this moment?
Please share the full device tree and dmesg for further check.

/ {
overlay-name = “SPI0 MCP2515 CAN”;
jetson-header-name = “Jetson 40pin Header”;

compatible = "nvidia,p3768-0000+p3767-0000\0nvidia,p3768-0000+p3767-0001\0nvidia,p3768-0000+p3767-0003\0nvidia,p3768-0000+p3767-0004\0nvidia,p3768-0000+p3767-0005\0nvidia,p3768-0000+p3767-0000-super\0nvidia,p3768-0000+p3767-0001-super\0nvidia,p3768-0000+p3767-0003-super\0nvidia,p3768-0000+p3767-0004-super\0nvidia,p3768-0000+p3767-0005-super\0nvidia,p3509-0000+p3767-0000\0nvidia,p3509-0000+p3767-0001\0nvidia,p3509-0000+p3767-0003\0nvidia,p3509-0000+p3767-0004\0nvidia,p3509-0000+p3767-0005";

/* Disable existing spidev device on SPI0 CS0 */
fragment@0 {
    target-path = "/bus@0/spi@3210000/spi@0";
    __overlay__ {
        status = "disabled";
    };
};

/* Add MCP2515 CAN controller on SPI0 CS0 */
fragment@1 {
    target-path = "/bus@0/spi@3210000";
    __overlay__ {
        status = "okay";
        #address-cells = <1>;
        #size-cells = <0>;

        can_clock: can_clock {
            compatible = "fixed-clock";
            #clock-cells = <0>;
            clock-frequency = <20000000>;
            clock-accuracy = <100>;
        };

        mcp2515@0 {
            status = "okay";
            compatible = "microchip,mcp2515";
            reg = <0>;
            spi-max-frequency = <5000000>;
            interrupt-parent = <&gpio>;
            interrupts = <TEGRA234_MAIN_GPIO(I, 1) IRQ_TYPE_LEVEL_LOW>;
            clocks = <&can_clock>;
            nvidia,enable-hw-based-cs;
        };
    };
};

};

Please also provide the dmesg when you try to send the data.

Do you actually connect PI.01 from Orin Nano and use it as Input?

Here is the dmesg,

[ 78.846531] mcp251x spi0.0 can1: MCP2515 successfully initialized.
[ 78.846550] mcp251x spi0.0: ===== MCP2515 Register Dump =====
[ 78.847170] mcp251x spi0.0: CANSTAT = 0x20
[ 78.847233] mcp251x spi0.0: CANCTRL = 0x60
[ 78.847289] mcp251x spi0.0: EFLG = 0x00
[ 78.847344] mcp251x spi0.0: TEC = 0
[ 78.847399] mcp251x spi0.0: REC = 0
[ 78.847455] mcp251x spi0.0: CANINTF = 0x40
[ 78.847724] mcp251x spi0.0: CNF1 = 0x00
[ 78.847784] mcp251x spi0.0: CNF2 = 0x00
[ 78.848045] mcp251x spi0.0: CNF3 = 0x00
[ 78.848048] mcp251x spi0.0: ===============================

these logs are when I try to send the data, I have printed the regs of the MCP2515, apart from these there are no other logs.
[ 5553.567470] mcp251x spi0.0: Test, mcp251x_open:1312
[ 5553.576792] mcp251x spi0.0: ===== MCP2515 Register Dump =====
[ 5553.577158] mcp251x spi0.0: CANSTAT = 0x00
[ 5553.577535] mcp251x spi0.0: CANCTRL = 0x00
[ 5553.577893] mcp251x spi0.0: EFLG = 0x00
[ 5553.577945] mcp251x spi0.0: TEC = 0
[ 5553.578307] mcp251x spi0.0: REC = 0
[ 5553.578357] mcp251x spi0.0: CANINTF = 0x00
[ 5553.578412] mcp251x spi0.0: CNF1 = 0x04
[ 5553.578737] mcp251x spi0.0: CNF2 = 0xB5
[ 5553.578791] mcp251x spi0.0: CNF3 = 0x01
[ 5553.578793] mcp251x spi0.0: ===============================
[ 5553.579867] IPv6: ADDRCONF(NETDEV_CHANGE): can1: link becomes ready
[ 5562.904358] mcp251x spi0.0: [BEFORE HW TX] CANSTAT=0x00 CANCTRL=0x00 CANINTE=0x3F CANINTF=0x00 EFLG=0x00 TEC=0 REC=0 TXB0CTRL=0x00
[ 5562.904408] mcp251x spi0.0: TXB0CTRL: ABTF=0 MLOA=0 TXERR=0 TXREQ=0
[ 5562.904964] mcp251x spi0.0: [AFTER HW TX] CANSTAT=0x00 CANCTRL=0x00 CANINTE=0x3F CANINTF=0x80 EFLG=0x00 TEC=16 REC=0 TXB0CTRL=0x18
[ 5562.904969] mcp251x spi0.0: TXB0CTRL: ABTF=0 MLOA=0 TXERR=1 TXREQ=1
[ 5562.969896] mcp251x spi0.0: [AFTER 50ms HW TX] CANSTAT=0x00 CANCTRL=0x00 CANINTE=0x3F CANINTF=0x80 EFLG=0x00 TEC=16 REC=0 TXB0CTRL=0x18
[ 5562.969913] mcp251x spi0.0: TXB0CTRL: ABTF=0 MLOA=0 TXERR=1 TXREQ=1

Yes I have actually connected the interrupt pin and I can see the interrupts increase in the ‘cat /proc/interrupts’.

Can you give me more clearance that are there any more configuration I need to do to make this SPI to CAN module work from the jetson side, in terms of the clock and other parameters.

I have set the CAN clock as 20MHz, but in the driver the it gets divided by 2 and becomes 10MHz.

is this expected behavior?

root@jetson-orin-nano-devkit-nvme:/home/hunter# ip -details link show can1
6: can1: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
link/can promiscuity 0 minmtu 0 maxmtu 0
can state ERROR-ACTIVE restart-ms 0
bitrate 10000 sample-point 0.850
tq 5000 prop-seg 8 phase-seg1 8 phase-seg2 3 sjw 1 brp 50
mcp251x: tseg1 3..16 tseg2 2..8 sjw 1..4 brp 1..64 brp_inc 1
clock 10000000 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 parentbus spi parentdev spi0.0

Could you apply the patch from the following thread to check if it could help for your case?
Jetson orin nano SPI Speed not changing - #9 by KevinFFF

I am getting the voltage at the MOSI as 3V3, and the CS goes all the way to 0V. So I don’t think this will apply to my case.

I verified my hardware using the CAN0 interface of the Jetson itself.

We have verified MCP2515 module working with Orin Nano with both JP5.x and JP6.x.

It is the known SPI CS issue we found in JP6.
Please kindly give it a try.

Could you also get 2 MCP2515 modules and connect them together to verify?

This issue is resolved.
I had to replace the crystal on the MCP2515 PICtail Plus daughter board I was using; the crystal was faulty, or the part was replaced, which showed 30 MHz instead of 20 MHz.

I replaced the 16MHz crystal and changed the overlay CAN frequency to 16 MHz, and it was working.

I did not include the hardware-based CS change in the kernel that you recommend.

Thank you for helping us out.

Thank you for sharing the root cause in your case.
This will likely help others who encounter a similar issue with the external crystal clock.