How to enable SPI2 interface

Hello,

We designed a Jetson Xavier AGX carrier board with the following SPI pins:

SPI2_CLK (E61)

SPI2_MISO (D62)

SPI2_MOSI (F60)

SPI2_CS0_N (D60)

How to enable these pins? We are using the Jetpack 4.2.2 and see nothing when we type ls /dev/spi*.

What we did so far:

  • cd /boot/dtb
  • sudo dtc -I fs -O dts -o extracted_proc.dts /proc/device-tree and a file extracted_proc.dts will be available in /boot/dtb.
  • Edit the file extracted_proc.dts. We identified that spi2 is spi@3230000 and made the following changes.
spi@3220000 {
        ...
        status = "okay";
        ...
        spidev@0 {
                compatible = "spidev";
                reg = <0>;
                spi-max-frequency=<25000000>;
        };
};
  • Recompiled it sudo dtc -I dts -O dtb -o tegra194-p2888-0001-p2822-0000-base.dtb extracted_proc.dts
  • sudo dd if=tegra194-p2888-0001-p2822-0000-base.dtb of=/dev/mmcblk0p3
    • We also tried to use sudo ./flash.sh -r -k kernel-dtb jetson-xavier mmcblk0p1
  • Changed the pinmux according to SPI1 not work on Xavier - #4 by tw.manny.wang
sudo devmem2 0x0c302048 word 0x00000400
sudo devmem2 0x0c302050 word 0x00000450
sudo devmem2 0x0c302048 word 0x00000400
sudo devmem2 0x0c302028 word 0x00000400
  • sudo modprobe spidev

Additional questions:

  1. Is spidev@0 correct? Should it be spidev@2 ?
  2. How to verify the pinmux values corresponding to the SPI2 registers? For example, what does pinmux.0x0c302048 = 0x00000400 mean? Would using devmem2 be okay?
  3. When we decompile the file again (i.e. sudo dtc -I fs -O dts -o extracted_proc.dts /proc/device-tree), the extracted_proc.dtb does not reflect the changes we made. How to make sure that our changes are applied?

SPI2 is spi@c260000 and map to spidev@1, the spidev@# is the HW SPI number -1
devmem2 is fine for debug, but modify the cfg file should be good.

Hi ShaneCCC,

Thanks for replying to this message. Then how would we enable the SPI2 interface. Isn’t that the one connected to the pins listed in my initial message.
In our extracted_proc.dts file, we see spi1 = "/spi@c260000"; .I’m confused as why this refers to as being spi1.

We are pretty new to the NVIDIA environment so a short guide on how to enable the spi interface will be greatly appreciated.

The pin number from the pinmux table is the HW name it’s started from 1, however the software device function number is started from 0, So you have to minus 1 to get software bus number.

Hi ShaneCCC,

Thanks for the clarification. We will modify the spi@c260000.

  1. After compiling it with sudo dtc -I dts -O dtb -o tegra194-p2888-0001-p2822-0000-base.dtb extracted_proc.dts, how do we make sure that our .dtb file is properly loaded?
  2. Would you mind telling me where I can find the cfg file (instead of using devmem2)?

EDIT: We tried to use the dd and flash.sh methods, but no luck so far.

You should be able the see which dtb is applied by dmesg | grep DTS,
Then replace the same file in the …/Linux_for_tegra/kernel/dtb/ then issue the flash.sh command to update it.

Also for the cfg file have a reference to below topic.

Hi ShaneCCC,

Thank you very much for supporting us.

Here is the output of dmesg | grep DTS

[    0.566759] DTS File Name: /dvs/git/dirty/git-master_linux/kernel/kernel-4.9/arch/arm64/boot/dts/../../../../../../hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-p2888-0001-p2822-0000-common.dtsi
[    0.953457] DTS File Name: /dvs/git/dirty/git-master_linux/kernel/kernel-4.9/arch/arm64/boot/dts/../../../../../../hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-p2888-0001-p2822-0000-common.dtsi

