GPIO Input set mode failed using Adafruit_BBIO (works for GPIO Output)

I am unable to setup a GPIO pin as an input using the Adafruit_BBIO library. Setting the pin as an output works. Below is a simple version of what I want to do. I searched several chat groups (this and the adafruit forum) and the issues list for the Adafruit_BBIO library for ideas. I tried updating my bootloader (from U-Boot 2018.09-00002-g9d95a561c9 to U-Boot 2019.04-00002-gbb4af0f50f), but that did not have an impact. I am using a UART port, so the uboot_overlay is enabled. The image version used is based on the 9/11/18 release. I would prefer not to move to a newer release quite yet, but do plan to do so in about a month. Is there anything I can do here to make this work with this current setup? Please let me know what other information would be useful here.

Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import Adafruit_BBIO.GPIO as GPIO
GPIO.setup(‘P8_11’, GPIO.OUT, GPIO.PUD_UP, 0, 100)
GPIO.output(‘P8_11’, 1)
GPIO.input(‘P8_11’)
1

GPIO.cleanup(‘P8_11’)
GPIO.setup(‘P8_11’, GPIO.IN)
Traceback (most recent call last):
File “”, line 1, in
ValueError: Set gpio mode failed, missing file or invalid permissions.

sudo /opt/scripts/tools/version.sh
git:/opt/scripts/:[24f2e3495113a63c2dcc2c0bdc0d7660b54e4e8f]
eeprom:[A335BNLT00C02016BBBK1A0B]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[RIAPS console Ubuntu Image 2019-03-22]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2019.04-00002-gbb4af0f50f]:[location: dd MBR]
kernel:[4.14.79-ti-rt-r84]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_addr4=/lib/firmware/BB-UART2-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade ]
pkg:[bb-cape-overlays]:[4.4.20190320.1-0rcnee0~bionic+20190320]
pkg:[bb-wl18xx-firmware]:[1.20190227.1-0rcnee0~bionic+20190227]
pkg:[kmod]:[24-1ubuntu3.2rcnee0~bionic+20190208]
WARNING:pkg:[librobotcontrol]:[NOT_INSTALLED]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet security=apparmor]
dmesg | grep remote
[ 1.849544] remoteproc remoteproc0: wkup_m3 is available
[ 2.096540] remoteproc remoteproc0: powering up wkup_m3
[ 2.096675] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217168
[ 2.099941] remoteproc remoteproc0: remote processor wkup_m3 is now up
dmesg | grep pru

uname -a
Linux bbb-ff98 4.14.79-ti-rt-r84 #1 SMP PREEMPT RT Tue Nov 13 22:30:45 UTC 2018 armv7l armv7l armv7l GNU/Linux

Is your user a member of the gpio group? If the pin is already an output and you don’t have permission it seems reasonable that it might not fail.

You could always sudo python to rule out a permissions problem, which is what the error message says. Then solve the permissions problem.

Have fun

Jim

The user name is a part of the “gpio” group. I did try running sudo python3 from riaps user and moving to root user and running this again, but same issue is happening.

riaps : riaps adm kmem dialout cdrom floppy sudo audio dip video plugdev users systemd-journal bluetooth netdev i2c gpio pwm eqep admin spi tisdk weston-launch xenomai cloud9ide

If you are using a microsd card to boot, either update the bootloader on the BBB board (remove the microsd card, boot, sudo git pull, etc) or press the boot button on every boot.

Chad

I am using an SD Card to boot. I updated the BBB board to be the latest flasher image, then updated the bootloader on this image using ‘sudo /opt/scripts/tools/developers/update_bootloader.sh’. The board is now the latest, along with the SD card image. I then installed python3 and Adafruit-BBIO on the board image, with this the GPIO input setup worked. Looking at this uEnv.txt file, the universal cape is enabled. So, I went back to my SD card image and enabled the universal cape there and it worked. BUT, I do not want all ports open for product solutions. While this fixes this issue, it still seems to leave the system open for security issues by having all GPIO and UART ports open. Is there a different way to enable specific GPIO ports like there is for the UART? I do not see any built-in overlays that address GPIO (/lib/firmware).

Information from BBB board image:

git:/opt/scripts/:[9df8deb6b2ae7570c9102ab58f795d3bed592194]
eeprom:[A335BNLT00C02016BBBK1A0B]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[rcn-ee.net console Ubuntu Image 2019-04-10]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2019.04-00002-gbb4af0f50f]:[location: dd MBR]
kernel:[4.14.108-ti-r104]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade ]
pkg:[bb-cape-overlays]:[4.4.20190404.0-0rcnee0~bionic+20190404]
pkg:[bb-wl18xx-firmware]:[1.20190227.1-0rcnee0~bionic+20190227]
pkg:[kmod]:[24-1ubuntu3.2rcnee0~bionic+20190208]
WARNING:pkg:[librobotcontrol]:[NOT_INSTALLED]
groups:[ubuntu : ubuntu adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal bluetooth netdev i2c gpio pwm eqep admin spi 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 quiet cape_universal=enable]
dmesg | grep remote
[ 1.400670] remoteproc remoteproc0: wkup_m3 is available
[ 1.617230] remoteproc remoteproc0: powering up wkup_m3
[ 1.617347] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217168
[ 1.621695] remoteproc remoteproc0: remote processor wkup_m3 is now up
dmesg | grep pru
dmesg | grep pinctrl-single
[ 1.094293] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568
dmesg | grep gpio-of-helper
[ 1.106412] gpio-of-helper ocp:cape-universal: ready
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
END