Control On-board LEDs


#8

So there’s still not a solution for this? :(( The green LED while power on is really bright and it could degrade with such brigthness I think and I want to have a better control over them so I can make them blink on wifi activity for example or storage I/O.


(Frank W.) #9

Why not using the gpio with an additional led+resistor?


#10

My case has special like holes for those 3 LEDs and the green LED is too bright but yeah I will try to put a led with resistor.

Thanks


(Przemek) #11

I’m so sorry that I write in this old subject, but I need exactly the same - have possibility to turn on/off system LEDs. I try to setup automatic configuration for BPI-R2 and I want to use this system LEDs to inform about the setup process finished. I would use sound but I cant find any speaker on this board. I can’t use any additional LEDs and resistors to connect it to GPIO port :frowning: @linkerosa Are you will be able to show me how I can use this mentioned by you? In /sys/devices/platform/ I have only mediatek,dummy_codec/, mediatek,mt7623_audio/, mediatek,mt7623_dai/, mt8173-cpufreq/ regarded to mediatek.


(Frank W.) #12

the leds itself seems to be mapped here: /sys/class/leds/ as

bpi-r2:isink:blue/                       
bpi-r2:isink:green/
bpi-r2:isink:red/ 

bpi-r2:pio:blue/   
bpi-r2:pio:green/ 
bpi-r2:pio:red/ 

but currently i have no idea, how to control them


(dorabmon) #13

mt6323 pmic has three leds , they can be found on bpi r2 board

you need to add them to dts and enable them in kconfig, as they’re done in upstream kernel https://elixir.bootlin.com/linux/v4.17-rc1/source/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts#L485

and how to use ?

on =>

echo 1 > /sys/class/leds/bpi-r2:isink:green/brightness

off =>

echo 0 > /sys/class/leds/bpi-r2:isink:green/brightness

blink =>

echo timer > /sys/class/leds/bpi-r2:isink:green/trigger

change blink frequency (on and off time in ms) =>

echo 100 > /sys/class/leds/bpi-r2:isink:green/delay_on

echo 100 > /sys/class/leds/bpi-r2:isink:green/delay_off


(Frank W.) #14

thank you @linkerosa

works in my tests…red and blue simply going on with “echo 1”, green blinks in nearly 1s period (~500ms on and ~500ms off)

brightness sounds like a float-value, right? can it be dimmed?

delay-values are not existing in my system (4.14.34), tried to create => permission denied

btw. i had thought, that the leds are these next to gpio, but these are the leds near power-socket


(Przemek) #15

OK, thanks all for exploration. Now, I have only this:

root@bpi-iot-ros-img:~# ls -l /sys/class/leds/
total 0
lrwxrwxrwx 1 root root 0 Apr 17 16:51 input4::capslock -> ../../devices/platform/1a1c0000.usb/usb1/1-1/1-1:1.0/0003:03F0:064A.0003/input/input4/input4::capslock
lrwxrwxrwx 1 root root 0 Apr 17 16:51 input4::numlock -> ../../devices/platform/1a1c0000.usb/usb1/1-1/1-1:1.0/0003:03F0:064A.0003/input/input4/input4::numlock
lrwxrwxrwx 1 root root 0 Apr 17 16:51 input4::scrolllock -> ../../devices/platform/1a1c0000.usb/usb1/1-1/1-1:1.0/0003:03F0:064A.0003/input/input4/input4::scrolllock

Because I use original kernel from Ubuntu image 1.2.1 (recompalied to have build in sata and raid support):

root@bpi-iot-ros-img:~# uname -a
Linux bpi-iot-ros-img 4.4.70-BPI-R2-Kernel

It is true?


(dorabmon) #16

/sys/class/leds/bpi-r2:isink:green/brightness can be 1 ~ 6

after you have to input echo timer > /sys/class/leds/bpi-r2:isink:green/trigger

and then the entires

/sys/class/leds/bpi-r2:isink:green/delay_on

and

/sys/class/leds/bpi-r2:isink:green/delay_off

can appear


(Frank W.) #17

can blinking disabled? i have echoed timer to trigger, now the delay_on and delay_off node are visible, but i see no difference when i change the values. if i enable these noedes first the green led flickers strange with different times

green is brighter that the other 2


(Przemek) #18

@frank-w In which of your kernel version these system LEDs are supported?


(Frank W.) #19

as i wrote above…4.14.34…should be supported also in earlier 4.14.x


(Przemek) #21

Thanks @frank-w and sorry, but I’m not catched this detail. Could you share the link for the sources of this kernel(s)?


(dorabmon) #22

blinking can be disabled by echo 0 > /sys/class/leds/bpi-r2:isink:green/brightness

frequency can changes, you can try

echo 100 > /sys/class/leds/bpi-r2:isink:green/delay_on

echo 100 > /sys/class/leds/bpi-r2:isink:green/delay_off

and

echo 1000 > /sys/class/leds/bpi-r2:isink:green/delay_on

echo 100 > /sys/class/leds/bpi-r2:isink:green/delay_off

and compare what diffrences between the two set of commands

It seems hardware characteristics. i have checked the hardware value written by the driver, it indeed to writing the same value to their leds registers but there’s brightness differences


(Frank W.) #23

(Frank W.) #24

:stuck_out_tongue: then the led is off :wink: i want a steady-on

with 100/1000 i see no difference…tried with 10/1000 …there is a difference


(dorabmon) #25

echo 1 > /sys/class/leds/bpi-r2:isink:green/brightness

it is steady on on my setup …


(Frank W.) #26
[11:45] root@bpi-r2:~# L=/sys/class/leds/bpi-r2\:isink
[12:05] root@bpi-r2:~# echo 0 > $L:green/brightness                 #goes off 
[12:05] root@bpi-r2:~# echo 1 > $L:green/brightness                 #starts blinking

(dorabmon) #27

weird. it is different with my test.

echo 0 (to cancel blinking), and then echo 1 , i can get a always steady on

how about the other two leds ?

driver should use the same programming to those leds


(Frank W.) #28

the other 2 (red/blue) go on (1) and off (0), no blinking

timing with delay-nodes ist strange anyway…hard to describe

i see no difference between red,blue and green: https://github.com/frank-w/BPI-R2-4.14/blob/b80a9345899842733507fe40decec0ab7f0ba3cd/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts#L72

btw. i have HW rev 1.1 (if it matters), running debian 8 on my test-system with kernel 4.14.34