Default LED settings?

How do I change the default LEDs that light up when my device boots? At the moment my router uses four LEDs, WLAN, Signal Strength, Power, and LAN, but I'd like to reduce that to just Power and LAN. I don't use WIFI on this device so the other two should be switched off by default. I think I could just write a little script and have it run after boot with crontab but it feels better to me to make the change at the source, to stop them coming on in the first place so to speak.

Later on (when I get WireGuard working--if that ever happens haha) I want to use the LEDs to show when the WireGuard connection is up and when its down. Where would I add the script to do that?

I just flashed my device to 19.07.4 and haven't made any changes yet so this is a 'stock' install.

Ciao!

You forgot to tell us, which device you are talking about...

The answer depends on that, as in some routers all LED config is found in /etc/config /system, while in some routers some LEDs are controller directly by some driver, like e.g. the ath10k wifi driver can control directly the wifi LEDs in some ipq806x routers and there is no wifi LED config provided in OpenWrt.

Usually the LED devices are defined in the DTS file of each router, and those provide the visible led devices for Linux. And those devices files can be manipulated by scripts for LED control. See the contents of /sys/class/leds.

Examples:


root@router1:~# ls /sys/class/leds/
ath10k-phy0        r7800:amber:power  r7800:white:esata  r7800:white:usb1   r7800:white:wan    r7800:white:wps
ath10k-phy1        r7800:amber:wan    r7800:white:power  r7800:white:usb2   r7800:white:wifi

root@router1:~# ls /sys/class/leds/r7800\:amber\:wan/
brightness      device          max_brightness  subsystem       trigger         uevent

root@router1:~# cat /sys/class/leds/r7800\:amber\:wan/trigger
[none] switch0 timer disk-activity disk-read disk-write ide-disk default-on netdev heartbeat usbport phy0rx phy0tx phy0assoc phy0radio phy0tpt phy1rx phy1tx phy1assoc phy1radio phy1tpt
root@router1:~# cat /sys/class/leds/r7800\:white\:wan/trigger
none [switch0] timer disk-activity disk-read disk-write ide-disk default-on netdev heartbeat usbport phy0rx phy0tx phy0assoc phy0radio phy0tpt phy1rx phy1tx phy1assoc phy1radio phy1tpt

root@router1:~# cat /sys/class/leds/r7800\:white\:wan/brightness
255

Turn the LED "off" (0) and then back "on" (255).

root@router1:~# echo 0 > /sys/class/leds/r7800\:white\:wan/brightness
root@router1:~# echo 255 > /sys/class/leds/r7800\:white\:wan/brightness

And the relevant DTS for R7800. The names and wiring of the LEDs are defined there:

And based on those DTS definitons, the LED config for OpenWrt is specifed in

1 Like

Have you looked in:

LuCI > System > LED Configuration

You may be able to 'delete' any entries you find for LEDs you wish to permanently turn off.

2 Likes

That's some really good information, thanks for that! When I have more
time I'll look into this again, I think it would be a useful feature. If
I get it to work (when! Be positive!) I'll post the solution to the
forum - share and share alike!

Ciao!