Skip to content
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

Cannot Control LED - Causes Crash #59

Closed
lswee opened this issue Aug 4, 2023 · 5 comments · Fixed by #61
Closed

Cannot Control LED - Causes Crash #59

lswee opened this issue Aug 4, 2023 · 5 comments · Fixed by #61

Comments

@lswee
Copy link

lswee commented Aug 4, 2023

I'm using Model: Raspberry Pi 3 Model B Rev 1.2

There are no LEDs listed under /sys/class/leds/, so I get:

echo 0 | sudo tee /sys/class/leds/led0/brightness > /dev/null
tee: /sys/class/leds/led0/brightness: No such file or directory

When trying to run setup the remapper.service fails:

Synchronizing state of bluetooth.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable bluetooth
Created symlink /etc/systemd/system/dbus-org.bluez.service → /lib/systemd/system/bluetooth.service.
Created symlink /etc/systemd/system/bluetooth.target.wants/bluetooth.service → /lib/systemd/system/bluetooth.service.
Job for remapper.service failed because the control process exited with error code.
See "systemctl status remapper.service" and "journalctl -xe" for details.

If I check the service, I can see it's due to the inability to control the LED:

systemctl status remapper.service
● remapper.service - Remapper
     Loaded: loaded (/lib/systemd/system/remapper.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Fri 2023-08-04 13:16:11 BST; 4min 19s ago
    Process: 690 ExecStart=/usr/bin/python3 /home/pi/bthidhub/remapper.py (code=killed, signal=TERM)
    Process: 691 ExecStartPost=/usr/bin/bash -c echo none > /sys/class/leds/led0/trigger (code=exited, status=1/FAILURE)
    Process: 693 ExecStopPost=/usr/bin/bash -c echo heartbeat > /sys/class/leds/led0/trigger (code=exited, status=1/FAILURE)
   Main PID: 690 (code=killed, signal=TERM)
        CPU: 38ms

Aug 04 13:16:11 bthidhub systemd[1]: Starting Remapper...
Aug 04 13:16:11 bthidhub bash[691]: /usr/bin/bash: line 1: /sys/class/leds/led0/trigger: No such file or directory
Aug 04 13:16:11 bthidhub systemd[1]: remapper.service: Control process exited, code=exited, status=1/FAILURE
Aug 04 13:16:11 bthidhub bash[693]: /usr/bin/bash: line 1: /sys/class/leds/led0/trigger: No such file or directory
Aug 04 13:16:11 bthidhub systemd[1]: remapper.service: Control process exited, code=exited, status=1/FAILURE
Aug 04 13:16:11 bthidhub systemd[1]: remapper.service: Failed with result 'exit-code'.
Aug 04 13:16:11 bthidhub systemd[1]: Failed to start Remapper.

It seems like it's a known problem and there's a different way to turn off the LED?
https://overflow.hostux.net/questions/19863723/turn-off-leds-of-raspberry-pi#71492090
https://github.com/seamusdemora/PiFormulae/blob/master/LEDControlForRPi.md

I believe it can be controlled via ACT:

sudo find /sys/devices -name '*trigger*'
/sys/devices/platform/leds/leds/ACT/trigger
/sys/devices/platform/leds/leds/PWR/trigger
/sys/devices/virtual/leds/default-on/trigger
/sys/devices/virtual/leds/mmc0/trigger

It would be good if the LED thing was optional, I don't think it should crash the whole thing if it fails.

Update

For now I removed two lines from

ExecStartPost=/usr/bin/bash -c 'echo none > /sys/class/leds/led0/trigger'

ExecStartPost=/usr/bin/bash -c 'echo none > /sys/class/leds/led0/trigger' ExecStopPost=/usr/bin/bash -c 'echo heartbeat > /sys/class/leds/led0/trigger'

Which allowed it to run, although I'm now getting this issue:
#55

@Dreamsorcerer
Copy link
Collaborator

Yep, sounds like a reasonable change. If you'd like to make a PR and test it on your device, we can merge that.

@lswee
Copy link
Author

lswee commented Aug 6, 2023

What would you prefer me to do:
simply remove the lines, disable the LED thing, and remove mention to it in the guide
find a way for it to fail silently, but not crash the system
find another way to control the LED that works on more Pi's?

@Dreamsorcerer
Copy link
Collaborator

I'd like to keep the LED function, but silently failing would be fine. If you think it's easy enough to add support for other devices, then it would be nice to get that included.

@xiezhensheng
Copy link

xiezhensheng commented Aug 6, 2023

I think the issue here is that in the latest PI os lite (Bullseye), the name of the "LED0" changes to "ACT". So need to change all the LED0 in the script to ACT to fix the issue.

@Dreamsorcerer
Copy link
Collaborator

If it's a different Raspbian image (different version of Debian), then I'll be looking to update the project to use the latest version soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants