SPI error : can't open device: No such file or directory

Dear Support,
After pasting the spidev_test.c to the main .c, and run it, has an error and pleases see the image below,

for device it was static const char *device = “/dev/spidev1.1”; I change it to static const char *device = “/dev/spidev1.0”; and then changed to static const char *device = “/dev/verdin-spi-cs0”; none of them works


Also at Custom Properties , added appargs -D /dev/verdin-spi-cs0

please see the output and debug console text.

debug console.txt (1.5 KB)
output.txt (26.7 KB)

Best regards,
Mehrdad

Hi @Mehrdad ,

From your configuration properties I can see that you added appargs and set it correctly with -D /dev/verdin-spi-cs0. Now you also need to add an entry in devices and put the value as /dev/verdin-spi-cs0.

Changing the code itself shouldn’t be necessary, so I suggest reverting any changes you’ve made to it.

Try doing the above and see if the code works.

Best regards,
Lucas Akira

1 Like

Hi @lucas_a.tx ,

I have added /dev/gpiochip4 before and I did not know I should add SPI as well after adding /dev/verdin-spi-cs0 to the devices it works, thank you so much, and sorry for asking simple questions, thanks for taking your time.
and if I want to use send and received data I should use void transfer functions in int main? Are there any examples?

Best regards,
Mehrdad

Hi @Mehrdad ,

No problem, glad to help!

For more information on how to use spidev_test look here: linux/spidev_test.c at v5.15 · torvalds/linux · GitHub. There are ways to transmit and receive data without altering the code.

For instance, you can change appargs to -D /dev/verdin-spi-cs0 -v -p "1234\xDE\xAD" to send chars ‘1’, ‘2’, ‘3’ and ‘4’ followed by hex bytes 0xDE and 0xAD. The -v option shows the TX buffer.

If you short-circuit the MOSI and MISO pins (loopback) and use the new appargs you should see a result similar to this:

spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 kHz)
TX | 31 32 33 34 DE AD __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  |1234..|
RX | 31 32 33 34 DE AD __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  |1234..|

Best regards,
Lucas Akira

1 Like

Hi @lucas_a.tx ,
Thank you so much for taking the time.


I appreciate you taking the time to respond. Thanks for helping me sort it out.

1 Like