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.