Adafruit BBIO: GPIO input error : Set gpio mode failed, missing file or invalid permissions

I have problems with reading GPIO stat with Adafruit BBIO, here is the error:
root@beaglebone:/home/debian# python3
Connecting… /dev/ttyUSB0
main thread started
Traceback (most recent call last):
File “”, line 44, in
GPIO.setup(di0, GPIO.IN)
ValueError: Set gpio mode failed, missing file or invalid permissions.

Output of sudo /opt/scripts/tools/
dogtag:[ Debian Buster IoT Image 2020-04-06]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2019.04-00002-g31a8ae0206]:[location: dd MBR]
UBOOT: Booted Device-Tree:[am335x-boneblack-uboot-univ.dts]
UBOOT: Loaded Overlay:[AM335X-PRU-RPROC-4-19-TI-00A0]
UBOOT: Loaded Overlay:[BB-ADC-00A0]
UBOOT: Loaded Overlay:[BB-BONE-eMMC1-01-00A0]
UBOOT: Loaded Overlay:[BB-HDMI-TDA998x-00A0]
/boot/uEnv.txt Settings:
pkg check: to individually upgrade run: [sudo apt install --only-upgrade ]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal bluetooth netdev i2c gpio pwm eqep remoteproc admin spi iio docker tisdk weston-launch xenomai cloud9ide]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk1p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet]
dmesg | grep remote
[ 55.938370] remoteproc remoteproc0: wkup_m3 is available
[ 56.036447] remoteproc remoteproc0: powering up wkup_m3
[ 56.036480] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217168
[ 56.036771] remoteproc remoteproc0: remote processor wkup_m3 is now up
[ 58.419640] remoteproc remoteproc1: is available
[ 58.437995] remoteproc remoteproc2: is available
dmesg | grep pru
[ 58.419640] remoteproc remoteproc1: is available
[ 58.419776] pru-rproc PRU rproc node pru@4a334000 probed successfully
[ 58.437995] remoteproc remoteproc2: is available
[ 58.438168] pru-rproc PRU rproc node pru@4a338000 probed successfully
dmesg | grep pinctrl-single
[ 0.921873] pinctrl-single 44e10800.pinmux: 142 pins, size 568
dmesg | grep gpio-of-helper
[ 0.935074] gpio-of-helper ocp:cape-universal: ready
Bus 001 Device 002: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Can you please advise what I’m doing wrong and how to fix it?

I am using the Adafruit library on a BBB, although with a slightly older kernel.

I would check permissions first, given the error message.

from console do

ls -l /sys/class/gpio

make a note of the file group owner for export (4th column)

On my board /sys/class/gpio/export is owned by root/gpio

then as the debian user type


make sure the group from the first command is included in the output of the second.

If it isn’t you can add the group by doing (as root or using sudo)

usermod -a -G ‘missing group name’ debian

If debian is already a member of the group, after booting but before running your code, it would also be worth checking /sys/class/gpio/ to see if something else has grabbed the I/O pin already. That will also cause your program to fail.

Hi Benedict

I’m trying to install the Adafruit_BBIO library on the am335x-debian-11.5-minimal-armhf-2022-11-01-2gb.img.xz image on my BeagleBone Green. I had already quite a hard time getting the image to the emmc but now I get errors installing the library following the instructions on:

It states Adafruit_BBIO supports Linux kernels 3.8 through 4.19 … I’m on 5.10.140-ti-r52 :confused:

Which version do you use?

Can I simply downgrade the kernel or do I have to install an older image?

Did you try the Adafruit_Blinka library on the BBB/BBG?


Just downgrade to 4.19.x-ti Debian 10.x/11.x Kernel Updates

that project needs a maintainer…


Thanks for the quick reply @RobertCNelson

Unfortunately the downgrade did not solve the problem. A few hours of trial & error later I figured out that the root cause for the error during the installation is due to python version api deprications.

Adafruit BBIO is built/tested with python 3.7 but uses the function PyEval_ThreadsInitialized which was deprecated in version 3.9:

When I interprete the docs correctly, this call is not really required since it should have been dealt with already…
So I modified the source code of the Adafruit BBIO (py_gpio.c) and installed manually, which still raised some warnings, but no errors!

Search for PyEval_ThreadsInitialized() and add the following directives on the line before:

#if PY_VERSION_HEX >= 0x03070000 && !defined(PyEval_ThreadsInitialized)
#define PyEval_ThreadsInitialized() 1

Found this solution via

It might not be the best solution, but it seems to work. I’ll open an issue for this, maybe someone with more experience can do it properly and create a pull-request.

Hope this helps somebody else faceing this issue.



  • Added link to adafruit-beaglebone-io-python issues
1 Like