LED SD Card indicator 看全部

Hello guys.
the fact is, in armbian LED indicators on the board are useless somehow !
in mine red LED won't turn on and green LED blinks and stays on, so i made a use from them
i will write here how to make red LED like SD Card indicator LED so at SD Card activities LED would blink (Like green LED in Raspberry Pi)
i did try to do this for green LED, it worked but when i put the code in startup it didn't affected the green LED and it only worked for red LED. so in this guid we will use green LED as ON/OFF status of device and red LED as SD Card activty indicator.

1- Open terminal and login with root user or use this command to login as root
  1. su
2- Type this command to open rc.local with nano text editor
  1. nano /etc/rc.local
3- add this before exit 0
  1. echo none >/sys/class/leds/red_led/trigger
  2. echo mmc0 >/sys/class/leds/red_led/trigger
  3. echo 1 >/sys/class/leds/green_led/brightness
4- then press Ctrl + X then Y
5- It's Done ! Reboot now to test how this works
  1. reboot

I got an idea in your post.
I made the script which checks a package update.

1.Change in /etc/sudoers
$ sudo visudo

The following 1 line is added to the end.


2.Create this script(pkg_checker.sh) in $HOME

  1. #!/bin/bash
  2. sudo apt-get -s upgrade > /tmp/apt.log
  3. #grep -c "The following packages will be upgraded" /tmp/apt.log
  4. check=`grep -c "The following packages will be upgraded" /tmp/apt.log`
  5. #echo $check
  6. rm /tmp/apt.log
  7. if [ $check -ne 0 ] ; then
  8. # Update package EXIST
  9.   sudo sh -c "echo 0 > /sys/class/leds/red_led/brightness"
  10.   sudo sh -c "echo heartbeat > /sys/class/leds/red_led/trigger"
  11.   sudo sh -c "echo 1 > /sys/class/leds/red_led/brightness"
  12. else
  13. # Update package NOT EXIST
  14.   sudo sh -c "echo none > /sys/class/leds/red_led/trigger"
  15.   sudo sh -c "echo 0 > /sys/class/leds/red_led/brightness"
  16. fi

3.Add execute permission to this script.
chmod 777 pkg_checker.sh

4.Execute this script.
If there is update package,RED-LED become blink.

5.Add crontab
0 * * * * /home/orangepi/pkg_checker.sh

  • Bench M3NI
  • 2016-7-30 18:37:59
Thanks! I will test it on my pi when i got home, also could you manage to make green LED blink for sd card activity? When i attempted to do that on startup it would just get stock and would be on. Not blinking. I think we have to find the original command in armbian to disable the "heartbeat" trigger for it that starts at startup, unfortunately i didn't found it
Actually M3NI I had fixed that already, if you run your program at that boot level if you pay attention, actually works... But! After it continues booting (I don't know why or when honestly) the system itself changes it function for it default (Default-ON), so the solution is to start the green LED just when your start your GUI, any of them, so my solution is (if you are using xserver ofcourse).
- Test you have all x servers dependencies (you must try a "startx" command into a terminal and it should open your GUI.
- At your home direction (usually in armbian is /home/pi/) check your .xinitrc file and if you don't have it create it
- Edit that text starting your graphical interface and sending the GREEN LED FUNCTION together.

FOR EXAMPLE if you are starting XFCE4
  1. exec echo heartbeat >/sys/class/leds/green_led/trigger &
  2. exec startxfce4

if your xserver goes to that file for your personal configuration, and you are using Orange Pi's defauilt GUI, xfce4, it should start your graphical interface AND start beating your led, obviously you should use any function you want there.

Could the original script of blinking red on SDCard access have the same problem?  It is in my /etc/rc.local but it never seems to work.  Should I maybe put it in one of the rcn.d directories?  Oh wait all those are 777 and rc.local is 755.  Maybe I should chmod 777 rc.local.  I'll give that a try.

I know it should work somehow becuase if I SU then execute the two echo statements the LED starts working as defined.