Request to resolve SPI debugging issues

Teacher:
I have completed the setup SPI@3230000 For slave mode, dmesg.log and device tree are as follows(dmesg_device_tree.zip).
2. I tested according to your requirements SPI@3210000 and SPI@3230000 The running result is as follows:(send_command_run_result.txt (830 Bytes和receive_command_run_result.txt (927 Bytes).

I’m not sure if this can be considered a success. From the shell command, it seems that data has been received, but the content of the file “patterned cord. txt” is empty, and I don’t know how to save the data.
The receiving command I used is:sudo …/spidev_test -D /dev/spidev2.0 -s8000000 -g8 -b8 -H -f …/pattern_record.txt -n1 -zzz -r
The command I used to send is:sudo …/spidev_test -D /dev/spidev0.0 -s8000000 -g8 -b8 -H -f …/pattern.txt -n1 -zzz -t
I hope the teacher can provide further guidance.

I am reissuing three test records, hoping they will be helpful in analyzing the issue.
Receiving commands always reports the following error, I don’t know if it’s considered normal.

receive_command_test3_record.txt (2.9 KB)

send_command_test3_record.txt (2.5 KB)

From the log you shared, it seems the transaction is successful.

Master:
transfer bytes [8]
0000: 55 55 55 55 55 55 55 55 

Slave:
receive bytes [8]
0000: 55 55 55 55 55 55 55 55 
Not enough data in file, repeat data from file....
transfer: received packet size:8 len:8 stat:0

Please also get a scope to measure the signal during the test.

Why you create pattern.txt and pattern_record.txt?
For SPI master(TX), it is used to send the data.
For SPI salve (RX), it is used to check if it receives the expected data.

1.Please also get a scope to measure the signal during the test.

Okay, I’ll go test it right away and get back to you with the waveform.

2.Why you create pattern.txt and pattern_record.txt?

Because in the project, I need to save the received data and then analyze it. Is there any way to save the received data?
3.What do the “- g8- b8” in the command mean? Can you help explain it?

For SPI slave, the tool will compare and check if the received data is the same as it specified in pattern.txt.
Please note that it is a sample tool for user to verify SPI function.
You have to write your own SPI application for your specific use case.

-g is the length, -b is the bits/word
Please simply run sudo ./spidev_test -h to check in details.

1.Please simply run sudo ./spidev_test -h to check in details.

Answer:I ran it twice and the result is as follows:

spidev_test-h-result.txt (6.4 KB)

2. You have to write your own SPI application for your specific use case.

Answer:There are shell commands for SPI to save data. Can you give me some guidance on your development experience? It will also be easier for me to program.

3. The waveform you need is as follows. I am testing the SPI0.MOSI port.

(The oscilloscope bandwidth is too low, resulting in significant distortion of the test waveform.)

If you need to test anything else, please leave me a message and I will do it immediately.

They are mentioned in the result you shared.

  -g --length   transaction length in bytes. Multiple lengths can be comma separated.
  -b --bpw      bits per word 

Please refer to the following open source of spidev_test tool.
linux/tools/spi/spidev_test.c at master · torvalds/linux · GitHub

Maybe using logic analyzer would be better in your case.

Maybe using logic analyzer would be better in your case.

I’m really sorry, the logic analyzer here was damaged by a fresh graduate and is currently being repaired.

Teacher:
Do you need me to test any other information?

It seems you’ve performed the SPI transaction between SPI master and slave on the devkit.
Please move to your custom carrier board to verify if it is working.

Thank you, teacher. The SPI function has been debugged and completed. Special thanks to the teacher for their long-term guidance.