So I’ve read all I could read.
Went through the instructions on https://github.com/rt-net/JetsonNano_DT_SPI
The script executed successfully from a host running Ubuntu. After the flashing was over and the Jetson restarted I got ‘spidev’ when I did ‘lsmod’.
I was also able to see spidev0.0 and spidev1.0 under /dev.
At this point I took the kernel test code spidev.c compiled it and executed '/spidev_test -D /dev/spidev0.0 -v
Placed a probe on PIN 23 (CLK) and …
Nothing :)
Absolutely nothing at all.
NVIDIA, letting developers an easy access to peripherals (SPI, I2C. UART act’) is mandatory, in my opinion, for the success of this line of products.
And tested again the python script (sudo /opt/nvidia/jetson-io/jetson-io.py ).
I was able to see something that blinks momentarily and then it was gone.
No error message, no nothing.
SPI (master) works, the simple spidev.c tester works and I can see the clocks from an external logic.
Now, I’m trying to make the Jetson nano work in a slave mode, so it could read and analyze a fast stream of data being sent to it from an external sensor,
So the next question would be, did this python script enabled SPI slave on SPI 0 & 1?
If so, could you point me to a simple SPI slave source that I could use as a reference, My focus is more on analyzing the data in the Jetson core rather the communication method which seem to take most of my time.
There currently isn’t a device tree model for using the tegra210 in slave mode. There’s a driver that supports it though so I can try and create one. Give me a day or so.
I think I’ve got a devicetree overlay that’ll put a controller in slave mode. I’m testing and packaging now. Do you have some software that uses the slave mode that I could test with?
The master in this case sends messages of 256 / 512 bytes, where the slave (Jetson) never sends anything, it’s a simple SPI listener, not sure if the CS is being used at all.
Each ‘message’ has start byte of 0xa5 and the last 2 bytes are crc16.
Once I have SPI slave mode running all I’ll crate some sort of a Q that stores those messages and another thread that takes those messages and do all the math.
Sorry. I got carried away with the install procedure and wound up writing a whole python library to create overlays. :) I’ll have a zip file for you to test with later this afternoon (GMT-7).
# unzip DTBOverlayCreator.zip
# cd DTBOverlayCreator
# make
# make install
# reboot
I’m still working on the documentation but running SPI_Custom.py will create a dts file that enables /dev/spidev0.0 in master mode and /dev/spidev1.0 in slave mode. The Makefile runs that python script and compiles the result into a new dtb file.
OK,so I have my sensor hooked to SPI1 (hope I got it right)
SPI1_CLK : PIN 13
SPI1_MISO : PIN 22
SPI1 CS0 : PIN 18
SPI1 MOSI : None, we are the slave and we never talk.
I have executed your script and rebooted.
So, since the overlay enables SPI on spidev I could actually read data from the master in user space ?
( I can see only spi=master under /sys/class)
If so could you point me to a sample that does this?
Could find anything regarding Linux, SPI -Slave, SPIDev.
First, I can’t thank you enough for all the help !
So I have the following :
I’ve attached a different board to the Jetosn’s SPI-1 (only Clk, MOSI & CS). This board is a
master that sends 0xa5 and 0x5a continuously at 500Khz, I have a logic that observing the data being sent between that board and the Jetson, everything looks fine, CS goes low, master is sending data during the 8 clocks it’s generating.
I’ve used SPI1 (37: MOSI, 13 CLK, 18: CS).
I’ve used you reference code, and made an infinite loop that read and print a received byte.
In another terminal I have ‘dmesg -w’
Immediately after I turn the master device on I get :
[ 8283.765308] spi_master spi1: CMD[03f01027]: Sl M0 CS0 [HHHH] MSB MSb Rx Pa 8b TRANS[00ff0000]:BSY I:255 B:0
FIFO[00c00004]:RxF:1 TxE:64 Err RxSTA TxSTA[E]DMA[00000000]: RxTr:0 TxTr:0 B:0
[ 8283.784388] spi_master spi1: failed to transfer one message from queue
[ 8283.792313] spi_master spi1: failed to transfer one message from queue
[ 8283.800204] spi_master spi1: failed to transfer one message from queue
[ 8283.807625] spi_master spi1: failed to transfer one message from queue … endlessly
(Doesn’t look good but it means that the Jetson knows that data is being transmitted, when I turn the master device off, those error messages stops).
My process gets many errors (read returns a negative value) and once in a while it reads a byte (but not 0xa5 or 0xa5).
Something is defiantly working now :)
And I think I know what’s causing the ‘failed to transfer one message from queue’ errors
My device is sending data at 12Mhz with about 30μ between each byte.
if I place ~5ms gap between the bytes everything works, once the gap is less I get tons of errors.
Is there anything I could do ?
The real sensor is sending data at fast rate and I can’t change it’s behavior.