Jetson Orin Nano GPIO Interrupt for MCP2515 on Jetpack 6

Hi, I am trying to follow this guide to configure a Jetson Orin Nano running Jetpack 6.0.2 to work with an MCP2515 running on SPI0. I got an invalid syntax error when adding these lines to extracted.dts:

interrupt-parent = <&gpio>;
interrupts = <TEGRA234_MAIN_GPIO(Q, 5) IRQ_TYPE_LEVEL_LOW>;

So, I did some digging and modified the dts file to add the following:

interrupt-parent = <0xe5>;
interrupts = <0xe5 0x7d 0x8>;

I am assuming the interrupt-parent and first byte in interrupts are the phandle for gpio@2200000, the second byte in interrupts is the Q5 port for the tegra234-gpio chip, and the third byte is IRQ_TYPE_LEVEL_LOW.

I am wondering if my understanding is correct, since the device tree compiles with dtc -I dts -O dtb -o modified.dtb extracted.dts no matter what value the interrupt-parent takes.

Here is the device tree source file (converted from .dtc to .txt)
extracted.txt (310.5 KB)

Hi TTHERALT,

Are you using the devkit or custom board for Orin Nano?

Could you verify with the latest JP6.2(r36.4.3)?

It is not necessary since interrupt-parent has been specified for phandle of gpio-controller.
I think you just need to configure it as following:

interrupt-parent = <0xe5>;
interrupts = <0x7d 0x8>;

Just to confirm, do I need to modify the .dtsi and defconfig files on a host machine, follow these instructions to rebuild the kernel, and then flash the custom Jetpack 6.2 kernel onto the Jetson Orin Nano with SDK Manager?

Are you using the devkit or custom board?

Please run the following command to check if the driver has been built into kernel image or built as a kernel module.

$  zcat /proc/config.gz | grep CONFIG_CAN_MCP251X

We would suggest using flash command to update custom BSP package.

Hi, I am using a devkit. I have tried reflashing, but I do not have a can1 interface. Running sudo ip link set can1 up type can bitrate 1000000 shows:

Cannot find device "can1"

Only running sudo ip link set can0 up type can bitrate 1000000 runs successfully, but it does not give any CAN readings using candump can0 when wiring the MCP2515 to the SPI0 pins and a device that outputs CAN (the device’s CAN data is read correctly from a Rasperry Pi 4B + MCP2515).

Running zcat /proc/config.gz | grep CONFIG_CAN_MCP251X shows the following (after re-flashing):

CONFIG_CAN_MCP251X=m
CONFIG_CAN_MCP251XFD=m
# CONFIG_CAN_MCP251XFD_SANITY is not set

This is what I tried:

  1. Ran the following:
sudo apt install git-core build-essential bc flex bison
cd /home/robomaster/Downloads/images/JetPack_6.2_Linux_JETSON_ORIN_NANO_TARGETS/Linux_for_Tegra/source
./source_sync.sh -k -t jetson_36.4.3
  1. Modified kernel/kernel-jammy-src/arch/arm64/configs/defconfig:
...
CONFIG_CAN_MCP251X=y
CONFIG_CAN_MCP251XFD=y
  1. Modified hardware/nvidia/t23x/nv-public/nv-platform/tegra234-p3768-0000+p3767-xxxx-nv-common.dtsi to the following:
