BeagleBone Black Built-In LEDs

BeagleBone Black Built-In LEDs

About each LED

There are four user LEDs on the BeagleBone. You can modify them, but they each have their own purposes by default. USER0 is the closest to the top in the picture at the right, and USER3 is the bottom one closest to the ethernet port.

 

  • USER0 is the heartbeat indicator from the Linux kernel.
  • USER1 turns on when the SD card is being accessed
  • USER2 is an activity indicator. It turns on when the kernel is not in the idle loop.
  • USER3 turns on when the onboard eMMC is being accessed.

You can change each of the LED's behaviors at the following locations:

/sys/class/leds/beaglebone\:green\:usr0/
/sys/class/leds/beaglebone\:green\:usr1/
/sys/class/leds/beaglebone\:green\:usr2/
/sys/class/leds/beaglebone\:green\:usr3/

Yeah, the LEDs are blue, but the folder is called green for some reason. Also, those colons make BASH freak out a bit, so pay attention to escape them.

If you explore those directories, things start to get interesting.

First, any write operatoins will require root privileges. The use of IO redirection will require that you be the root account, not just use sudo. This is only really applicable if you are not using Angstrom, where the root account is the default account.

root@beaglebone:~# cd /sys/class/leds/beaglebone\:green\:usr0/
root@beaglebone:/sys/class/leds/beaglebone:green:usr0# ls -l 
total 0 -rw-r--r-- 1 root root 4096 Jan 1 00:08 brightness lrwxrwxrwx 1 root root 0 Jan 1 00:08 device -> ../../../gpio-leds.8 -r--r--r-- 1 root root 4096 Jan 1 00:08 max_brightness drwxr-xr-x 2 root root 0 Jan 1 00:08 power lrwxrwxrwx 1 root root 0 Jan 1 00:08 subsystem -> ../../../../../class/leds -rw-r--r-- 1 root root 4096 Jan 1 00:08 trigger -rw-r--r-- 1 root root 4096 Jan 1 00:00 uevent

root@beaglebone:/sys/class/leds/beaglebone:green:usr0# cat trigger
none nand-disk mmc0 mmc1 timer oneshot [heartbeat] backlight gpio cpu0 default-on transient

You can see that USER0 is in hearbeat trigger mode. I find that heartbeat to be annoying (it's so bright!). Let's get rid of it

Take Over a USER LED

You can change what LED blinks to indicate by changing the trigger. For example, GPIO would indicate GPIO activity.

In order to change these, you will need to become root by either using sudo bash or sudo su

Sudo alone will not help because of the I/O redirection used in these commands. You could do sudo nano trigger instead.

root@beaglebone:/sys/class/leds/beaglebone:green:usr0# echo none > trigger
root@beaglebone:/sys/class/leds/beaglebone:green:usr0# cat trigger
[none] nand-disk mmc0 mmc1 timer oneshot heartbeat backlight gpio cpu0 default-on transient
root@beaglebone:/sys/class/leds/beaglebone:green:usr0# echo 0 > brightness

Blinking a USER LED

Just a simple BASH loop:

while true; do echo 255 > brightness ; sleep 1; echo 0 > brightness; sleep 1; done;

OR you can use the timer built-in trigger

echo timer > trigger
echo 500 > delay_off
echo 50 > delay_on

You can even use it as a sort of PWM to dim the LED. There should be another way to do this, but this is all I've found.

echo timer > trigger
echo 1 > delay_on
echo 12 > delay_off

Interestingly, I think this should behave similar to the heartbeat. If the system crashes it would turn on or off completely.

Evan Boldt Sat, 06/01/2013 - 17:46