Unable to get SPI working on Jetson Orin Nano

Hello everyone,

I’m trying to get SPI working on my Jetson Orin Nano. My end goal is to get it connected to my Arduino Due via SPI. But I’m unable to get a successful comms between them. I don’t care much about either of them being slaves or master.

What I’ve tried and tested:

  1. Tested Self-loopback tests on both the SPI ports (SPI1 and SPI3) and both worked.

  2. The above test confirms that the SPI ports are open and I can confirm using
    ls /dev/spidev* showing me 4 available ports 0.0, 0.1, 1.0 and 1.1

  3. I was following the guide given here: Jetson/L4T/peripheral/ - eLinux.org

    • I came across the spidev_test.c code from the guide and went to test on this by following the steps given in “Slave Mode” section. By treating one SPI port of Jetson as a Master and another port as a Slave. And I did similar Wiring connections as given image.

    • I even updated the device tree as described in the guide to also include the "nvidia,tegra210-spi-slave";

    • When I was verifying the communication I was getting errors like
      invalid option – ‘g’ for many different letters used in the verification command of the guide given below:

      • 3. Run SPI slave
        $ sudo ./spidev_test -D /dev/spidev1.0 -s8000000 -g8 -b8 -H -f pattern.txt -n1 -zzz -r
        
        
      • 
        4. Run SPI master
        $ sudo ./spidev_test -D /dev/spidev0.0 -s8000000 -g8 -b8 -H -f pattern.txt -n1 -zzz -t
        
    • Then I concluded that the spidev_test.c code given was outdated and I went came to here searching different forums and so. After which I found many posts linking to some newer updated spidev_test.c files and/or their binaries that I tried to test the SPI comms. But nothing of those files worked… It is like sometimes Transmitting was getting Passed and Receiving was getting Failed and sometimes TX was failing and RX was getting passed.

These last steps I did was testing SPI within Jetson only. But my end goal is to achieve SPI comms between Jetson and Arduino Due. Your inputs will be greatly valued if any of you had success in establishing comms between Jetson and Arduinos.

Happy to answer any questions and thank you for reading all this!

Kind regards,
KRP

Hi kaushal5,

It is a good start to verify if you have configured SPI correctly.

Please note they are assigned dynamically.

The earlier probed driver will be assigned for SPI device first.
-r option is used for SPI slave, -t option is used for SPI master.
That’s why you feel that sometimes TX work, sometimes RX work.

What’s your use case for Jetson and Arduino Due?
Do you want to use Jetson Orin Nano as SPI master or slave?

What’s your use case for Jetson and Arduino Due?
Do you want to use Jetson Orin Nano as SPI master or slave?

I want to get the sensor data and hardware attached on Due to communicate with Jetson.
I’m just a bit inclined towards Jetson being the Master

Can you please explain a bit more on what do you mean by assigned dynamically?

But I was doing the same command over and over and the output was getting passed and failed randomly. I wasn’t switching Slaves (-r) and Master (-t) options in my command.

Can you confirm if the code mentioned above is outdated and link me the latest spidev_test.c code to test with and its verification commands too.

Thank you,
KRP

In the device tree configuration where SPI1 is the master and SPI3 is the slave, the assignment of device nodes is determined by the probe order.
If SPI1 probes first, it is assigned /dev/spidev0.x, while SPI3 receives /dev/spidev1.x.
Conversely, if SPI3 probes first, the node assignments are swapped.

That spidev_test.c does not support for -r and -t options.
Please use the following one instead:
Request to resolve SPI debugging issues - #47 by KevinFFF

Ok, so does this affect my Verification command where I’m specifying the ports i.e., -D /dev/spidev1.0 and -D /dev/spidev0.0 in any way?

I performed this test. Please check the screenshot, it’s now coming passed for all Transmits and failing for every Receiving

Thanks,
KRP

Corret, please confirm that you specify -r option for SPI slave and -t option for SPI master.

Do you run spidev_test with -r for SPI slave first?
Please share the full dmesg for further check.

I was just going to test the setup to get the dmesg, and guess what… It worked out of nowhere!!
I believe wiring might have been the problem, i still wonder how… i was working on this for 2 full days…
I was running -r first and then -t.

Now i’ll go and try to get the communication working between Jetson and Arduino Due

If you run the spidev_test with -r option for SPI master, it will return TEST FAILED immediately.
Good to hear that you have verified SPI master/slave working with spidev_test tool.