Jump to content

Enable LED blinking for Cubietruck kernel 4.1.2


wsian

Recommended Posts

Thanks for the links. :)

I have check the dts file (converted from dtb), all the leds parameters are already there.

 

Listing from /sys/class/leds, the 4 leds are ready

cubietruck:blue:usr  
cubietruck:orange:usr
cubietruck:green:usr  
cubietruck:white:usr

 

 
echo "heartbeat" > /sys/class/leds/cubietruck\:blue\:usr/trigger  works okay.
 
What is the best way to make these triggers auto start when boot?
Link to comment
Share on other sites

echo "heartbeat" > /sys/class/leds/cubietruck\:blue\:usr/trigger  works okay.

 
What is the best way to make these triggers auto start when boot?

 

 

Put this in /etc/rc.local prior to the last line "exit 0"

Link to comment
Share on other sites

how to disable the leds, if they are on?

how to switch them on or off when certain conditions are met (e.g. disk full)?

thank you!

 

Just a hint. You will need to write a mini application / script / daemon.

Link to comment
Share on other sites

 

Thanks for the links. :)

I have check the dts file (converted from dtb), all the leds parameters are already there.

 

Listing from /sys/class/leds, the 4 leds are ready

cubietruck:blue:usr  
cubietruck:orange:usr
cubietruck:green:usr  
cubietruck:white:usr

 

 
echo "heartbeat" > /sys/class/leds/cubietruck\:blue\:usr/trigger  works okay.
 
What is the best way to make these triggers auto start when boot?

 

 

This address does not exist in my ubuntu ct distribution.

 

Although there is

 

/sys/class/leds/orange\:ph20\:led2/trigger

 

This file have a sintax like a b [c] d, to enable trigger c.

 

The issue is that this file can not be writen in any way. Is this config somewhere else?

Link to comment
Share on other sites

Just a hint. You will need to write a mini application / script / daemon.

 

Not in any case. You could also do some redirect/filter magic and let the output of a specific command lead to different triggers that modify blink frequency based on load or something like that.

 

On page 4 of this thread there are many examples using iostat (one line in /etc/rc.local). Also the BananaLEDd project that has been started in the aforementioned thread should be usable starting with v1.2 on Cubietruck using the LED=cubietruck:orange:usr syntax.

 

A simple daemon approach would be something like this (saved as eg. /usr/local/bin/diskblink.sh and started from within /etc/rc.local):

#!/bin/bash

export PATH=/usr/local/bin:/usr/bin:/bin

MyLed="/sys/class/leds/green:ph24:led1"
PartitionUUID=a7747356-feed-432a-81a3-7caea67c8cb8
PartitionDevice=$(ls -l /dev/disk/by-uuid/${PartitionUUID} | awk -F"/" '{print $7}')

echo timer >${MyLed}/trigger

while true ; do
    PartitionUseage=$(df -k | awk -F" " "/\/dev\/${PartitionDevice}/ {print \$5}" | tr -d '%')
    echo ${PartitionUseage} >${MyLed}/delay_on
    echo $(( ( 100 - ${PartitionUseage} ) * 100 )) >${MyLed}/delay_off
    # echo $(( 10000 - ${PartitionUseage} * ${PartitionUseage} ))  >${MyLed}/delay_off
    sleep 10
done
 
Since LED blinking is rather annoying I would also adjust brightness in the loop by something like this (value is in the range 0-255, with the following formula you get 2 with 10%, 62 with 50%, 202 with 90% and 245 with 99% -- so you will notice the LED only when it gets critical): 
 
echo $(( ${PartitionUseage} * ${PartitionUseage} / 40 )) >${MyLed}/brightness

You've to define $MyLed and of course $PartitionUUID (lookup with blkid). The script uses the timer trigger and adjust on/off cycles based on df's percentage output for the partition in question.

 

@Igor: Request for enhancement: please add BananaLEDd to /usr/local/bin for the A20 boards and ship with a disabled config for all supported boards :-)

Link to comment
Share on other sites

Small addendum: I just tried this out with an externally connected LED that was defined in script.bin. Works the same way as with the board's internal LEDs so you could use the convenient timer trigger or BananaLEDd to show average load or disk activity also with external LEDs since these populate sysfs when defined in script.bin. I just added a small section to the linux-sunxi wiki: http://linux-sunxi.org/Fex_Guide#external_leds

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines