How to use the spi on xavier

Hi teams

I config the Xavier’s SPI0 as slave mode.Which communication with stm32,
I set STM32’s SPI as master mode.The xavier SPI can receive data from STM32 ,
But can not send data ? it’s why

The spi config of xavier as below:

sudo ./devmem2 0x0243d010 w 0x00000415
sudo ./devmem2 0x0243d020 w 0x00000404
sudo ./devmem2 0x0243d040 w 0x00000444
sudo ./devmem2 0x0243d050 w 0x00000400
sudo ./devmem2 0x0243d058 w 0x00000448

my cmd::

./spidev_test -H 1 -O 1 -s500000 -d1000000 -v -p aaaaaaa

Did you try the loopback test?

Hi ShaneCCC

I did not try the loopback test.
1 How to test it ?
2 The SPI should be use as master or slave while loopback test.

Have check below link. Maybe verify both of master and slave mode to confirm it.

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

You may need to enable external master/slave loopback.
One for master and one enable as slave and connect them by loopback and run below command.

sudo ./spidev_test -D /dev/spidev2.0 -s8000000 -g512 -b32 -H -p0 -n1 -r &
sleep
sudo ./spidev_test -D /dev/spidev0.0 -s8000000 -g512 -b32 -H -p0 -n1 -zzz -t

Hi ShaneCCC

I have test it.
Xavier1 SPI (/dev/spi0.0) act as master
Xavier2 SPI (/dev/spi0.0) act as slave

connect as below:

Xavier1 Xavier2
SPI1_MOSI----------- SPI1_MOSI
SPI1_MISO----------- SPI1_MISO
SPI1_SCK ----------- SPI1_SCK
SPI1_CS0 ----------- SPI1_CS0

MASTER config:

sudo ./devmem2 0x0243d010 w 0x00000400
sudo ./devmem2 0x0243d020 w 0x00000450
sudo ./devmem2 0x0243d040 w 0x00000400
sudo ./devmem2 0x0243d050 w 0x00000400
sudo ./devmem2 0x0243d058 w 0x00000400

SLAVE config

sudo ./devmem2 0x0243d010 w 0x00000415
sudo ./devmem2 0x0243d020 w 0x00000404
sudo ./devmem2 0x0243d040 w 0x00000444
sudo ./devmem2 0x0243d050 w 0x00000400
sudo ./devmem2 0x0243d058 w 0x00000448

Xavier1

./spidev_test -H -s500000 -v -p 11
sleep .5

Xavier2

./spidev_test -H -s500000 -d1000000 -v -p aa
#sleep 1

The message is sent normally。

1 When I use Xavier2 SPI act as mater ,Xavier 1 SPI act as slave,it can not send,
Does this have anything to do with device tree configuration?

2 I didn’t brush the new SPI driver(Xavier2 spi config: “nvidia,tegra186-spi-slave”).
Just changed the next pin reuse configuration
Do I need to change the device tree again and then swipe the system?

I think you need to configure Xavier2 as slave mode by add “nvidia,tegra186-spi-slave” in dts.
And need to run the below command in Xavier2 first then run the spidev_test command in Xavier1

sudo ./spidev_test -D /dev/spidev0.0 -s8000000 -g512 -b32 -H -p0 -n1 -r

Hi ShaneCCC

I had test it.
Only the master (Xavier 1)can receive the data. the slave (Xavier 2)can not receive data