BeagleBone Blue: Set gpio direction failed
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

BeagleBone Blue: Set gpio direction failed

by vmasan on Sun Jun 24, 2018 11:09 am


I'm using Cloud9 IDE to write code for BeagleBone Blue with Debian 9.4 2018-06-17 4GB SD LXQT installed (found here https://beagleboard.org/latest-images)

Here is the code:

Code: Select all | TOGGLE FULL SIZE
import Adafruit_BBIO.GPIO as GPIO

GPIO.setup("P8_9", GPIO.IN)
GPIO.setup("P8_7", GPIO.OUT)

while True:
    if GPIO.input("P8_9"):
        GPIO.output("P8_7", GPIO.HIGH)
        GPIO.output("P8_7", GPIO.LOW)

According to this link https://github.com/beagleboard/beaglebone-blue/blob/master/BeagleBone_Blue_Pin_Table.csv, P8_9 is pause button and P8_7 is red LED.

But I get this error:

Code: Select all | TOGGLE FULL SIZE
Traceback (most recent call last):
  File "/var/lib/cloud9/examples/blink.py", line 4, in <module>
    GPIO.setup("P8_9", GPIO.IN)
ValueError: Set gpio direction failed, missing file or invalid permissions.

I have tried updating kernel and bootloader according to this issue on github https://github.com/adafruit/adafruit-beaglebone-io-python/issues/248, but that did not solve the problem.

Here is sudo /opt/scripts/tools/version.sh output:
Code: Select all | TOGGLE FULL SIZE
dogtag:[BeagleBoard.org Debian Image 2018-06-17]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2018.03-00002-gac9cce7c6a]:[location: dd MBR]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal i2c bluetooth netdev cloud9ide gpio pwm eqep admin spi tisdk weston-launch xenomai]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet]
dmesg | grep pinctrl-single
[    0.937803] pinctrl-single 44e10800.pinmux: 142 pins, size 568
dmesg | grep gpio-of-helper

Also, i have to mention that there's no problem runing this code:
Code: Select all | TOGGLE FULL SIZE
import Adafruit_BBIO.GPIO as GPIO

GPIO.setup("P8_7", GPIO.OUT)
GPIO.output("P8_7", GPIO.HIGH)

So, there's no problem with LED pins. I tried another button (MODE_BTN) but same error.


Posts: 1
Joined: Sun Jun 24, 2018 8:17 am

Re: BeagleBone Blue: Set gpio direction failed

by drewfustini on Tue Jul 03, 2018 4:28 pm

It would be helpful if you could run strace so that I can better understand what is happening.

Install strace (if it doesn't already exist):
sudo apt-get install strace
Then run strace, replace test.py with the name of your test program:
strace -f -o strace.log python test.py
Paste the contents of strace.log into a GitHub Gist and post the link in a reply here.

Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Please be positive and constructive with your questions and comments.