Question: How do I enable and address SPI ports?

I’m trying to figure out how to enable the SPI ports on the Xavier. In particular, the ports on the 40 pin header and on the PCIe port. I can’t seem to find any documentation for setting the pinmux, or addressing the ports once enabled. Can someone point me in the right direction? Or if you’ve accomplished this already, please share? Thanks!

I have been using SPI devices with Jetson Xavier. (https://devtalk.nvidia.com/default/topic/1042964/?comment=5293576)

Try the following.

1. Edit device-tree

The changes of the device tree are as follows.

spi@xxxxxx {
    ...
    status = "okay"; // Before change: "disable"
    spidev@0 {
        compatible = "spidev";
        reg = <0>;
        spi-max-frequency=<25000000>;
    };
}

The commands used are as follows.

$ sudo dtc -I fs -O dts -o extracted_proc.dts /proc/device-tree
$ sudo vi extracted_proc.dts # edited device tree.
$ 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/mmcblk0p31

2. Change pinmux

The changed pinmux settings are as follows.

0x0243d040 = 0x00000400
0x0243d020 = 0x00000458
0x0243d058 = 0x00000400
0x0243d010 = 0x00000400
0x0243d050 = 0x00000400
0x0c302048 = 0x00000400
0x0c302050 = 0x00000450
0x0c302028 = 0x00000400
0x0c302038 = 0x00000400

For example, do the following: $ devmem2 0x243d040 word 0x00000400

3. Load a module

$ sudo modprobe spidev

Thanks for the info! A few further questions -

  1. Can you define the pinmux registers? What are they addressing? Chip select (CS)? Polarity? etc.
  2. I’m having a ton of trouble changing the CS delay time. I can send a SPI message, but there’s a 40 micro second delay AFTER the clock stops and BEFORE CS rises. Same thing on the falling edge of CS - huge delay before the clock starts. How do I change this delay time?

I need to burst data at a near 100kHz rate, can’t do it presently because of the delay time with the chip select.

I have tried it your way.

spi@3210000 {
        //compatible = "nvidia,tegra186-spi";
        clocks = <0x4 0x87 0x4 0x66 0x4 0xe>;
        resets = <0x5 0x5b>;
        dma-coherent;
        clock-names = "spi", "pll_p", "clk_m";
        nvidia,clk-parents = "pll_p", "clk_m";
        /*status = "okay";
        spidev@0 {
                compatible = "spidev";
                reg = <0>;
                spi-max-frequency=<25000000>;
        };*/
        #address-cells = <0x1>;
        interrupts = <0x0 0x24 0x4>;
        #size-cells = <0x0>;
        dma-names = "rx", "tx";
        phandle = <0x172>;
        //reg = <0x0 0x3210000 0x0 0x10000>;
        iommus = <0x2 0x20>;
        dmas = <0x1e 0xf 0x1e 0xf>;
        reset-names = "spi";
        linux,phandle = <0x172>;
        spi-max-frequency = <0x3dfd240>;
        status = "okay";
        spidev@0 {
                compatible = "spidev";
                reg = <0>;
                spi-max-frequency=<25000000>;
        };
};

Run

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/mmcblk0p31
sudo modprobe spidev
ls /dev/ | grep spi

Nothing after execution

use the flash.sh to update the DTB instead of using the dd command.

No device files were generated after burning.
I suspect that the file is not configured correctly.
File links:https://hkaa028-my.sharepoint.com/:f:/g/personal/mj8918_office2016_info/EgXhn7WMQCRCtbd544YMJkIBghDgT-AaI4QfXFLMH7qhnQ?e=XS5Uzy

Hi ShaneCCC,

sorry, but where is the flash.sh in Xavier.

in TX2 the command is :
sudo ./flash.sh -r -k kernel-dtb jetson-tx2 mmcblk0p1

what the command will be in xavier, can you type it?

@Gaosiy
TX2 and Xavier use the same command only TX1 is different.

Flash.sh in “nvidia_sdk/JetPack_4.2_linux_P2888/Linux_for_Tegra”

I think jetson-xavier should be used because https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%2520Linux%2520Driver%2520Package%2520Development%2520Guide%2Fflashing.html%23wwpID0E0ID0HA the link The jetson-xavier parameters are used in

Hi,
I cant find the flash.sh, I cant find the dir you say “nvidia_sdk/JetPack_4.2_linux_P2888/Linux_for_Tegra” ,where is this dir?
BTW, I say you try to enable the SPI, how is going?

It can be set in DOWNLOAD & INSTALL OPTIONS in step STEP 02 of SDK Manager. After refreshing the device, these files will be generated in the corresponding directory.

So you mean the flash.sh is on the host x86 machine, and I should run the sh on the host with a USB connection with jetson?

[quote]

[quote =“”]

yes

yes

thanks a lot, I find it on the host. But there is a question cofused me.
if I modify the device-tree and use this command on xaiver
sudo dtc -I dts -O dtb -o tegra194-p2888-0001-p2822-0000-base.dtb extracted_proc.dts
I get a dtb file. the next step is flash.sh. I cant find the relationship between the new dtb file and the sh, so how doese the sh work?

sudo ./flash.sh --no-flash -k kernel-dtb jetson-xavier mmcblk0p1

should I copy the tegra194-p2888-0001-p2822-0000-base.dtb to the host, and replace the kernel-dtb with it, then run the flash.sh?

Thanks, and I want to know if I recompile a dtb file name A.dtb on xavier.
should I copy A.dtb to my host and use flash.sh to update the xavier’s dtb?
if so, how to change the command
sudo ./flash.sh -r -k kernel-dtb jetson-tx2 mmcblk0p1

I check the flash.sh and it says -d
so is the below command can be used?

sudo ./flash.sh -r -d A.dtb jetson-xavier mmcblk0p1

I didn’t try the -d ever, but some user tell it worked for them.
For me I just replace the …/Linux_for_tegra/kernel/dtb/tegra194-p2888-0001-p2822-0000.dtb with A.dtb then issue the sudo ./flash -r -k kernel-dtb jetson-xavier mmcblk0p1

thanks shane,

do you change the A.dtb file name to tegra194-p2888-0001-p2822-0000.dtb or you change the flash.sh to fit the new dtb file ?

Yes, I copy the A.dtb to tegra194-p2888-0001-p2822-0000.dtb