Troubles when adding a LED to Device Tree

Hi. First of all, thanks in advance for those who try to help me.

I’m studying about Device Trees, and I’ve chosen to use Beaglebone Green Wireless as a board to practice.
I’ve done the following steps:

  1. From u-boot serial, I’ve seen that Beaglebone green Wireless is using uses am335x-bonegreen-wireless-uboot-univ.dtb as DTB file
  2. Cloned / downloaded beaglebone Kernel (from
  3. I want to add LED at GPIO 47 ( = GPIO1_16, and accordingly to board schematic, AM33xx GPMC_A0 pin). I’ve edited am335x-bone-common.dtsi file, adding led (led6) in leds node as follows:


leds {
pinctrl-names = “default”;
pinctrl-0 = <&user_leds_s0>;
compatible = “gpio-leds”;
led2 {
label = “beaglebone:green:usr0”;
gpios = <&gpio1 21 GPIO_ACTIVE_HIGH>;
linux,default-trigger = “heartbeat”;
default-state = “off”;
led3 {
label = “beaglebone:green:usr1”;
gpios = <&gpio1 22 GPIO_ACTIVE_HIGH>;
linux,default-trigger = “mmc0”;
default-state = “off”;
led4 {
label = “beaglebone:green:usr2”;
gpios = <&gpio1 23 GPIO_ACTIVE_HIGH>;
linux,default-trigger = “cpu0”;
default-state = “off”;
led5 {
label = “beaglebone:green:usr3”;
gpios = <&gpio1 24 GPIO_ACTIVE_HIGH>;
linux,default-trigger = “mmc1”;
default-state = “off”;

led6 {
label = “beaglebone:green:extLed”;
gpios = <&gpio1 16 GPIO_ACTIVE_HIGH>;
linux,default-trigger = “heartbeat”;
default-state = “off”;



And I’ve added gpio2_16 in pinmux of user leds, as follows:


&am33xx_pinmux {
user_leds_s0: user_leds_s0 {
pinctrl-single,pins = <
gpmc_a6.gpio1_22 /
gpmc_a7.gpio1_23 /
gpmc_a8.gpio1_24 /
gpmc_a0.gpio1_16 */



  1. I’ve successfully compiled all dtbs by doing:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- dtbs


  1. After that, I’ve updated the recently compiled am335x-bonegreen-wireless-uboot-univ.dtb file to /boot/dtbs/{uname-r} folder in Beaglebone Green

  2. And, finally, I rebooted the board. However, board has entered in a “strange state”, with all user leds powered on. Using U-Boot serial, I’ve noticed that boot process have stopped at “starting kernel” message

In this case, what have I done wrong? Are my modifications in DTS file right?

Again, thanks in advance.


Forget about all that device tree trouble, use libpruio instead. You can configure the pin and set the desired output state by a single function call in your programm running at user space (no sudo commands, no rebooting, …)

gpio_setValue(Io, P9_15, 1) // configure and set high

gpio_setValue(Io, P9_15, 0) // set low

You’ll have faster boot, less memory consumption, and your code executes much faster (compared with sysfs GPIO control).

You may want to check out some examples.


Your steps look right, but there is a simpler way to do them. Check out:

No need to cross compile etc.



I’ve never heard about libpruio before. It seems to be very nice and fast, once it uses PRUs for writing and reading I/Os, per my understanding. Thanks for the suggestion.

Best Regards,
Pedro Bertoleti

Hi Mark. Great, thanks!

Per my understanding, the Device Tree approach of doesn’t include modifying user_leds_s0 (pinmux for user leds). Do you know why isn’t this needed?

Best Regards,
Pedro Bertoleti

I think I got lucky and the mux was already set to gpio.