Jump to content
Shin

Unable to open SPI device

Recommended Posts

Hi,

I am following the URL below to start up SPI with WiringPi library.

I can see spidev in /dev on my TinkerBoard2S. Therefore, I believe the spi settings are reflected at boot time.

linaro@linaro-alip:~/Desktop/CSampleCode/spiSpeed$ ls /dev/spidev*
/dev/spidev1.0  /dev/spidev5.0

When I run the sample code, I get an error "Unble to open SPI device". 
Can you please tell me the cause and countermeasure?

linaro@linaro-alip:~$ cd /home/linaro/Desktop/CSampleCode/spiSpeed/
linaro@linaro-alip:~/Desktop/CSampleCode/spiSpeed$ sudo ./spiSpeed 
+-------+--------+----------+----------+-----------+------------+
|   MHz |   Size | mS/Trans |      TpS |    Mb/Sec | Latency mS |
+-------+--------+----------+----------+-----------+------------+
Unable to open SPI device: No such file or directory

Board:TinkerBoard2S

Linux version:4.4.194

 

Best regards,

 

Share this post


Link to post
Share on other sites

hello @Shin

sorry for the inconvenience. this was caused by a bug that we're aiming to fix in the next releases (for both kernel 4.19/ 5.10), before that, please follow the steps below to fix it manually.

1. update the system time (the compiler library would check it so the time has to be correct)

2. use commands to rebuild and reinstall wiringpi libraries for tinker board 2s: 

cd /usr/local/share/gpio_lib_c_rk3399
sudo ./build clean
sudo ./build uninstall
sudo ./build

 

Share this post


Link to post
Share on other sites

hello @tooz

I installed WiringPi using the method you provided. However, the problem was not resolved.
I have already installed the latest Linux(debian 11 v.3.0.18 kernel 5.10).

linaro@linaro-alip:/usr/local/share/gpio_lib_c_rk3399$ sudo ./build clean
wiringPi:   [Clean]
DevLib:     [Clean]
gpio:       [Clean]
Examples:   [Clean]
Gertboard:  [Clean]
PiFace:     [Clean]
Quick2Wire: [Clean]
PiGlow:     [Clean]
linaro@linaro-alip:/usr/local/share/gpio_lib_c_rk3399$ sudo ./build uninstall
wiringPi: [UnInstall]
DevLib:   [UnInstall]
gpio:     [UnInstall]
linaro@linaro-alip:/usr/local/share/gpio_lib_c_rk3399$ sudo ./build
wiringPi Build script
=====================


WiringPi Library
[UnInstall]
Rockchip
Rockchip
[Compile] wiringPi.c
[Compile] wiringTB.c
[Compile] wiringSerial.c
[Compile] wiringShift.c
[Compile] piHiPri.c
[Compile] piThread.c
[Compile] wiringPiSPI.c
[Compile] wiringPiI2C.c
[Compile] softPwm.c
[Compile] softTone.c
[Compile] mcp23008.c
[Compile] mcp23016.c
[Compile] mcp23017.c
[Compile] mcp23s08.c
[Compile] mcp23s17.c
[Compile] sr595.c
[Compile] pcf8574.c
[Compile] pcf8591.c
[Compile] mcp3002.c
[Compile] mcp3004.c
[Compile] mcp4802.c
[Compile] mcp3422.c
[Compile] max31855.c
[Compile] max5322.c
[Compile] sn3218.c
[Compile] drcSerial.c
[Compile] wpiExtensions.c
[Link (Dynamic)]
[Install Headers]
[Install Dynamic Lib]

WiringPi Devices Library
[UnInstall]
[Compile] ds1302.c
[Compile] maxdetect.c
[Compile] piNes.c
[Compile] gertboard.c
[Compile] piFace.c
[Compile] lcd128x64.c
[Compile] lcd.c
[Compile] piGlow.c
[Link (Dynamic)]
[Install Headers]
[Install Dynamic Lib]

GPIO Utility
[Compile] gpio.c
[Compile] readall.c
[Compile] pins.c
[Link]
[Install]

All Done.

NOTE: To compile programs with wiringPi, you need to add:
    -lwiringPi
  to your compile line(s) To use the Gertboard, MaxDetect, etc.
  code (the devLib), you need to also add:
    -lwiringPiDev
  to your compile line(s).

linaro@linaro-alip:/usr/local/share/gpio_lib_c_rk3399$ cd /home/linaro/Desktop/CSampleCode/spiSpeed/
linaro@linaro-alip:~/Desktop/CSampleCode/spiSpeed$ sudo gcc -o spiSpeed spiSpeed.c -lwiringPi -lpthread
linaro@linaro-alip:~/Desktop/CSampleCode/spiSpeed$ ls /dev/spidev*
/dev/spidev1.0  /dev/spidev5.0
linaro@linaro-alip:~/Desktop/CSampleCode/spiSpeed$ sudo ./spiSpeed 
+-------+--------+----------+----------+-----------+------------+
|   MHz |   Size | mS/Trans |      TpS |    Mb/Sec | Latency mS |
+-------+--------+----------+----------+-----------+------------+
Unable to open SPI device: No such file or directory

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...