How to set LED state in the BBB U-Boot?

456 views
Skip to first unread message

Nikolay

unread,
Dec 17, 2019, 3:13:47 PM12/17/19
to BeagleBoard

On a custom cape board I have a power button and two LEDs, one red and one blue, connected on P9_12 and P8_11, respectively.  Following the instructions on how to build U-Boot here: https://www.digikey.com/eewiki/display/linuxonarm/BeagleBone+Black#BeagleBoneBlack-Bootloader:U-Boot,  was able to mux both LEDs in the BeagleBone Black configuration am335x_evm_defconfig by including additional initialisation in the U-Boot v2019.04  u-boot/board/ti/am335x/mux.c :

Enter code here...static struct module_pin_mux gpio1_28_pin_mux[] = {
{OFFSET(gpmc_be1n), (MODE(7) | PULLDOWN_EN)}, /* RED LED GPIO60 <= P9_12 */
{-1},
};
static struct module_pin_mux gpio1_13_pin_mux[] = {
{OFFSET(gpmc_ad13), (MODE(7) | PULLDOWN_EN)}, /* BLUE LED GPIO45 <= P8_11 */
{-1},
};

void enable_board_pin_mux(void)
{
configure_module_pin_mux(gpio1_28_pin_mux); /* LED RED ON ? */
configure_module_pin_mux(gpio1_13_pin_mux); /* LED BLUE ON ? */  

/* Do board-specific muxes. */
if (board_is_beaglelogic()) {
/* BeagleLogic pinmux */
. . .
so on power on I can see a dimmed light on both LEDs. The question is how and where I can turn them on during the boot process or even let them blink? I am aware of the U-Boot LED driver and I tried to customise beagle led.c configuration with no luck.  Is there an easy way to set the LEDs state high after the muxing, early during the U-Boot initialisation?

Any help is greatly appreciated!
Nikolay

Robert Nelson

unread,
Dec 17, 2019, 3:53:27 PM12/17/19
to Beagle Board, n.teo...@gmail.com
Hi Nikolay,

Once you "jump" from u-boot to the kernel, anything u-boot set for i/o
will be reinitialized.. To keep the led in the same state as u-boot
early in the kernel initilaion.. take a look at 'gpio-hog'..

Here is a quick example of a pin pulled high as early as possible..

https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-BBGW-WL1835-00A0.dts#L191-L201

If you look at a scope, it'll still "blip", but it's as fast of a
transition as possible..

Regards,

--
Robert Nelson
https://rcn-ee.com/

Robert Nelson

unread,
Dec 17, 2019, 4:56:12 PM12/17/19
to Beagle Board, Nikolay Teofilov
On Tue, Dec 17, 2019 at 3:50 PM Nikolay Teofilov <n.teo...@gmail.com> wrote:
>
> Hi Robert,
>
> Thank you for your prompt reply. If I understood correctly this fragment I have to adapt in my cape overlay to set the LEDs state as early as kernel is being loading? The problem is exactly the transition time between U-Boot phase and the kernel loading, there is noting shown on the display and somehow the user have to be able to get feedback that at least the pressing on the power button is doing something. With custom compiled kernel and one single overlay file I have now about 5 to 7 seconds darkness between the U-Boot and the LCD response. This includes about 3 to 4 s of u-boot of initialising and loading the overlays right before loading kernel. So this will allow the LEDs being on in the early kernel loading transition phase after this 3 initial seconds?

Upgrade your version of u-boot, i nuked the 2 second wait about a month ago.

Using the fdtoverlay utility, you can have u-boot load one *.dtb, thus
bypassing the overlay loading loop..

For example: am335x-boneblack-uboot-univ.dtb +
BB-BONE-eMMC1-01-00A0.dtbo + AM335X-PRU-UIO-00A0.dtbo +
BB-UART2-00A0.dtbo = am335x-boneblack.dtb

fdtoverlay -i am335x-boneblack-uboot-univ.dtb -o am335x-boneblack.dtb
BB-BONE-eMMC1-01-00A0.dtbo AM335X-PRU-UIO-00A0.dtbo BB-UART2-00A0.dtbo

so that would cut down on a few seconds..
Reply all
Reply to author
Forward
Message has been deleted
0 new messages