...
                can_clock: can_clock {
                        compatible = "fixed-clock";
                        #clock-cells = <0>;
                        clock-frequency = <25000000>;
                        clock-accuracy = <100>;
                };

                /* SPI1, 40pin header, Pin 19(MOSI), Pin 21(MISO), Pin 23(CLK), Pin 24(CS) */
                spi@3210000{
                        status = "okay";
                        spi@0 {
                                compatible = "microchip,mcp2515";
                                reg = <0x0>;
                                spi-max-frequency = <2000000>;
                                interrupt-parent = <&gpio>;
                                interrupts = <TEGRA234_MAIN_GPIO(Q, 5) IRQ_TYPE_LEVEL_LOW>;
                                clocks = <&can_clock>;
                                nvidia,enable-hw-based-cs;
                                controller-data {
                                        nvidia,enable-hw-based-cs;
                                        nvidia,rx-clk-tap-delay = <0x10>;
                                        nvidia,tx-clk-tap-delay = <0x0>;
                                };
                        };
...
  1. Ran the following:
cd /home/robomaster/Downloads/images/JetPack_6.2_Linux_JETSON_ORIN_NANO_TARGETS/Linux_for_Tegra/source
export CROSS_COMPILE=/home/robomaster/Downloads/aarch64--glibc--stable-2022.08-1/bin/aarch64-buildroot-linux-gnu-
make -C kernel
export INSTALL_MOD_PATH=/home/robomaster/Downloads/images/JetPack_6.2_Linux_JETSON_ORIN_NANO_TARGETS/Linux_for_Tegra/rootfs/
sudo -E make install -C kernel
cp kernel/kernel-jammy-src/arch/arm64/boot/Image ../kernel/Image
export KERNEL_HEADERS=$PWD/kernel/kernel-jammy-src
make dtbs
cp kernel-devicetree/generic-dts/hardware/nvidia/t23x/nv-public/nv-platform/* ../kernel/dtb/
sudo ./apply_binaries.sh
sudo ./tools/kernel_flash/l4t_initrd_flash.sh --external-device mmcblk0p1 \
  -c tools/kernel_flash/flash_l4t_external.xml -p "-c bootloader/generic/cfg/flash_t234_qspi.xml" \
  --showlogs --network usb0 jetson-orin-nano-devkit internal
  1. Booted up the Jetson, enabled SPI1 with the following, and rebooted:
sudo /opt/nvidia/jetson-io/jetson-io.py

I am flashing by plugging in a USB-C cable from my host to the Jetson, shorting pins 9/10, and inserting an SD card into the Jetson. (flashing to mmcblk1p1 shows that /dev/mmcblk1p1 was not found)

Also here is the output of sudo dmesg for can0:

mttcan c310000.mttcan can0: Bitrate set
mttcan_controller_config: ctrlmode 0
mttcan c310000.mttcan can0: Bitrate set
IPV6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
can: controller area network core
NET: Registered PF_CAN protocol family
can: raw protocol

Please share the full dmesg to check if the mcp2515x driver has been probe correctly.

I’m curious that why you read it as m here.

But it seems you configure it as y in kernel config.

I rebuilt the kernel and ran

cp kernel-devicetree/generic-dts/dtbs/* ../kernel/dtb/

instead of

cp kernel-devicetree/generic-dts/hardware/nvidia/t23x/nv-public/nv-platform/* ../kernel/dtb/

Now, I can see the MCP2515 loaded in my dmesg log:
log.txt (60.2 KB)

However, I still do not get CAN readings after running:

sudo ip link set can1 up type can bitrate 500000
candump can1

and plugging the MCP2515 into a CAN motor device.

Here is my dtsi and defconfig files.
defconfig.txt (31.3 KB)
tegra234-p3768-0000+p3767-xxxx-nv-common.dtsi.txt (7.8 KB)

I also tried plugging in a custom board with an MCP2515 chip into the SPI0 pins, but running sudo ip link set can1 up type can bitrate 500000 hangs and causes the NetworkManager to freeze.

Any help would be appreciated.

Could you share the block diagram of your connections between Orin Nano devkit and MCP2515 module?

It seems you’ve configured MCP2515 for both spi@3210000 and spi@3230000.
Have you tried to verify with the similar connections as https://elinux.org/Jetson/L4T/peripheral/#MCP2515_Verification?

In addition, have you configured the pinmux for SPI related pins before use?

The connection between the devkit and MCP2515 on the custom board (originally designed for a Raspberry Pi 4B, but connected using jumper wires) is as follows:

Custom Board → Devkit
3V3 → 3V3
SPI0 MOSI → SPI0 MOSI
SPI0 MISO → SPI0 MISO
SPI0 SCLK → SPI0 SCLK
SPI0 CS0 → SPIO CS0
GPIO 25 → GPIO01 (interrupt pin)

Yes, I have also tried wiring the devkit to a MCP2515 CAN bus module according to this diagram:


Connecting VCC to 5V (pin 2) made the MCP2515 fail to initialize according to the Jetson’s dmesg logs. Connecting VCC to 3V3 (pin 1) instead led to the dmesg logs described in my prior reply, where the driver successfully initializes but is unable to read and write CAN.

Yes, I enabled both spi interfaces using sudo /opt/nvidia/jetson-io/jetson-io.py

It seems you connected Jetson and RPI4 through SPI interface directly.
And you try using RPI4 as SPI master and Jetson as SPI slave?
Where is MCP2515 module here?

What I mean is using MCP2515 module for each SPI interface(SPI0 and SPI1) as the full diagram shown.

Where is MCP2515 module here?

I want to replace the RPI4 with the Jetson such that the Jetson is the SPI master and communicates with CAN motors (SPI slaves).

What I mean is using MCP2515 module for each SPI interface(SPI0 and SPI1) as the full diagram shown.

I tried wiring another MCP2515 module to SPI1 to set up the loopback test, but I get a similar bug as before where running sudo ip link set can2 up type can bitrate 500000 hangs and causes the NetworkManager to freeze.

Okay, then I just want to check your connection for Jetson and MCP2515 and CAN motor.

Please provide the complete dmesg log at this moment and confirm whether you have connected the devices exactly as we did. We have verified the setup on our setup, and it should work.