Change the behavior of LEDs during bootup

Hi :slight_smile:

Is there a way to change the default behavior of LEDs during bootup, before the leds init script is started? Or is this determined by the hardware in a hard-coded manner?

Cheers, Tobias

1 Like

Early LED behavior is governed by the pre-init process.

root@OpenWrt:~# find /lib/preinit/
/lib/preinit/
/lib/preinit/00_preinit.conf
/lib/preinit/02_default_set_state
/lib/preinit/02_sysinfo
/lib/preinit/05_set_iface_mac_ipq40xx.sh
/lib/preinit/06_set_preinit_iface_ipq40xx.sh
/lib/preinit/10_indicate_failsafe
/lib/preinit/10_indicate_preinit
/lib/preinit/30_failsafe_wait
/lib/preinit/40_run_failsafe_hook
/lib/preinit/50_indicate_regular_preinit
/lib/preinit/70_initramfs_test
/lib/preinit/80_mount_root
/lib/preinit/81_urandom_seed
/lib/preinit/99_10_failsafe_login
/lib/preinit/99_10_run_init

The specific LED chosen, at least for DTS-based targets, is set in the DTS

        aliases {
                led-boot = &led_wps_amber;
                led-failsafe = &led_wps;
                led-running = &led_linksys;
                led-upgrade = &led_world;

(No doubt "The Powers That Be" will object to my naming, but this at least shows the aliases needed.)

Hmmm … I don't have an "aliases" definition in any of my /lib/preinit/* scripts … /etc/diag.sh is sourced, which contains definitions of a "status led", but the long list doesn't contain my board name (gl-ar150), so I think some default value is used.

Can you tell me where the first status led action is triggered? These scripts are a bit confusing :wink:

Yeah, they are. I walked through them some time ago and, as I recall, they register functions to be executed at various points in the boot process. I haven't looked at it in a while, but last I did, I edited https://openwrt.org/docs/techref/preinit_mount#overview with some hopefully useful information.

That "aliases" definition is in the DTS (Device Tree Source) and is loaded with the kernel in a compiled form. it isn't a "script" but more of a hardware definition; "If asking for the led-boot, twiddle GPIO 23, active low" or the like.

This is not as easy as I thought :wink: I'll see what I find. Thanks for the info!

2 Likes