Hii @ShaneCCC ,
Thank you for your support.
Loopback test does not work on slave, it gives error but the master slave communication worked fine but I just want to ask that
Why only this pinmux(provided by you) setting is worked and not other ?
Master and slave communicate with each other in transmit only(-t) and receive only(-r) mode, when use normal command(without -t/-r) slave does not wait for master, slave gives error & test fails. is there any command by using that we can test duplex communication on master and slave?
I have done the pinmux setting according to technical guide provided by NVIDIA for jetson nano, but spidev_test passes only when we set pinmux settings according to your pinmux, I dont understand why is that happens.
How we can send our data like patternfile example
To transfer all bytes from user defined pattern file,
spidev_test -D/dev/spidev0.0 -s18000000 -f/path/to/patternfile
using spidev_test. I have created a file with dummy data but it fails when we run command
./spidev_test -D/dev/spidev1.0 -s20000 -fpatternfile -zzz
using device: /dev/spidev1.0
setting spi mode for read,write
setting spi bpw
setting max speed for rd/wr
spi mode: 0
bits per word: 8 bytes per word: 1
max speed: 20000 Hz (20 KHz)
no. runs: 1
Using seed:0x5f674756
loop count = 0
Using user defined pattern from patternfile file ....
transfer ioctl error: -1
/dev/spidev1.0: TEST FAILED !!!!! (status:-1)
====== Transfer stats ====
Transmit:
total: 18446744073709551615B (18014398509481983KiB 17592186044415MiB)
total: 1P
ioerr: 0B (0KiB 0MiB)
ioerr: 1P
Rate:
wire total: -1B/s (0KB/s)
total: -1B/s (0KB/s)
wire total: -1P/s
total: -1P/s
Receive:
total: 0B (0KiB 0MiB)
total: 0P
good: 0B (0KiB 0MiB)
good: 0P
ioerr: 1P
dataerr: 0P
Rate:
good: -1B/s (0KB/s)
good: -1P/s
packet drop: -1/10000
Total time: 0.126969s
but same file gives test passed on Master and test failed on slave
here are results :-
ON MASTER
$ ./spidev_test -D/dev/spidev1.0 -s20000 -fpatternfile1 -zzz -t
Disabling receive
using device: /dev/spidev1.0
setting spi mode for read,write
setting spi bpw
setting max speed for rd/wr
spi mode: 0
bits per word: 8 bytes per word: 1
max speed: 20000 Hz (20 KHz)
no. runs: 1
Using seed:0x5f6748a4
loop count = 0
Using user defined pattern from patternfile1 file ....
/dev/spidev1.0: TEST PASSED
====== Transfer stats ====
Transmit:
total: 0B (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.000321s
$./spidev_test -D/dev/spidev1.0 -s20000 -fpatternfile1 -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: 0
bits per word: 8 bytes per word: 1
max speed: 20000 Hz (20 KHz)
no. runs: 1
Using seed:0x5f674804
loop count = 0
transfer: Return actual transfer length: 0
/dev/spidev1.0: TEST PASSED
====== Transfer stats ====
Receive:
total: 0B (0KiB 0MiB)
total: 0P
good: 0B (0KiB 0MiB)
good: 0P
ioerr: 0P
dataerr: 0P
Rate:
good: -1B/s (0KB/s)
good: -1P/s
packet drop: -1/10000
Total time: 0.000277s
ON SLAVE :
$./spidev_test -D/dev/spidev1.0 -s20000 -fpatternfile1 -H -O -zzz -t
Disabling receive
using device: /dev/spidev1.0
setting spi mode for read,write
setting spi bpw
setting max speed for rd/wr
spi mode: 3
bits per word: 8 bytes per word: 1
max speed: 20000 Hz (20 KHz)
no. runs: 1
Using seed:0x5f674898
loop count = 0
Using user defined pattern from patternfile1 file ....
transfer ioctl error: -1
/dev/spidev1.0: TEST FAILED !!!!! (status:-1)
====== Transfer stats ====
Transmit:
total: 18446744073709551615B (18014398509481983KiB 17592186044415MiB)
total: 1P
ioerr: 0B (0KiB 0MiB)
ioerr: 1P
Rate:
wire total: -1B/s (0KB/s)
total: -1B/s (0KB/s)
wire total: -1P/s
total: -1P/s
Total time: 0.034047s
$./spidev_test -D/dev/spidev1.0 -s20000 -fpatternfile1 -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: 0
bits per word: 8 bytes per word: 1
max speed: 20000 Hz (20 KHz)
no. runs: 1
Using seed:0x5f674889
loop count = 0
^Ctransfer ioctl error: -1
/dev/spidev1.0: TEST FAILED !!!!! (status:-1)
====== Transfer stats ====
Receive:
total: 0B (0KiB 0MiB)
total: 0P
good: 0B (0KiB 0MiB)
good: 0P
ioerr: 1P
dataerr: 0P
Rate:
good: 0B/s (0KB/s)
good: 0P/s
packet drop: -1/10000
Total time: 1.418285s
This full duplex test is not giving fix results sometimes it gives error sometimes it successfully completed, what to do in this case ?
$./spidev_test -D/dev/spidev1.0 -n1 -s20000 -g12 -p4 -H -zzz
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: 20000 Hz (20 KHz)
no. runs: 1
Using seed:0x5f675340
loop count = 0
Using rand() buffer
Using crc check
transfer packet bytes [12]
0000: FE EE CA AB FF FF FF FF 00 00 00 00
transfer: Return actual transfer length: 12
receive packet bytes [12]
0000: FE EE CA AB FF FF FF FF 00 00 00 00
transfer: received packet size:12 len:0 stat:0
/dev/spidev1.0: TEST PASSED
====== Transfer stats ====
Transmit:
total: 12B (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
Receive:
total: 12B (0KiB 0MiB)
total: 1P
good: 12B (0KiB 0MiB)
good: 1P
ioerr: 0P
dataerr: 0P
Rate:
good: -1B/s (0KB/s)
good: -1P/s
packet drop: -1/10000
Total time: 0.934475s
slave only transmits at mode 1 and mode 3 so above test fails in SPI mode 3 and sometimes it works in mode 3 and fails in mode 1, it always gives unpredictable output What should I do ?
can you please tell me is there Buffer Overwrite occur in SPI ?
I have 2 Jetson Nano devices. I want these Jetson Nano devices to communicate with SPI. I want one of the Jetson Nano devices to be in master mode and the other device (Jetson Nano) in slave mode. I tried the solutions you suggested but I couldn’t get any results. I guess the data answers apply to Jetson Xavier. Do the same solutions apply to the Jetson Nano ? Can I get information about this topic?
then change pinmux settings as shown using devmem2
and then try running spidev_test on slave 1st and then on master.
use this command on master as well as on slave
./spidev_test -D/dev/spidev1.0 -n1 -s20000 -H -g12 -p4 -zzz
use -H and -O options to set SPI mode just be sure that only on mode 1 & 3 slave can transmit as well as receive the message in mode 0 and 2 slave can only receive message.