I’m working with the Verdin AM62 SoM on the Mallow Carrier Board, and I’ve successfully built a Yocto image. I’m currently trying to enable SPI1 and have written the following device tree overlay for it:
We already have an overlay if you are trying to use/test the SPI. You can find it here.
It enables the spidev to be used in userspace. For more information about it, please refer to this article.
Regarding the upstream, are you using the upstream kernel? As you are using a written device tree as an example, I would recommend using the device tree from the same branch of the kernel you are using. Otherwise, you could face errors due to the different device trees.
I’m using the same code structure you shared previously for GPIO pull-up configuration, and I followed that style to set up the spidev overlay as well.
kernel - (6.6.84-7.2.0-devel)
Now, coming to the pre-built overlay — I see that it looks like this:
Let’s say I want to modify the max frequency and SPI mode — I’d like to know where exactly I should make those changes, especially since it looks like these overlays are being pulled from GitHub directly.
Once everything is in place, what’s the best way to check if spidev is actually working?
As far as I understood, you can change the mode, and probably the frequency, using the spidev_test, which is the script you can use to test the spidev. You can find it here.
You’ll need to compile it with make (remember to prepare your computer for cross-compilation with arm64). Then you can copy it using scp command to the module, and run the script.
I saw it has some interesting flags, as you can see below:
Usage: ./spidev_test [-2348CDFHILMNORSZbdilopsv]
general device settings:
-D --device device to use (default /dev/spidev1.1)
-s --speed max speed (Hz)
-d --delay delay (usec)
-l --loop loopback
spi mode:
-H --cpha clock phase
-O --cpol clock polarity
-F --rx-cpha-flip flip CPHA on Rx only xfer
number of wires for transmission:
-2 --dual dual transfer
-4 --quad quad transfer
-8 --octal octal transfer
-3 --3wire SI/SO signals shared
-Z --3wire-hiz high impedance turnaround
data:
-i --input input data from a file (e.g. "test.bin")
-o --output output data to a file (e.g. "results.bin")
-p Send data (e.g. "1234\xde\xad")
-S --size transfer size
-I --iter iterations
additional parameters:
-b --bpw bits per word
-L --lsb least significant bit first
-C --cs-high chip select active high
-N --no-cs no chip select
-R --ready slave pulls low to pause
-M --mosi-idle-low leave mosi line low when idle
misc:
-v --verbose Verbose (show tx buffer)
You can set the mode and the max speed using these flags.