Hello, I have an issue working with SPI 3-wire mode and spi.no_cs = True

Hello, I have an issue working with SPI 3-wire mode.

I want to manually control the CS (Chip Select) line using GPIO,
but I always get an error when I try to use spi.no_cs = True.

Why does this happen, and how can I fix it?


any one can help

Hi khaled178234,

Are you using the devkit or custom board for Orin NX?
What’s the Jetpack version in use?

Please share the full dmesg and device tree for this use case.
Which GPIO you are using?

Could you elaborate on this? Do you customize something in SPI driver?

Holybro Pixhawk Jetson Baseboard

3 aarch64 aarch64 aarch64 GNU/Linux
holybro-nx@holybronx-desktop:~$
holybro-nx@holybronx-desktop:~$ head -n 1 /etc/nv_tegra_release

R35 (release), REVISION: 4.1, GCID: 33958178, BOARD: t186ref, EABI: aarch64, DATE: Tue Aug 1 19:57:35 UTC 2023

Please also help to answer these questions.

It’s an quite old release. Could you also verify with the latest Jetpack 5.1.5(r35.6.2) to verify?

“When I try to use spidev, it always receives 0. Why?”

What do you mean about “receives 0”? Do you mean the MISO staying LOW?

holybro-nx@holybronx-desktop:~$ sudo ./spidev_test -D /dev/spidev0.0 -p “Test” -s 500000 -H -O -v
spi mode: 0x3
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX | 54 65 73 74 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ |Test|
RX | 00 00 00 00 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ |…|
holybro-nx@holybronx-desktop:~$
holybro-nx@holybronx-desktop:~$ sudo ./spidev_test -D /dev/spidev0.0 -p “Test” -s 500000 -H -O -v
spi mode: 0x3
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX | 54 65 73 74 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ |Test|
RX | 00 00 00 00 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ |…|
holybro-nx@holybronx-desktop:~$ sudo ./spidev_test -D /dev/spidev0.0 -p “Test” -s 500000 -H -v
spi mode: 0x1
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX | 54 65 73 74 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ |Test|
RX | 00 00 00 00 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ |…|
holybro-nx@holybronx-desktop:~$ sudo ./spidev_test -D /dev/spidev0.0 -p “Test” -s 500000 -H -O -v
spi mode: 0x3
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX | 54 65 73 74 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ |Test|
RX | 00 00 00 00 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ |…|
holybro-nx@holybronx-desktop:~$ sudo ./spidev_test -D /dev/spidev0.0 -l -v
can’t set spi mode: Invalid argument
Aborted
holybro-nx@holybronx-desktop:~$
holybro-nx@holybronx-desktop:~$ sudo ./spidev_test -D /dev/spidev0.1 -l -v
can’t set spi mode: Invalid argument
Aborted
holybro-nx@holybronx-desktop:~$ sudo ./spidev_test -D /dev/spidev1.0 -l -v
can’t set spi mode: Invalid argument
Aborted
holybro-nx@holybronx-desktop:~$ sudo ./spidev_test -D /dev/spidev0.0 -H -O -l -v
can’t set spi mode: Invalid argument
Aborted
holybro-nx@holybronx-desktop:~$
holybro-nx@holybronx-desktop:~$ sudo ./spidev_test -D /dev/spidev0.0 -s 500000 -b 8 -l -v
can’t set spi mode: Invalid argument
Aborted

There is no update from you for a period, assuming this is not an issue anymore.
Hence, we are closing this topic. If need further support, please open a new one.
Thanks
~1105

Could you get a scope or logic analyzer to measure the signal from both MISO and MOSO?

Is SPI mode 3 your expected SPI mode?

Please also verify SPI loopback test for both SPI1 and SPI3.

I would also like to check the full dmesg and device tree in your case.