I'm running a Pi4 with Debian Buster (not Raspbian / RaspberryPi OS) and need to interact with the GPIO pins but am having problems doing so.
I've created a gpio group and added the pi user to it along with setting the file permissions and group accordingly (re:GPIO Permission Denied). However accessing GPIO18 and other gives me the following error:
> sudo sh -c 'echo 18 >/sys/class/gpio/export' > sh: 1: echo: echo: I/O error
> echo 18 >/sys/class/gpio/export > -bash: echo: write error: Invalid argument
If I run
ls /sys/class/gpio I get:
> export gpiochip446 gpiochip454 unexport
I can see (cant recall the command used) the gpiochip454 handles 58 pins and is the Broadcom BCM2711 which handles the GPIO. As a test I tried to export various GPIO pin numbers but none of them worked if below the gpiochip number. However, all (58) numbers from the gpiochip number upwards, do export.
So, I took a guess and assumed that if I counted up 18 pings from the gpiochip number (gpio472), I should be able to interact with gpio18, but this did not shutdown the power management board that reacts to gpio18. I also tried using the physical pin number(12) and adding this to the chip number giving me gpio466. Again, this did nothing, although in both cases I do see these pins being exported and visible via
> ls -l /dev/gpiochip* crw------- 1 root root 254, 0 Jan 4 16:06 /dev/gpiochip0 crw------- 1 root root 254, 1 Jan 4 16:06 /dev/gpiochip1
Is there a way that I can use the gpio number like I would on Raspbian / Raspberrypi OS ?
I'm now at a loss as to what I need to do to get this working and would appreciate some help in working this out.