How to set to spi slave mode

What should I check?

I mean I will check internal if can give a working configure.

The developer of jetson xavier nx devkit is nvidia.
I bought the nx devkit and then looked at https://www.jetsonhacks.com/2020/05/04/spi-on-jetson-using-jetson-io/, activated spi1, spi3, and did what you asked for.(dt Modification, reg value modification)

nvidia should tell if nx’s loopback test is possible.
I did not develop a carrier board.

That’s what I am going to doing with nvidia developer to check the loopback test configure.

Are you saying you should check with the nvidia developer?

Yes, I am going to check with nvidia developer.

Yes, please answer after checking.

Do you ever need to compile kernel/kernle-4.9/drivers/spi/spi-tegra124-slave.c and load spi-tegra124-slave.ko to use slave on jetson xavier nx?

No, I think it’s build-in kernel module.

Yes thank you.
Please check with the developer and answer, such as slave method and slave mode test method.

@_JJANG
Make below as a script, below is my test pass result.

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

nvidia@dhcp-10-19-107-152:~$ sh spi1.sh
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: 32 bytes per word: 4
max speed: 8000000 Hz (8000 KHz)
no. runs: 1
Using seed:0x5f894840
loop count = 0
using sequential pattern …
transfer bytes [512]
0000: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
0010: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
0020: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
0030: 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
0040: 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
0050: 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
0060: 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
0070: 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
0080: 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
0090: 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F
00A0: A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF
00B0: B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF
00C0: C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
00D0: D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF
00E0: E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF
00F0: F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE 00
0100: 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
0110: 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
0120: 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30
0130: 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40
0140: 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50
0150: 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60
0160: 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70
0170: 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 80
0180: 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F 90
0190: 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0
01A0: A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0
01B0: B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF C0
01C0: C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF D0
01D0: D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF E0
01E0: E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF F0
01F0: F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE 00 01
/dev/spidev2.0: TEST PASSED
/dev/spidev0.0: TEST PASSED
====== Transfer stats ====
Transmit:
total: 512B (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.007458s

https://forums.developer.nvidia.com/t/how-to-set-to-spi-slave-mode/155310/11?u=_jjang

Was it set up like this link?

Oh oh!! Thank you very much!!

I used the program you gave me in #4.

sudo ./spidev_test -D /dev/spidev2.0 -s8000000 -g512 -b32 -H -p0 -n1 -r &
sleep 5
sudo ./spidev_test -D /dev/spidev0.0 -s8000000 -g512 -b32 -H -p0 -n1 -zzz -t
I entered the command and it was successful!

I changed spi3 to slave and entered the command (the register value was not changed)

spi1 reg value
mosi : 0x444
miso : 0x444
sck : 0x444
cs0 : 0x448
cs1 : 0x448

spi3 reg value
mosi : 0x444
miso : 0x444
sck : 0x444
cs0 : 0x448
cs1 : 0x448

I have a question.
1.
https://github.com/torvalds/linux/blob/master/tools/spi/spidev_test.c
How do I enter a command to use this source code?
Or can you share the source code of the program you gave me?

2.

can’t send spi message: Invalid argument
Aborted (core dumped)
<<<<< dmesg >>>>>>
spi-tegra124-slave 3230000.spi: Tx is not supported in mode 0
spi-tegra124-slave 3230000.spi: spi can not start transfer, err -22
spi_master spi2: failed to transfer one message from queue

Does this error occur when spi mode is 0 or 3?
In the open source of spidev_test, the spi mode was 0 (error occurred) and the program you gave was spi mode 1 (successful).

  1. Sorry, can’t public the source.
  2. The master must run first then run the slave.

Thank you so much for letting me know!