SPI communication failed

Hi all:

Using jetpack6.2_r36.4.3 and The customer carrier board has two SPI interfaces. SPI1 is the slave interface and SPI2 is the master interface. These two SPI interfaces are respectively the slave device spi@3210000 (PZ03.PZ04.PZ05.PZ06.PZ07), and the master device spi@c26000 (PCC00.PCC01.PCC02.PC003). They are directly connected and the wiring method is spi1_MISO to spi2_MISO. spi1_MOSI to spi2_MOSI ; spi1_clk to spi2_clk; spi1_cs to spi2_cs. The attached file is the modification of pinmux for spi1 and spi2, and the modification of the dtb. This is
Change spi@3210000 to slave mode. hardware/nvidia/t23x/nv-public/nv-platform/tegra234-p3737-0000.dtsi 
spi@3210000 {
compatible = "nvidia,tegra186-spi-slave";
Change "spi@3210000" to "slave" mode 

Enable spi@c260000 in the hardware/nvidia/t23x/nv-public/nv-platform/tegra234-p3737-0000.dtsi 

spi@c260000{
status = "okay";
spi@0 { /* chip select 0 */
compatible = "tegra-spidev";
reg = <0x0>;
spi-max-frequency = <50000000>;
};
spi@1 { /* chips select 1 */
compatible = "tegra-spidev";
reg = <0x1>;
spi-max-frequency = <50000000>;
};
};
 and used python script to test communication,nothing can get .
could give some advice ,thanks

 ls /dev/spidev
spidev0.0  spidev0.1  spidev1.0  spidev1.1  spidev2.0  spidev2.1

sudo dmesg | grep spi
[    7.609560] spi-tegra114 3230000.spi: Adding to iommu group 1
[    7.616104] spi-tegra124-slave 3210000.spi: Adding to iommu group 1
[    7.616447] spi-tegra124-slave 3210000.spi: Dynamic bus number will be registered
[    7.671044] spi-tegra114 c260000.spi: Adding to iommu group 1

org_spi1_slave.zip (7.4 KB)

python_script.zip (2.5 KB)

Hi Big_Z,

Please note that spi@c260000 is from SPE, and its level is 1V8 rather than 3V3.

You have to know that the numbers here are assigned dynamically according to the order of probing.

In your case:
spidev0.0/spidev0.1 => 3230000.spi
spidev1.0/spidev1.1 => 3210000.spi
spidev2.0/spidev2.1 => c260000.spi

How do you connect them externally?
Do you want to use spi@3210000 as SPI slave and spi@c260000` as SPI master?
If so, you need the level shifter connected for this use case.

n your case:
spidev0.0/spidev0.1 => 3230000.spi
spidev1.0/spidev1.1 => 3210000.spi
spidev2.0/spidev2.1 => c260000.spi

  ----> How to know this ,could you show it

Do you want to use spi@3210000 as SPI slave and spi@c260000` as SPI master?
    ---> yes
If so, you need the level shifter connected for this use case.
   --> yes,we use the level shifter connected by 3.3v both

could show the test solutions for this case ,spi slave and spi master. 

 

Hi

Now Using two agx orin devkit to test spi slave and master , connect two agx orin devkit spi pin which in 40 pin header (SPI_MOSI_LVS SPI_MISO_LVS SPI_SCK_LVS SPI_CS0_LVS SPI_CS1_LVS ) , and used tool this spidev_test, and it block in slave agx orin

master send :

sudo ./spidev_nvidia -D /dev/spidev0.0 -s8000000 -g8 -b8 -H -f pattern.txt -n1 -zzz -t
Disabling receive
using device: /dev/spidev0.0
setting spi mode for read,write
setting spi bpw
setting max speed for rd/wr
spi mode: 1
bits per word: 8 bytes per word: 1
max speed: 8000000 Hz (8000 KHz)
no. runs: 1
Using seed:0x69a83c0a
loop count = 0
Using user defined pattern from pattern.txt file …
transfer bytes [8]
0000: 55 55 55 55 55 55 55 55
/dev/spidev0.0: TEST PASSED
====== Transfer stats ====
Transmit:
total: 8B (0KiB 0MiB)
total: 1P
ioerr: 0B (0KiB 0MiB)
ioerr: 0P
Rate:
wire total: -1B/s (0KB/s)
total: -1B/s (0KB/s)
wire total: -1P/s
total: -1P/s

Total time: 0.000289s

slave block:

sudo ./spidev_nvidia -D /dev/spidev1.0 -s8000000 -g8 -b8 -H -f pattern.txt -n1 -zzz -r
Disabling transmit
using device: /dev/spidev1.0
setting spi mode for read,write
setting spi bpw
setting max speed for rd/wr
spi mode: 1
bits per word: 8 bytes per word: 1
max speed: 8000000 Hz (8000 KHz)
no. runs: 1
Using seed:0x69a83bf5
loop count = 0

can not work

slave dmesg | grep spi

sudo dmesg | grep spi
[ 9.302273] spi-tegra114 3230000.spi: Adding to iommu group 1
[ 9.302566] spi-tegra124-slave 3210000.spi: Adding to iommu group 1
[ 9.302750] spi-tegra124-slave 3210000.spi: Dynamic bus number will be registered
[ 9.310739] spi-tegra114 c260000.spi: Adding to iommu group 1
[ 161.100886] spi-tegra124-slave 3210000.spi: waiting for controller was interrupted
[ 161.101000] spi_master spi1: failed to transfer one message from queue
[ 1406.148461] spi-tegra124-slave 3210000.spi: waiting for controller was interrupted
[ 1406.148582] spi_master spi1: failed to transfer one message from queue

master:

/home/nvidia# sudo dmesg | grep spi
[ 10.873039] spi-tegra114 3210000.spi: Adding to iommu group 1
[ 10.885693] spi-tegra114 3230000.spi: Adding to iommu group 1

please help to check it ,thanks

321000_spi_master_pinmux.txt (31.4 KB)

321000_spi0slave_pinmux.txt (31.4 KB)

dump_master.dts.txt (396.9 KB)

dump_slave_orin.dts.txt (398.1 KB)

)

