-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing support for USR% leds on BBB #96
Comments
i also just have begun to play with Blinka and related on a PocketBeagle - and can you test the example directly from an ssh-comandline? also - from the cmd you can try if you need to run the example as root - you also can try to use the Adafruit Beaglebone I/O Python API
PS: by the way - try to use code-block-formatting - that would be easier to read.. |
@hulkco thanks for raising this issue. Please paste the output of this script: The error you encountered:
can be ambiguous as to the root cause. When such an error occurs, running Python with strace will show the system calls that occurred and is useful to determining the exact path of the directory or file that is causing the error. I will try to reproduce the issue you encountered and report back. |
Adafruit_Blinka is using Adafruit_BBIO as the backend as @s-light mentioned. For reference, the Linux kernel has a LED subsystem which is different than the GPIO subsystem. Therefore, the built-in LED devices show up under This requires a special case in Adafruit_BBIO to handle the built-in LEDs:
Adafruit_Blinka should inherit this logic from Adafruit_BBIO. I'll test the USR LEDs too and report with my findings. |
I hope this helps. The source code is: import board
import digitalio
import busio
import time
#led = digitalio.DigitalInOut(board.LED_USR0)
led = digitalio.DigitalInOut(board.LED_USR1)
led.direction = digitalio.Direction.OUTPUT
while True:
led.value = True
time.sleep(0.5)
led.value = False
time.sleep(0.5) The output using trace is: $ sudo python3 -mtrace --trace led_test.py | egrep '^(digitalio.py)'
digitalio.py(8): """
digitalio.py(10): from adafruit_blinka.agnostic import board_id, detector
digitalio.py(16): elif detector.chip.AM33XX:
digitalio.py(17): from adafruit_blinka.microcontroller.am335x.pin import Pin
digitalio.py(32): class DriveMode(Enum):
digitalio.py(33): PUSH_PULL = None
digitalio.py(34): OPEN_DRAIN = None
digitalio.py(37): DriveMode.PUSH_PULL = DriveMode()
digitalio.py(38): DriveMode.OPEN_DRAIN = DriveMode()
digitalio.py(41): class Direction(Enum):
digitalio.py(41): class Direction(Enum):
digitalio.py(42): INPUT = None
digitalio.py(43): OUTPUT = None
digitalio.py(46): Direction.INPUT = Direction()
digitalio.py(47): Direction.OUTPUT = Direction()
digitalio.py(50): class Pull(Enum):
digitalio.py(50): class Pull(Enum):
digitalio.py(51): UP = None
digitalio.py(52): DOWN = None
digitalio.py(56): Pull.UP = Pull()
digitalio.py(57): Pull.DOWN = Pull()
digitalio.py(62): class DigitalInOut(ContextManaged):
digitalio.py(62): class DigitalInOut(ContextManaged):
digitalio.py(63): _pin = None
digitalio.py(65): def __init__(self, pin):
digitalio.py(69): def switch_to_output(self, value=False, drive_mode=DriveMode.PUSH_PULL):
digitalio.py(74): def switch_to_input(self, pull=None):
digitalio.py(78): def deinit(self):
digitalio.py(81): @property
digitalio.py(85): @direction.setter
digitalio.py(98): @property
digitalio.py(102): @value.setter
digitalio.py(109): @property
digitalio.py(116): @pull.setter
digitalio.py(135): @property
digitalio.py(142): @drive_mode.setter
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/lib/python3.5/trace.py", line 856, in <module>
main()
File "/usr/lib/python3.5/trace.py", line 802, in main
t.runctx(code, globs, globs)
File "/usr/lib/python3.5/trace.py", line 508, in runctx
exec(cmd, globals, locals)
File "led_test.py", line 7, in <module>
led = digitalio.DigitalInOut(board.LED_USR1)
File "/usr/local/lib/python3.5/dist-packages/digitalio.py", line 67, in __init__
self.direction = Direction.INPUT
File "/usr/local/lib/python3.5/dist-packages/digitalio.py", line 93, in direction
self._pin.init(mode=Pin.IN)
File "/usr/local/lib/python3.5/dist-packages/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.
digitalio.py(66): self._pin = Pin(pin.id)
digitalio.py(67): self.direction = Direction.INPUT
digitalio.py(87): self.__direction = dir
digitalio.py(88): if dir is Direction.OUTPUT:
digitalio.py(92): elif dir is Direction.INPUT:
digitalio.py(93): self._pin.init(mode=Pin.IN) |
@hulkco thanks, I able to reproduce the issue:
from the strace output:
there is this line:
The issue is that is the wrong path for the USR LED. I have to investigate why this is handled differently than in Adafruit_BBIO directly. |
For comparision, in Adafruit_BBIO:
|
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:
This now works:
strace shows that the correct path is being used:
I'll investigate further the root cause in Adafruit_BBIO |
I can reproduce the behavior directly in Adafruit_BBIO by calling
results in error:
and strace shows the bad path:
|
This fix resolves Adafruit_BBIO issue #310 and adafruit/Adafruit_Blinka#96 which was preventing the USR LEDs from being used by the CircuitPython Blinka library
This issue should now be resolved by the fix in Adafruit_BBIO for: This example now runs OK and blinks USR0:
|
@hulkco please install the current |
amazing, thanks @pdp7 |
@hulkco have you had a chance to try the current master branch of Adafruit_BBIO and see if you can now blink USR LEDs with Blinka? If so, I will create a new release of Adafruit_BBIO and publish to PyPI and then close this issue. |
Ready @pdp7 , all the LEDs work, i close the issue, thanks dude!!! |
Hi, I'm testing Blinka on a BBB, and I have this problem when trying to use User Leds
Thank you for your attention
The text was updated successfully, but these errors were encountered: