question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing support for USR% leds on BBB

See original GitHub issue

Hi, I’m testing Blinka on a BBB, and I have this problem when trying to use User Leds

debian@beaglebone:/var/lib/cloud9/python$ sudo python3 blinka_blink.py
hello blinky!
Traceback (most recent call last):
  File "blinka_blink.py", line 9, in <module>
    led = digitalio.DigitalInOut(board.LED_USR1)
  File "/usr/local/lib/python3.5/dist-packages/Adafruit_Blinka-1.2.7.dev3+g5d33134-py3.5.egg/digitalio.py", line 67, in __init__
    self.direction = Direction.INPUT
  File "/usr/local/lib/python3.5/dist-packages/Adafruit_Blinka-1.2.7.dev3+g5d33134-py3.5.egg/digitalio.py", line 93, in direction
    self._pin.init(mode=Pin.IN)
  File "/usr/local/lib/python3.5/dist-packages/Adafruit_Blinka-1.2.7.dev3+g5d33134-py3.5.egg/adafruit_blinka/microcontroller/am335x/pin.py", line 30, in init
    GPIO.setup(self.id, GPIO.IN)
ValueError: Set gpio mode failed, missing file or invalid permissions.

Thank you for your attention

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
pdp7commented, Apr 1, 2019

I can reproduce the behavior directly in Adafruit_BBIO by calling GPIO.setup("USR1", GPIO.IN) instead of GPIO.setup("USR1", GPIO.OUT)

import Adafruit_BBIO.GPIO as GPIO
GPIO.setup("USR1", GPIO.IN)

results in error:

Traceback (most recent call last):
  File "/home/debian/test-usr.py", line 2, in <module>
    GPIO.setup("USR1", GPIO.IN)
ValueError: Set gpio mode failed, missing file or invalid permissions.

and strace shows the bad path:

open("/sys/devices/platform/ocp/ocp:USR01_pinmux/state", O_WRONLY|O_CREAT|O_TRUNC, 0666) = -1 ENOENT (No such file or directory)
1reaction
pdp7commented, Apr 1, 2019

I believe this behavior is due to a bug in Adafruit_BBIO where USRn LED is setup initially in INPUT mode instead of OUTPUT mode.

I hard coded the pin to be an output to test:

diff --git a/src/adafruit_blinka/microcontroller/am335x/pin.py b/src/adafruit_blinka/microcontroller/am335x/pin.py
index 71715e6..0455454 100644
--- a/src/adafruit_blinka/microcontroller/am335x/pin.py
+++ b/src/adafruit_blinka/microcontroller/am335x/pin.py
@@ -24,12 +24,17 @@ class Pin:
         return self.id == other
 
     def init(self, mode=IN, pull=None):
+        print("am335x: init(): self.id {0}".format(self.id))
+        # HARD CODE TO OUTPUT
+        mode = self.OUT
         if mode != None:
             if mode == self.IN:
+                print("am335x: self.IN: self.id {0}".format(self.id))
                 self._mode = self.IN
                 GPIO.setup(self.id, GPIO.IN)
             elif mode == self.OUT:
                 self._mode = self.OUT
+                print("am335x: self.OUT: self.id {0}".format(self.id))
                 GPIO.setup(self.id, GPIO.OUT)
             else:
                 raise RuntimeError("Invalid mode for pin: %s" % self.id)

This now works:

led = digitalio.DigitalInOut(board.LED_USR0)

strace shows that the correct path is being used:

access("/sys/class/leds/beaglebone:green:usr0/brightness", W_OK) = 0
open("/sys/class/leds/beaglebone:green:usr0/brightness", O_WRONLY) = 4

I’ll investigate further the root cause in Adafruit_BBIO

Read more comments on GitHub >

github_iconTop Results From Across the Web

No user activity LEDS after upgrade - BeagleBoard.org
After reboot the 4 user leds turn off permanently early in the boot process. I looked some based on what I found online...
Read more >
Can't control LEDs on BBB from terminal - Google Groups
As I recall, you can't use I/O redirection with sudo. The "> brightness" accesses the file using your regular user account. What group...
Read more >
User LEDs on the BeagleBone Black Rev. C - DigiKey Forum
I was wondering if it was possible to mimic the user LED's on the BBB ... i would like to do. any help...
Read more >
Beaglebone: Controlling the on-board LEDs using C++
In this short post I am going to look at how you can change the behaviour of the Beaglebone on-board LEDs – the...
Read more >
Brightology | Reviews | Better Business Bureau® Profile
I bought 24 lights all exposed to full bright sun of Miami. They work for 1 hour and die I left 5 messages...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found