Pmbootstrap: Indicate initramfs status with LED

Created on 14 Jun 2017  路  11Comments  路  Source: postmarketOS/pmbootstrap

Idea from @MartijnBraam, who said, that Jolla also uses the LED for initramfs status.

For the led you need to glob through the /sys/class/led directories looking for one with RGB support

enhancement initramfs

All 11 comments

Maybe create some small C executable to abstract away the status led?

On amami, I couldn't find anything with RGB support, there are directories for every supported color:

/sys/class/leds/led:rgb_blue/
/sys/class/leds/led:rgb_green/
/sys/class/leds/led:rgb_red/

Maybe the led path should be added to the deviceinfo as an array since there isn't realy a naming standard for RGB leds (But they are working on a RGB led interface: https://patchwork.kernel.org/patch/8470681/).

# amami
deviceinfo_status_led  = "
/sys/class/leds/led:rgb_red
/sys/class/leds/led:rgb_green
/sys/class/leds/led:rgb_blue
"

# n900
deviceinfo_status_led  = "
/sys/class/leds/lp5523:r
/sys/class/leds/lp5523:g
/sys/class/leds/lp5523:b
"

I don't think the python code can handle multiline arrays just yet in deviceinfo files (but we could add that).

Anyway, how about storing the names of the LED files, assuming, that they are all under /sys/class/leds/? That would be way shorter:
deviceinfo_status_led = "lp5523:r lp5523:g lp5523:b"

only led names would work. But I found out that some led controllers need more than the brightness setting to change the value. For exampe:

Simply set the brightness, then set on_off_ms, then trigger via rgb_start. Note that two transactions will need different numbers to be sent to rgb_start

https://stackoverflow.com/questions/24736562/nexus-5-cannot-change-led-colour-through-sysfs-interface

the samsung i9070 doesn't even have a notification led, but as an alternative we can use the button backlight:
/sys/class/leds/button-backlight/brightness

Isn't the notification light required in the android device standard?

Hey.

I've started working on this and I have a proof of concept at https://github.com/PabloCastellano/pmbootstrap/tree/feature/indicate-initramfs-status-led

In my titan device I can control the white one but however I'm still unable to switch on the RGB led. So I guess we could start with the white one might work for everyone just by echoing values to brightness

These are my led devices:

# ls -F /sys/class/leds/
lcd-backlight@
led:flash_0@
led:flash_torch@
lm3630a-backlight@
mmc0::@
mmc1::@
rgb@
white@

rgb:

localhost:/sys/class/leds# ls -F rgb/
brightness
control
device@
max_brightness
power/
subsystem@
trigger
uevent

Notice the control interface. I can read and write to it but the led is always off. I've also played a bit with triggers but still, nothing:

# cat rgb/control 
RGB=0x0, on/off=0/0 ms, ramp=1/1
# echo 200 > rgb/brightness 
# echo "80 3000 2000" > rgb/control 
# cat rgb/control 
RGB=0x80, on/off=3000/2000 ms, ramp=1/1

white:

localhost:/sys/class/leds# ls -F white/
brightness
device@
max_brightness
power/
subsystem@
trigger
uevent

With the white led, I can also set a specific trigger and the led will switch on after some time (any idea how and how often is the trigger value checked?)

@PabloCastellano instead of include the deviceinfo in the initramfs, you can replace variables when it is created, see how it is done here

Since deviceinfo is now available in initramfs, we can try @ollieparanoid's apporach of defining the led names in the file, e.g.: deviceinfo_status_led = "lp5523:r lp5523:g lp5523:b".

@PabloCastellano are you still working on this? i'm also interested to have it, and your PoC looks very promising

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Asara picture Asara  路  6Comments

ata2001 picture ata2001  路  3Comments

ghost picture ghost  路  4Comments

zenety picture zenety  路  5Comments

fynngodau picture fynngodau  路  3Comments