How to control LEDs on All Libre Computer Boards

Libre Computer boards usually have 3 or 4 LEDs on board for various status indication. We like to arrange LEDs from the edge of the board to the center of the board in the following sequence:

  • Red - Power
  • Yellow - Status
  • Green - Status
  • Blue - Activity

Some boards differ from this sequence depending on the availability of GPIOs to control LEDs. Some LEDs are hard wired to power while others are GPIO controlled.

For the GPIO controlled LEDs, Linux exposes the /sys/class/leds VFS directory. We usually name the LEDs based on the color. Within the directory for the LED, there are two files of relevance:

  • brightness
  • trigger

For GPIO controlled LEDs, brightness is a virtual file that contains 0 or 1 indicating whether that LED is on or off. To control the LED, write to the virtual file via echo 0 | sudo tee brightness. This will turn off the LED.

The trigger file allows a subsystem in the Linux kernel to output on the specific LEDs. The available trigger options is determined by the Linux kernel config but you will typically have a large list to choose from.

$ cat trigger 
[none] usb-gadget usb-host kbd-scrolllock kbd-numlock kbd-capslock kbd-kanalock kbd-shiftlock kbd-altgrlock kbd-ctrllock kbd-altlock kbd-shiftllock kbd-shiftrlock kbd-ctrlllock kbd-ctrlrlock timer disk-activity disk-read disk-write ide-disk mtd nand-disk heartbeat cpu cpu0 cpu1 cpu2 cpu3 activity default-on panic mmc0 mmc1 rfkill-any rfkill-none mdio_mux-0.1:08:link mdio_mux-0.1:08:100Mbps mdio_mux-0.1:08:10Mbps rc-feedback

You can link any trigger to the LED by echoing the trigger name into the file: echo activity | sudo tee trigger. A few standard triggers and their description are below:

  • disk-activity # flashes when sdX and nvmeX devices are being read/written
  • heartbeat # double flashes every second to indicate that the system has not locked
  • activity # flashes when there is general system activity

You can find more information about different triggers in the Linux kernel documentation.