Issues with Configuring MCP2515 on Jetson Orin NX - Device Tree Overlay and Pinmux Setup

Hello everyone,

I’m currently trying to integrate an MCP2515 CAN controller with my Jetson Orin NX (devkit). I’ve been following some instructions to modify the Device Tree and set up the pinmux configuration, but I’m encountering several issues.
First of all, I connected MCP2515 with spi1 on 40p-header (19,21,23,24,26) and interrupt pin on PIN31( PQ.06). Next, I install mcp251x.ko module and check it with “lsmod”. I created the .dts by modifying the Seeed Studio
mcp2515.dts for the compatible with Orin NX and build it to .dtbo:

/dts-v1/;
/plugin/;

#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/pinctrl/pinctrl-tegra.h>
#include <dt-bindings/gpio/tegra234-gpio.h>
#include <dt-bindings/pinctrl/tegra234-p3767-0000-common.h>
/ {
        overlay-name = "MCP251x CAN Controller";
        jetson-header-name = "Jetson 40pin Header";
        compatible = "nvidia,p3768-0000+p3767-0000", "nvidia,p3509-0000+p3767-0000", "nvidia,p3767-0000", "nvidia,tegra234", "nvidia,tegra23x";

        fragment@0 {
                target-path = "/";
                __overlay__ {
                        clocks {
                                can_clock: can_clock {
                                        compatible = "fixed-clock";
                                        #clock-cells = <0>;
                                        clock-frequency = <16000000>;
                                        clock-accuracy = <100>;
                                };
                        };
                };
        };

        fragment@1 {
                target-path = "/spi@3210000/spi@0";
                __overlay__ {
                        status = "disabled";
                };
        };

        fragment@2 {
                target-path = "/spi@3210000/spi@1";
                __overlay__ {
                        status = "disabled";
                };
        };

        fragment@3 {
                target = <&spi0>;
                __overlay__ {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        spi@0 {
                                #address-cells = <1>;
                                #size-cells = <0>;
                                status = "okay";
                                compatible = "microchip,mcp2515";
                                reg = <0x0>;
                                spi-max-frequency = <10000000>;
                                nvidia,enable-hw-based-cs;
                                nvidia,rx-clk-tap-delay = <0x7>;
                                clocks = <&can_clock>;
                                interrupt-parent = <&tegra_main_gpio>;
                                interrupts = <TEGRA234_MAIN_GPIO(Q, 6) IRQ_TYPE_LEVEL_LOW>;
                                controller-data {
                                        nvidia,cs-setup-clk-count = <0x1e>;
                                        nvidia,cs-hold-clk-count = <0x1e>;
                                        nvidia,rx-clk-tap-delay = <0x1f>;
                                        nvidia,tx-clk-tap-delay = <0x0>;
                                };
                        };
                        spi@1 {
                                status = "disabled";
                        };
                };
        };


        fragment@4 {
                target = <&pinmux>;
                __overlay__ {
                        pinctrl-names = "default";
                        pinctrl-0 = <&spi1_pins>;

                        spi1_pins: exp-header-pinmux {
                                pin19 {
                                        nvidia,pins = "spi1_mosi_pz5";
                                        nvidia,function = "spi1";
                                        nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
                                        nvidia,tristate = <TEGRA_PIN_DISABLE>;
                                        nvidia,enable-input = <TEGRA_PIN_ENABLE>;
                                };
                                pin21 {
                                        nvidia,pins = "spi1_miso_pz4";
                                        nvidia,function = "spi1";
                                        nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
                                        nvidia,tristate = <TEGRA_PIN_DISABLE>;
                                        nvidia,enable-input = <TEGRA_PIN_ENABLE>;
                                };
                                pin23 {
                                        nvidia,pins = "spi1_sck_pz3";
                                        nvidia,function = "spi1";
                                        nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
                                        nvidia,tristate = <TEGRA_PIN_DISABLE>;
                                        nvidia,enable-input = <TEGRA_PIN_ENABLE>;
                                };
                                pin24 {
                                        nvidia,pins = "spi1_cs0_pz6";
                                        nvidia,function = "spi1";
                                        nvidia,pull = <TEGRA_PIN_PULL_UP>;
                                        nvidia,tristate = <TEGRA_PIN_DISABLE>;
                                        nvidia,enable-input = <TEGRA_PIN_ENABLE>;
                                };
                        };
                };
        };
};

After copy to /boot, with Jetson-IO I applied overlay to Device-Tree, reboot and get “Unable to boot via extlinux”. My main question: where is my mistakes? I have already lost hope that I will be able to configure CAN. Additional question is how to debug boot of kernel to understand what exactly is the conflict in the overlay, are there any ways? Many thanks in advance!!

Hi n.misinkevich,

What’s your Jetpack version in use?

You can refer to MCP2515 Verification to port MCP2515 on Jetson.

Please also share the full serial console log for further check.

Hi, KevinFFF, thanks for your reply!

  1. I use JetPack 6.0, L4T v36.3. Note: I got real-time kernel with OTA update. Kernel version 5.15.136-rt-tegra
  2. I saw this guide and made changes for .dts based on it
  3. Im attaching serial boot log, but I only noticed line 1041 “Linux version 5.15.136-tegra”. It turns out that the RT kernel with overlay does not start without any specific logs and bootloader tries to start the general kernel?
    minicom.log (59.8 KB)
[    4.023958] Root device found: mmcblk0p1
..
[   14.306302] ERROR: mmcblk0p1 not found

It seems you have boot up issue.

Please confirm you can boot up the board successfully before making any cutomization.

System and Bootloader are located on NVMe. After include overlay, the system dont boot from the NVMe and seems try to boot from not inserted microSD card. Before this step, everything is good

Bootloader should be located in QSPI in the module.

Do you mean the overlay in your original post causing the boot failed issue?

Sorry for the mistake. Yes, my overlay is causing the boot error. Tried editing and using jetson-io’s spi overlay. Same result - after including my overlay to extlinux, the system can’t start

Could you try to sync the kernel source and modify it in device tree and rebuild kernel image/dtsi instead of using overlay?

I choose this topic Jetson Orin NX(JP5.1.2_R35.4.1) mcp2515 can1 can send data, can not recieve data for reference and read recomendation from Kernel Customization, but im still not understand which .dtsi file should be changed and how build kernel from source on Jetson platforms, as if on other platforms it was much easier. If you could help me with this method, I would be very grateful!

For Jetpack 6.0, please refer to the one I shared above.
You should modify tegra234-p3768-0000+p3767-xxxx-nv-common.dtsi for Orin NX.

Have you referred to this guide step-by-step to sync and build the kernel image/dtb?
What issue do you hit now?

  1. I add lines to tegra234-p3768-0000+p3767-xxxx-nv-common.dtsi and lines to defconfig as shown in the link
  2. Next I build with make -C kernel already on a taget Jetson
  3. After that I install kernel and in-tree modules with sudo -E make install -C kernel
    But I’m still have a question. After install I saw that the device tree in /boot/dtb was not updated, how can I update it?

You should build kernel Image/dtb on a standalone x86 Ubuntu host PC.
The steps in Kernel Customization should be finished on host PC rather than Jetson.

As a result, please finish the steps on host PC to build kernel image/dtb and put them to your Jetson device.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.