ronnih
Posts: 14
Joined: Wed Nov 29, 2017 8:59 am

[solved] Control GPIO with openSuse?

Sun Oct 14, 2018 1:09 pm

Hello,

I test openSUSE Tumbleweed VERSION="20180920" on Raspberry Pi Model B Rev 2. The OS works fine and I find Nextcloud in the Repository thats good :)

But now I would like to control an LED with GPIO and Bash commands. But I receive an error:

Code: Select all

fhem02:/sys/class/gpio # echo 17 > /sys/class/gpio/export
-bash: echo: write error: Invalid argument
fhem02:/sys/class/gpio # echo 27 > /sys/class/gpio/export
-bash: echo: write error: Invalid argument
fhem02:/sys/class/gpio # echo 22 > /sys/class/gpio/export
-bash: echo: write error: Invalid argument
On Raspbian the commands works how expectet. Is there someting what I must change on openSUSE? Must I load a kernel modul?

Thx for all infos.
LG
ronnih
Last edited by ronnih on Sun Oct 14, 2018 6:05 pm, edited 1 time in total.

ronnih
Posts: 14
Joined: Wed Nov 29, 2017 8:59 am

Re: Control GPIO with openSuse?

Sun Oct 14, 2018 6:03 pm

Found the Solution for this problem.

In the path /sys/class/gpio contains the following:

Code: Select all

--w-------  1 root root 4096 Oct 14 17:32 export
lrwxrwxrwx  1 root root    0 Oct 14 17:32 gpiochip298 -> ../../devices/platform/soc/20200000.gpio/gpio/gpiochip298/
--w-------  1 root root 4096 Oct 14 17:32 unexport
Here we have gpiochip298. The 298 is where the GPIOs start, so you can say it is 0. That you can see in the file /sys/kernel/debug/gpio

Code: Select all

gpiochip0: GPIOs 298-351, parent: platform/20200000.gpio, pinctrl-bcm2835:
 gpio-314 (                    |led0                ) out hi    
Now if you like to control GPIO 23 you musst take 298 + 23 = 321. An the next steps are the same how in Raspbian:

GPIO Port activate:

Code: Select all

echo 321 > /sys/class/gpio/export
define as output:

Code: Select all

echo out > gpio321/direction
And set them to high signal:

Code: Select all

echo 1 > gpio321/value
LG
ronnih

Return to “openSUSE”