About testing SPI, Please can you check am I right?

OK. @ShaneCCC.

Thanks to guide me.

I did what you told me.
So, can you please check am I right?

And after that, what should I do for next step?

First, here is the list of what I did.

  1. Download L4T kernel source

  2. Modify SPI tree section on"tegra194-p2888-0001-p2822-0000-common.dtsi" file in </home/jhschai/L4T_Source/Linux_for_Tegra/source/public/hardware/nvidia/platform/t19x/galen/kernel-dts/common>
    I don’t fully understand about devicetree shown in below, but I’m sure I will use SPI1.
    ##############################################
    spi@3210000 {
    compatible = “nvidia,tegra186-spi”;
    reg = <0x0 0x3210000 0x0 0x10000>;
    interrupts = <0x0 0x24 0x4>;
    #address-cells = <0x1>;
    #size-cells = <0x0>;
    iommus = <0x2 0x20>;
    dma-coherent;
    dmas = <0x1e 0xf 0x1e 0xf>;
    dma-names = “rx”, “tx”;
    spi-max-frequency = <0x3dfd240>;
    nvidia,clk-parents = “pll_p”, “clk_m”;
    clocks = <0x4 0x87 0x4 0x66 0x4 0xe>;
    clock-names = “spi”, “pll_p”, “clk_m”;
    resets = <0x5 0x5b>;
    reset-names = “spi”;
    status = “okay”;
    linux,phandle = <0x162>;
    phandle = <0x162>;

     spi@0 {
     	compatible = "spidev";
     	reg = <0x0>;
     	spi-max-frequency = <0x1f78a40>;
     	nvidia,enable-hw-based-cs;
     	nvidia,rx-clk-tap-delay = <0x11>;
     };
    
     spi@1 {
     	compatible = “spidev”;
     	reg = <1>;
     	status = “okay”;
     }
    

};
##############################################

  1. Build kernel Source form L4T_Source with modified device-tree file.

  2. copy builded image file and dtb folder contents.

  3. Make new PINMUX.dtsi file from “Template.xlsm”.

  4. Make .cfg file with command.
    python pinmux-dts2cfg.py --pinmux addr_info.txt gpio_addr_info.txt por_val.txt --mandatory_pinmux_file mandatory_pinmux.txt tegra19x-jetson_agx_devkit-pinmux.dtsi tegra19x-jetson_agx_devkit-gpio-default.dtsi 1.0 > data.cfg

##############################################

Pinmux for gpio-input pins

pinmux.0x02212480 = 0x00000001; # CONFIG Z4

pinmux.0x0243d020 = 0x00000000; # GPIO spi1_miso_pz4

Pinmux for used pins

pinmux.0x0243d040 = 0x00000405; # spi1_sck_pz3: rsvd1, pull-down, tristate-disable, input-disable, lpdr-disable

pinmux.0x0243d020 = 0x00000055; # spi1_miso_pz4: rsvd1, pull-down, tristate-enable, input-enable, lpdr-disable

pinmux.0x0243d058 = 0x00000405; # spi1_mosi_pz5: rsvd1, pull-down, tristate-disable, input-disable, lpdr-disable

pinmux.0x0243d010 = 0x00000409; # spi1_cs0_pz6: rsvd1, pull-up, tristate-disable, input-disable, lpdr-disable

pinmux.0x0243d050 = 0x00000409; # spi1_cs1_pz7: rsvd1, pull-up, tristate-disable, input-disable, lpdr-disable
##############################################

  1. Copy contents of new .cfg file to “tegra19x-mb1-pinmux-p2888-0000-a04-p2822-0000-b01.cfg”

  2. Flash Kernel with modified PINMUX and modified device tree with command
    sudo ./flash.sh kernel-dtb jetson-xavier mmcblk0p1

  3. Re-install ubuntu at JETSON BOARD and connect [SPI1_MOSI(Header19)]&[SPI1_MISO(Header21)] to self test SPI.

This is right process to use SPI?

Second, What should I do for next step?

Please guide me little more!!

Thanks

The step need to flash without -k kernel-dtb to apply the cfg file.
The correct command is sudo ./flash -r jetson-xavier mmcblk0p1
And you can verify the REG setting by the devmem2 tools.

After the loopback test is OK you can connect your device and implement the driver for it.

@ShaneCCC.
I’ve already check REG value after flashing.

When I use devmem2 tools, REG values are setted with the value which I want.
for example,
$ sudo devmem2 0x0243d050
command return
Value at address 0x243D050( 0x7fad502050) : 0x409

I think my REGs are changed. Am I wrong?
Do I need to flash again with the command you told?

And can you tell me how to use loopback test?
what should I need to install.
sudo apt-get install spidev?

If the REG setting are apply as your configure file that should be fine.
Have a reference to below wiki.

https://elinux.org/Jetson/TX2_SPI#Testing_Communication

I’ve follow wiki.

After make spidev_test file, I copy that file to JETSON board.

And on terminal I try the command “spidev_test -D /dev/spidev0.0”.

After that I’ve got error message,
bash: spidev_test: connot find command
(it may not exactly same, because I translate it to Eng)

Can you please help me?

Run sudo ./spidev_test -D /dev/spidev0.0 at the spidev_test folder.

I’ve try it ant I got

spi mode: 0x0
bits per word: 8
max speed: 500000 hz (500KHz)
RX | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |…

Not I shoud have check pinmux…
Can you check my pinmux value and device tree is right for test?
Each value are shown in my original post up there. (not in reply)

Original PINMUX.cfg value for kernel is
pinmux.0x0243d040 = 0x00000055; # spi1_sck_pz3: rsvd1, pull-down, tristate-enable, input-enable, lpdr-disable
pinmux.0x0243d020 = 0x00000055; # spi1_miso_pz4: rsvd1, pull-down, tristate-enable, input-enable, lpdr-disable
pinmux.0x0243d058 = 0x00000055; # spi1_mosi_pz5: rsvd1, pull-down, tristate-enable, input-enable, lpdr-disable
pinmux.0x0243d010 = 0x00000059; # spi1_cs0_pz6: rsvd1, pull-up, tristate-enable, input-enable, lpdr-disable
pinmux.0x0243d050 = 0x00000059; # spi1_cs1_pz7: rsvd1, pull-up, tristate-enable, input-enable, lpdr-disable

I’ve modify it to
pinmux.0x0243d040 = 0x00000405; # spi1_sck_pz3: rsvd1, pull-down, tristate-disable, input-disable, lpdr-disable
pinmux.0x0243d020 = 0x00000055; # spi1_miso_pz4: rsvd1, pull-down, tristate-enable, input-enable, lpdr-disable
pinmux.0x0243d058 = 0x00000405; # spi1_mosi_pz5: rsvd1, pull-down, tristate-disable, input-disable, lpdr-disable
pinmux.0x0243d010 = 0x00000409; # spi1_cs0_pz6: rsvd1, pull-up, tristate-disable, input-disable, lpdr-disable
pinmux.0x0243d050 = 0x00000409; # spi1_cs1_pz7: rsvd1, pull-up, tristate-disable, input-disable, lpdr-disable

And After flash I already check mem value using devmem2.

Have a reference to below setting.

Thanks.
And also find I’m wrong.

I have miss to change pin usage in xlsm files.

Thanks I will try it again