User LED forward to GPIO

Hello!

Can I forward the User Led to the GPIO?
I want to build my own Expansion Board and need this LED.

OR is this function already connectet to some GPIO?

Thank you!

Hello!

Can I forward the User Led to the GPIO?
I want to build my own Expansion Board and need this LED.

OR is this function already connectet to some GPIO?

Thank you!

You can change the GPIO for the User LED by modifying the BBB device tree.
Look at arch/arm/boot/dts/am335x-bone-common.dtsi

Regards,
John

Hello John!

Thank you!
I`m using Debian and also the universal device tree from Charles: https://github.com/cdsteinkuehler/beaglebone-universal-io

Not sure if its there also available? I doesnt find an information about heartbeat and cpu for user led on the GPIO.

Thank you!

The way these systems are configured, I don't know if you can do what
you want without generating a custom device tree.

The leds class has a trigger function and can be tied to various GPIO
pins, but I believe that conflicts with exporting that same GPIO pin.

If anyone knows of a way to do this without requiring customizing a
device tree to move GPIO pins from /sys/class/gpio to /sys/class/leds/
entries, or if there's a way to have both for the same pin, I'd love to
hear it!

The way these systems are configured, I don't know if you can do what
you want without generating a custom device tree.

The leds class has a trigger function and can be tied to various GPIO
pins, but I believe that conflicts with exporting that same GPIO pin.

If anyone knows of a way to do this without requiring customizing a
device tree to move GPIO pins from /sys/class/gpio to /sys/class/leds/
entries, or if there's a way to have both for the same pin, I'd love to
hear it!

Without the benefit of a DT overlay, I think you are stuck with generating
a customized DT. Rather than modifying the existing DT files, perhaps it
would be better to update am335x-boneblack.dts to include a custom DTS
like this:

‹

/include/ ³am33xs.dtsi²
/include/ ³am335x-bone-common.dtsi²
/include/ ³am335x-custom.dtsi²

&am33xx_pinmux {
etc
‹

Now am335x-custom.dtsi can be used to override any previous DT settings.
It would also be possible to add various cape DT to am335x-custom.dtsi.
Unfortunately DTC cannot detect conflicts and these will only be detected
when the kernel boots.

Regards,
John

Hello John!

Maybe Charles unterstud what you mean.

Unfortunately I’m not an expert of DT. So maybe you can explain how I can use GPIO as usrLED?

In the am335x-boneblack.dts are GPIO 21 - 24 for usr0 - usr3. But don know if they are activ and available.
Cannot find these GPIO!

Thank you!

faimbs

Hello John!

Maybe Charles unterstud what you mean.

Unfortunately I’m not an expert of DT. So maybe you can explain how I can use GPIO as usrLED?

In the am335x-boneblack.dts are GPIO 21 - 24 for usr0 - usr3. But don know if they are activ and available.
Cannot find these GPIO!

I recommend that you always retain the previous responses as I don’t recall what your original questions was. Anyway, in arch/arm/boot/dts/am335x-bone-common.dtsi, on line 30 you will find the pins used for the LEDs. If you want to move the LEDs to a different GPIO, then this is where you make that change.

Regards,
John

Hi,

on a 3.14 kernel I copied am335x-boneblack.dts and made my own: am335x-boneblack-res-1.dts

to this I added:

/* → define custom leds pinmux /
&am33xx_pinmux {
traffic_leds_s0: traffic_leds_s0 {
pinctrl-single,pins = <
0x78 (PIN_OUTPUT_PULLDOWN | MUX_MODE7) /
.gpio1_28, P9_12 60 $PIN: 30 OUTPUT MODE7 - traffic-1 LED /
0x44 (PIN_OUTPUT_PULLDOWN | MUX_MODE7) /
.gpio1_17, P9_23 49 $PIN: 17 OUTPUT MODE7 - traffic-2 LED /
0x1A4 (PIN_OUTPUT_PULLDOWN | MUX_MODE7) /
.gpio3_19, P9_27 115 $PIN: 105 OUTPUT MODE7 - traffic-3 LED /
0x34 (PIN_OUTPUT_PULLDOWN | MUX_MODE7) /
.gpio1_13, P8_11 45 $PIN: 13 OUTPUT MODE7 - traffic-4 LED /
0x30 (PIN_OUTPUT_PULLDOWN | MUX_MODE7) /
.gpio1_12, P8_12 44 $PIN: 12 OUTPUT MODE7 - traffic-5 LED /
0x28 (PIN_OUTPUT_PULLDOWN | MUX_MODE7) /
.gpio0_26, P8_14 26 $PIN: 10 OUTPUT MODE7 - traffic-6 LED /
0x3c (PIN_OUTPUT_PULLDOWN | MUX_MODE7) /
.gpio1_15, P8_15 47 $PIN 15 OUTPUT MODE7 - traffic-7 LED */

;
};

};
/* ← define custom leds pinmux */

and

/* → define custom leds */

gpio_leds {
pinctrl-names = “default”;
pinctrl-0 = <&traffic_leds_s0>;

compatible = “gpio-leds”;

led@1 {
label = “trfcl1:red”;
gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
linux,default-trigger = “heartbeat”;
default-state = “on”;
};

led@2 {
label = “trfcl1:amber”;
gpios = <&gpio1 17 GPIO_ACTIVE_HIGH>;
linux,default-trigger = “heartbeat”;
default-state = “on”;
};

led@3 {
label = “trfcl1:green”;
gpios = <&gpio3 19 GPIO_ACTIVE_HIGH>;
linux,default-trigger = “heartbeat”;
default-state = “on”;
};

led@4 {
label = “trfcl2:red”;
gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>;
linux,default-trigger = “heartbeat”;
default-state = “on”;
};

led@5 {
label = “trfcl2:amber”;
gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
linux,default-trigger = “heartbeat”;
default-state = “on”;
};
led@6 {
label = “trfcl2:green”;
gpios = <&gpio0 26 GPIO_ACTIVE_HIGH>;
linux,default-trigger = “heartbeat”;
default-state = “on”;
};

led@7 {
label = “trfcl3:red”;
gpios = <&gpio1 15 GPIO_ACTIVE_HIGH>;
linux,default-trigger = “heartbeat”;
default-state = “on”;
};

};

/* ← define custom leds */

Then you need to build this new flat device tree and load it to your board.

Hope this helps,

Robert

I use this: https://github.com/nomel/beaglebone/tree/master/led-header

Makes setting up leds super easy.

I use this: https://github.com/nomel/beaglebone/tree/master/led-header

Makes setting up leds super easy.

Just so you know, this will only work for Kernel V3.8

Regards,
John

Hello faimbs,

the USER LEDs are allready connected to GPIO-1, pins 21 to 24. By default these pins are configured as outputs.

An easy (and fast) alternative to control USER LEDs is libpruio. No need for file access to control the status, just call a function to switch the LED on or off. Find the example sos.c in the package that makes the USER LED-3 blinking in SOS code: