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 /sys/class/gpio.

> 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.


  • Could you add the result of ls -l /dev/gpiochip* to your question.
    – joan
    Commented Jan 6, 2021 at 16:36
  • @joan I've added it that info in now, thanks. Commented Jan 6, 2021 at 18:53

3 Answers 3


I'm using a fresh aarch64 with Arch Linux on a RPi 4B, and had the same issue with echoing low numbers to /sys/class/gpio/export. Reading more, I see that the sysfs approach is legacy and probably being dropped from newer kernels. The character device ABI, using /dev/gpiochip[0-9]+ (as discussed by @joan), is the new way to access GPIOs.

On Arch, the gpio-utils package offers lsgpio, gpio-watch, gpio-hammer, gpio-event-mon as easy CLI tools for interacting with GPIO character devices. On Debian Buster, package gpiod provides gpioget, gpioinfo, gpiomon, gpioset, which may do the same.


I don't know why the sysfs exports aren't working. I tried a few variants of your commands but they did not work.

Given that the /dev/gpiochip devices exist you could use that interface instead.

I have a new /dev/gpiochip library suite called lg.


You could use that to manipulate the GPIO.

I have added some details at https://elinux.org/C

  • I'll take a look at that thanks. Unfortunately, my need for this to work is that my power management board (x735) relies on bash scripts and services to work. It'll mean having to convert everything. But converting is better than it not working at all. Thanks. Commented Jan 6, 2021 at 19:31

In one of the /sys/class/gpio/gpiochipNNN directories, there is a file named label containing pinctrl-bcm2835. This is the one you want.

You also see a file base which is the offset for GPIO-0. You add that to your GPIO number and write the result to export. Presto, you have a new numbered subdirectory /sys/class/gpio/gpioXXX which you can control as usual.

If this doesn't work, you most likely have a bug in your code.

  • The question was posted 3 years ago so, hopefully things have improved now. Either way, I've moved back to the RaspberryPi OS. But, I'm sure people would appreciate it if you could expand your answer a little for others to reference. Commented Dec 12, 2023 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.