Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to open SPI device: No such file or directory #28

Open
demenkovms opened this issue Mar 31, 2023 · 21 comments
Open

Unable to open SPI device: No such file or directory #28

demenkovms opened this issue Mar 31, 2023 · 21 comments

Comments

@demenkovms
Copy link

demenkovms commented Mar 31, 2023

Try to use it on Orange Pi Zero with WiringPi.

I connect TFT to OPI zero, to SPI 1

TFT                                OPI
SDO(MISO)  -------->   SPI1_MISO/PA16
SCK             -------->    SPI1_CLK/PA14
SDI(MOSI)    -------->   SPI1_MOSI/PA15
DC               -------->   PA12
RESET           -------->   PA11
CS                -------->   PA13
VCC, LED     -------->    3.3v
GND            -------->    GND

set in ili9340.c
#define D_C  12
#define RES  11
#define C_S  13

make
cc -o demo demo.c fontx.c ili9340.c -lwiringPi -lm -DWPI

in /boot/orangepiEnv.txt add:

overlays=spi-jedec-nor spi-spidev 
param_spidev_spi_bus=0

run ./demo and get:

Your TFT resolution is 240 x 320.
Your TFT offsetx    is 0.
Your TFT offsety    is 0.
Opening device /dev/spidev0.0
Unable to open SPI device: No such file or directory

Please, help: what I did wrong? Thanks!

@nopnop2002
Copy link
Owner

nopnop2002 commented Apr 1, 2023

Opening device /dev/spidev0.0

Orange Pi Zero's CS is CS1, not CS0.

Add the following two lines to /boot/armbianEnv.txt and reboot

overlays=spi-spidev usbhost2 usbhost3
param_spidev_spi_bus=1
$ ls /dev/spi*
/dev/spidev1.0

Clone latest and build.

$ cc -o demo demo.c fontx.c ili9340.c -lwiringPi -lm -pthread -DWPI -DSPI1

@demenkovms
Copy link
Author

Thanks for answer! Not I get
изображение

but nothing shows on display - it's white

@nopnop2002
Copy link
Owner

nopnop2002 commented Apr 1, 2023

set in ili9340.c
#define D_C  12
#define RES  11
#define C_S  13

There are several WiringPi libraries that can be used with ZERO, and the allocation of GPIO is different for each.

This is the WiringPi library I'm using.

It's probably not the same as you are using.

readall-OPI-ZERO-1

You can check the GPIO number of your library using GPIO command and LED Blinking.

$ gpio -g mode 13 out
$ gpio -g write 13 on
$ gpio -g write 13 off

@demenkovms
Copy link
Author

hm...
in my
изображение

is I need set number by from GPIO or wPi?

@nopnop2002
Copy link
Owner

nopnop2002 commented Apr 1, 2023

is I need set number by from GPIO or wPi?

probably neither

You should investigate the GPIO pinmap.

Does the following command blink the LED connected to pin number 8?

$ gpio -g mode 198 out
$ gpio -g write 198 on
$ gpio -g write 198 off

On my WiringPi this will flash pin number 8.

$ gpio -g mode 20 out
$ gpio -g write 20 on
$ gpio -g write 20 off

It is very difficult to use WiringPi Library in the OrangePi series.

@demenkovms
Copy link
Author

led is not not blink and gpio not made on...

изображение

@demenkovms
Copy link
Author

demenkovms commented Apr 2, 2023

I download this library https://github.com/xpertsavenue/WiringOP-Zero and it works correct with LED.

изображение

then I change in ili9340.c pins for wPi

#define D_C  8 

#define RES  9 

#define C_S  10

recompiled demo, but nothing changed...

@nopnop2002
Copy link
Owner

nopnop2002 commented Apr 2, 2023

@demenkovms
Copy link
Author

I need to downgrade kernel to 5.10. Is I correctly understood?

@nopnop2002
Copy link
Owner

You are correct, but there is no mention of OPI-ZERO anywhere.

OPI-ZERO is SPI1, so there may be other issues.

@demenkovms
Copy link
Author

then, may be it’s possible to change spi in library code?

@nopnop2002
Copy link
Owner

nopnop2002 commented Apr 2, 2023

I can’t understand your mention.

The WiringPi library is provided in source, so you can modify it as you like.

And since this project is also provided in source, you can modify it to your liking.

@demenkovms
Copy link
Author

I mean: in your library used /dev/spi0, and in Opi Zero used /dev/spi1. Can I change spi0 to spi1 in code?

@nopnop2002
Copy link
Owner

Can I change spi0 to spi1 in code?

Use compile flag.
-DSPI1

@demenkovms
Copy link
Author

yes. I compiled with this flag, as you wrote some posts earlier. It’s runs correctly but nothing shows on display

@nopnop2002
Copy link
Owner

nopnop2002 commented Apr 2, 2023

Using the latest repo, I have verified that it works fine on OrangePiPC.

