8

/boot/overlays/README has this text:

    act_led_trigger         Choose which activity the LED tracks.
                            Use "heartbeat" for a nice load indicator.
                            (default "mmc")

But are there other options? If I wanted to create my own (e.g. led constantly on until shutdown), where would I start? Is it recompiling a kernel module, or recompiling the entire kernel?

Lucas Walter
  • 185
  • 1
  • 1
  • 6

5 Answers5

14

I have tried describing the values mentioned.

none                No trigger
kbd-scrolllock      Keyboard scroll lock
kbd-numlock         Keyboard num lock
kbd-capslock        Keyboard caps lock
kbd-kanalock        Keyboard kana lock
kbd-shiftlock       Keyboard shift
kbd-altgrlock       Keyboard altgr
kbd-ctrllock        Keyboard ctrl
kbd-altlock         Keyboard alt
kbd-shiftllock      Keyboard left shift
kbd-shiftrlock      Keyboard right shift
kbd-ctrlllock       Keyboard left ctrl
kbd-ctrlrlock       Keyboard right ctrl
timer               Flash at 1 second intervals
oneshot             Flash only once
heartbeat           Flash like a heartbeat (1-0-1-00000)
backlight           Always on
gpio                Flash when a certain GPIO is high???
cpu0                Flash on cpu0 usage
cpu1                Flash on cpu1 usage
cpu2                Flash on cpu2 usage
cpu3                Flash on cpu3 usage
default-on          Always on
[input]             Default state
panic               Flash on kernel panic
mmc0                Flash on mmc0 (primary SD Card interface) activity
mmc1                Flash on mmc1 (secondary SD Card interface) activity
rfkill0             Flash on wifi activity
rfkill1             Flash on bluetooth activity
Ameer
  • 435
  • 3
  • 11
5

Try any of the values in cat /sys/devices/platform/leds/leds/led0/trigger

Milliways
  • 62,573
  • 32
  • 113
  • 225
3

In this Makefile, you can find all the triggers chosen for a 5.4 kernel.

But I noticed that by cat /sys/devices/platform/leds/leds/led0/trigger, some triggers are not listed (e.g. "pattern" and "activity").

It turned out that they are compiled as kernel modules but not loaded by default. They are located under /lib/modules/[your kernel release]/kernel/drivers/leds/trigger, and you can find out your kernel release by uname -r.

Then you can either manually load the triggers by sudo modprobe ledtrig_xxx or add them to /etc/modules-load.d/xxx.conf to load automatically during boot time.

Finally, try cat /sys/devices/platform/leds/leds/led0/trigger again and play with the triggers :)

Lucian
  • 31
  • 2
1

I've tried and it works:

In /boot/config.txt:

dtparam=pwr_led_trigger=heartbeat

Enjoy.

Greenonline
  • 2,969
  • 5
  • 27
  • 38
MitchFR
  • 11
  • 1
0

Lucian's answer suggesting the Makefile prompted me to look into the related kernel source code.

When /sys/devices/platform/leds/leds/led1/trigger (same for led0) is set to gpio, then the virtual filesystem exposes additional 'files'; I will use gpio 35 to drive the red on-board led ("power led").

$ sudo sh -c "echo 'gpio' > /sys/class/leds/led1/trigger"
$ ls -lA /sys/class/leds/led1/
total 0
-rw-r--r-- 1 root root 4096 Aug  6 10:33 brightness
-rw-r--r-- 1 root root 4096 Aug  6 10:34 desired_brightness
lrwxrwxrwx 1 root root    0 Aug  6 10:33 device -> ../../../leds
-rw-r--r-- 1 root root 4096 Aug  6 10:34 gpio
-rw-r--r-- 1 root root 4096 Aug  6 10:34 inverted
-r--r--r-- 1 root root 4096 Aug  6 10:33 max_brightness
drwxr-xr-x 2 root root    0 Aug  6 10:33 power
lrwxrwxrwx 1 root root    0 Aug  6 10:33 subsystem -> ../../../../../class/leds
-rw-r--r-- 1 root root    0 Aug  6 10:34 trigger
-rw-r--r-- 1 root root 4096 Aug  6 10:33 uevent
$ sudo sh -c "echo '255' > /sys/class/leds/led1/desired_brightness"
$ sudo sh -c "echo '35' > /sys/class/leds/led1/gpio"
$ echo 35 >  /sys/class/gpio/export 
$ echo 'out' > /sys/class/gpio/gpio35/direction 
$ echo '1' > /sys/class/gpio/gpio35/value 
Lucas Walter
  • 185
  • 1
  • 1
  • 6
Al_
  • 11
  • 2