Control user LEDs on Android


According to the DragonBoard’s hardware manual, two user LEDs are connected to APG GPIO 21 and APG GPIO 120, the other two are connected to PM PGIO 1 and PM GPIO 2.

How to I control them from user space, preferably through the same sysfs as documented in “GPIO Usage on Low Speed Connector Application Note”?

I tried to do:

  cd /sys/class/gpio
  export PIN=$((21 + 902))
  echo $PIN > export   # this failed

dmesg said:

  [69040.431307] _gpio_request: gpio-923 (sysfs) status -16
  [69040.431314] export_store: status -16

Apparently, these GPIO pins are not registered to the sysfs.

Never mind, I found my answer. The apq8016-sbc.dtsi file declared the LEDs and these pins are controlled by led sybsystem instead of general gpio class.

For the interested readers:

  cd /sys/class/leds
  cd led1
  echo 1 > brightness  # turn on led 1
  echo 0 > brightness  # turn off