After flashing Jetpack 4.2.2 using the SDKManager, I have files in ~/nvidia/nvidia_sdk/JetPack_4.2.2_Linux_GA_JETSON_AGX_XAVIER/Linux_for_Tegra.

From that location, I can see tegra194-p2888-0001-p2822-0000.dtb under <path to Linux_for_Tegra>/kernel/dtb. We tried to replace it, then used the flash.sh under Linux_for_Tegra, and our Jetson Xavier Module wont’t even show the desktop.

I can see from the documentation I may need to access <top>/hardware/nvidia/platform/t19x/<platform>/tegra194-mb1-bct-pinmux-gpio-P2972-<revision>.cfg. How do I get access to this file?
Source: Tegra Linux Driver

The cfg file is located at ~/nvidia/nvidia_sdk/JetPack_4.2.2_Linux_GA_JETSON_AGX_XAVIER//Linux_for_Tegra/bootloader/t186ref/BCT.

Did you use sudo ./flash.sh -r -k kernel-dtb jestson_xavier mmcblk0p1 to update the dtb?

Hi ShaneCCC,

Thank you for showing where the cfg file is.

Yes, I used sudo ./flash.sh -r -k kernel-dtb jetson-xavier mmcblk0p1 with jetson-xavier instead of jetson_xavier if that makes a difference. More specifically,

  1. After creating the .dtb file on my Jetson Xavier AGX, I copied it to my Ubuntu 18.04 host machine.
  2. I replaced tegra194-p2888-0001-p2822-0000.dtb in my Ubuntu 18.04 host machine with this newly created .dtb file.
  3. I ran the ./flash.sh command above.

Is there a mistake in my steps? I am not sure what could cause the image to be corrupted.

Yes, the command is correct it’s jetson-xavier instead of jetson_xavier.
Could you try the original extracted_proc.dtb if this file have problem, you may need to compile the dtb by kernel source instead of dtc.

Hi ShaneCCC,

Thank you for confirming that the command was correct. I will try your suggestion once I have access to the Xavier AGX and get back to you.

Hi ShaneCCC,

Would you mind letting us know how to compile the dtb by kernel source?

EDIT: It turns out that compiling the original extracted_proc.dts to tegra194-p2888-0001-p2822-0000.dtb fails. Should we have signed the compiled dtb file with l4t_sign_image.sh?

Have reference to below link to build the kernel Image and DTB.

https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%2520Linux%2520Driver%2520Package%2520Development%2520Guide%2Fkernel_custom.html%23

Hi ShaneCCC,

Thank you very much for your support. Following your guide and multiple other sources, I have been able to see the /dev/spidev1.0 on the NVIDIA carrier board, but when I use our own custom carrier board, it disappears.

I noticed that I can update the device tree with the following steps:

  • cd /boot/dtb
  • sudo dtc -I dtb -O dts -o extracted_proc.dts tegra194-p2888-0001-p2822-0000.dtb
    This command decompiles the dtb, instead of fs as I previously did.
  • Edit the file extracted_proc.dts . We identified spi1 = “/spi@c260000” and made the following changes.
spi@c260000 {
...
        status = "okay";
        ...
        spidev@1 {
                compatible = "spidev";
                reg = <0>;
                spi-max-frequency=<25000000>;
        };
};

There is a child node related to imx204@0 which I did not edit.

  • Use the flash.sh to reflash the kernel dtb.

Do you know if there are required hardware changes for the SPI2 to work on our own custom board?

EDIT: The outlined steps seem to work. I am not sure why I didn’t see the SPI before. I just rebooted the board and voila, it works!

Check the status of the spi@c260000 and spidev@1 in the /proc/device-tree/ to confirm it’s “okay”

Hi ShaneCCC,

I finally checked the spi@c260000 status and it was okay. I also tried it once again to my custom board and finally it works. I am not sure why the SPI did not show up before. I did not do anything significant apart from rebooting the module.

Thank you very much for the assistance. I really appreciate NVIDIA’s support!

1 Like