Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Enable LED blinking for Cubietruck kernel 4.1.2

Featured Replies

Can anyone help to provide guides since it is disable by default?

Thanks in advance.

  • Author

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?

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"

 

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?

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 :-)

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

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.