used the jeston-io to chose [*] spi1 (19,21,23,24,26) ,then save and reboot and add controller-data {
nvidia,enable-hw-based-cs;
nvidia,variable-length-transfer;
nvidia,cs-setup-clk-count = <0x20>;
nvidia,rx-clk-tap-delay = <0x10>;
nvidia,tx-clk-tap-delay = <0x0f>; in spi@3210000 ,

slave spi get as cmd below:

sudo ./spidev_nvidia -D /dev/spidev0.0 -s8000000 -g8 -b8 -H -f pattern.txt -n1 -zzz -r

master cmd:

sudo ./spidev_nvidia -D /dev/spidev0.0 -s8000000 -g8 -b8 -H -f pattern.txt -n1 -zzz -t

The master SPI needs to send instructions three times before the slave SPI stops stuttering and responds once — however, the received data does not match the data sent by the master

patter.txt as 55 aa 55 55 55 55 55 55

master:

udo ./spidev_nvidia -D /dev/spidev0.0 -s8000000 -g8 -b8 -H -f pattern.txt -n1 -zzz -t
Disabling receive
using device: /dev/spidev0.0
setting spi mode for read,write
setting spi bpw
setting max speed for rd/wr
spi mode: 1
bits per word: 8 bytes per word: 1
max speed: 8000000 Hz (8000 KHz)
no. runs: 1
Using seed:0x69a8f3c8
loop count = 0
Using user defined pattern from pattern.txt file …
transfer bytes [8]
0000: 55 AA 55 55 55 55 55 55
/dev/spidev0.0: TEST PASSED
====== Transfer stats ====
Transmit:
total: 8B (0KiB 0MiB)
total: 1P
ioerr: 0B (0KiB 0MiB)
ioerr: 0P
Rate:
wire total: -1B/s (0KB/s)
total: -1B/s (0KB/s)
wire total: -1P/s
total: -1P/s

Total time: 0.000342s

slave :

sudo ./spidev_nvidia -D /dev/spidev0.0 -s8000000 -g8 -b8 -H -f pattern.txt -n1 -zzz -r
Disabling transmit
using device: /dev/spidev0.0
setting spi mode for read,write
setting spi bpw
setting max speed for rd/wr
spi mode: 1
bits per word: 8 bytes per word: 1
max speed: 8000000 Hz (8000 KHz)
no. runs: 1
Using seed:0x69a8f3c4
loop count = 0
transfer: Return actual transfer length: 8
receive bytes [8]
0000: 86 D5 00 65 72 2E 73 6C
transfer: received packet size:8 len:8 stat:-6
/dev/spidev0.0: TEST FAILED !!! (status:-1)
====== Transfer stats ====
Receive:
total: 8B (0KiB 0MiB)
total: 1P
good: 0B (0KiB 0MiB)
good: 0P
ioerr: 0P
dataerr: 1P
Rate:
good: 0B/s (0KB/s)
good: 0P/s
packet drop: -1/10000

Total time: 2.303012s

Do need to upload spi driver for jetpack6.2

dmesg_master.log (62.5 KB)

dmesg_slave.log (61.7 KB)