$ uname -a
Linux orangepipc 5.10.60-sunxi #21.08.1 SMP Wed Aug 25 18:19:32 UTC 2021 armv7l GNU/Linux

$ cat /boot/armbianEnv.txt
verbosity=1
bootlogo=false
console=both
disp_mode=1920x1080p60
overlay_prefix=sun8i-h3
rootdev=UUID=8724794f-4966-4eeb-9e56-4eab78d3c318
rootfstype=ext4
overlays=spi-spidev
param_spidev_spi_bus=0
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

$ ls /dev/spi*
/dev/spidev0.0

RES-->Pin#5
DC-->Pin#3

git clone https://github.com/nopnop2002/Raspberry-ili9340spi
cd Raspberry-ili9340spi
cc -o demo demo.c fontx.c ili9340.c -lwiringPi -lm -pthread -DWPI
sudo ./demo

IMG_3601

Try latest, and with -DSPI1.

@nopnop2002
Copy link
Owner

nopnop2002 commented Apr 3, 2023

OrangePi ONE works fine.

However, it doesn't work properly with OrangePi ZERO.

It's probably a problem with ZERO's SPI driver.

IMG_3604

@demenkovms
Copy link
Author

I really can not understand what is wrong...

I reinstall Armbial for early version:

uname -a
Linux orangepizero 5.10.12-sunxi #21.02.1 SMP Wed Feb 3 20:39:30 CET 2021 armv7l GNU/Linux

edit /boot/armbianEnv.txt

verbosity=1
bootlogo=false
console=serial
disp_mode=1920x1080p60
overlay_prefix=sun8i-h3
overlays=usbhost2 usbhost3
rootdev=UUID=13a6830e-cee9-4001-83ce-6b4e7542699c
rootfstype=ext4
overlays=spi-spidev
param_spidev_spi_bus=0
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

and now I have SPI0:
изображение

gpio readall return:

изображение

Try to blink LED:

gpio mode 6 OUT
gpio write 6 on
gpio write 6 off

all work correctly - led was blink

check connection:

TFT OPI
SDO(MISO) --------> SPI1_MISO/PA16 (gpio 16 - wPi 12 - pin 21)
SCK --------> SPI1_CLK/PA14 (gpio 14 - wPi 14 - pin 23)
SDI(MOSI) --------> SPI1_MOSI/PA15 (gpio15 - wPi 11 - pin 19)
DC --------> PA12 (gpio 12 - wPi 0 - pin 3)
RESET --------> PA11 (gpio 11 - wPi 1 - pin 5)
CS --------> PA13 (gpio 13 - wPi 16 - pin 26)
VCC, LED --------> 3.3v
GND --------> GND

download new repo, make

cc -o demo demo.c fontx.c ili9340.c -lwiringPi -lm -pthread -DWPI

on run ./demo get output:
изображение

but the display is white...

@nopnop2002
Copy link
Owner

nopnop2002 commented Apr 4, 2023

change and try

It will blink pin#3

gpio mode 0 OUT
gpio write 0 on
gpio write 0 off

It will blink pin#5

gpio mode 1 OUT
gpio write 1 on
gpio write 1 off

param_spidev_spi_bus=0 ---> param_spidev_spi_bus=1

DC --------> PA12 (gpio 12 - wPi 0 - pin 3) --> #define D_C 0 // wPi IO0=Pin#3

RESET --------> PA11 (gpio 11 - wPi 1 - pin 5) --> #define RES 1 // wPi IO1=Pin#5

cc -o demo demo.c fontx.c ili9340.c -lwiringPi -lm -pthread -DWPI -DSPI1

@nopnop2002
Copy link
Owner

nopnop2002 commented Apr 5, 2023

I tried this and it doesn't work.

$ dmesg | grep spi
[    4.488718] spidev spi1.0: probing from DT

$ ls /dev/spi*
/dev/spidev1.0

$ uname -a
Linux orangepizero 5.10.34-sunxi #21.05.1 SMP Thu May 6 20:13:21 UTC 2021 armv7l GNU/Linux

$ cat /boot/armbianEnv.txt
verbosity=1
bootlogo=false
console=serial
disp_mode=1920x1080p60
overlay_prefix=sun8i-h3
overlays=usbhost2 usbhost3
rootdev=UUID=93502503-5a81-4c0c-b76e-fabcad07a82b
rootfstype=ext4
overlays=spi-spidev
param_spidev_spi_bus=1
param_spidev_spi_cs=0
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

@nopnop2002
Copy link
Owner

Hardware SPI doesn't work properly on ZERO.

So we supported software SPI.
Very slow but work.

I used this library.

https://github.com/xpertsavenue/WiringOP-Zero

$ uname -a
Linux orangepizero 5.15.93-sunxi #23.02.2 SMP Fri Feb 17 23:49:46 UTC 2023 armv7l GNU/Linux

IMG_3608

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants