LEDs on NSA325v2
January 27, 2021 05:52AM
Hello,

I am running Debian with 5.2.9 kirkwood kernel on my device which I installed from this awesome website. I was wondering if there is any way to interact with the LEDs and speaker on the device (e.g. I want my sata1/sata2 leds turn red and play a beep sound when there is a disk failure -> mdadm detects a degraded array). I found some files in /sys/class/leds but tbh I dont really know how to continue from there. Can I just set the value in the brightness file to max (255) ?

For the beeping,I tried the "beep" package but it does not produce any sound.

I dont want to break anything so I figured it is better to ask here first.
Re: LEDs on NSA325v2
January 27, 2021 06:11PM
Dyce,

> For the beeping,I tried the "beep" package but it
> does not produce any sound.

I don't think the buzzer works on this box.

> I was wondering if there is any way to
> interact with the LEDs and speaker on the device
> (e.g. I want my sata1/sata2 leds turn red and play
> a beep sound when there is a disk failure -> mdadm
> detects a degraded array).

> I found some files in
> /sys/class/leds but tbh I dont really know how to
> continue from there. Can I just set the value in
> the brightness file to max (255) ?
>

Look in your rootfs /etc/rc.local for example how to manipulate the GPIO.

In the 3 examples below, the first echo sets the Sys LED to green. The last 2 set the HDD1 and HDD2 to a trigger that will flash the LED whenever there is disk access.

if [ -d /sys/class/leds/nsa325:green:sys ]; then
   echo default-on  > /sys/class/leds/nsa325:green:sys/trigger 
   echo none        > /sys/class/leds/nsa325:orange:sys/trigger
fi

if [ -d /sys/class/leds/nsa325:green:sata1 ]; then
   echo ide-disk1  > /sys/class/leds/nsa325:green:sata1/trigger 
fi

if [ -d /sys/class/leds/nsa325:green:sata2 ]; then
   echo ide-disk2  > /sys/class/leds/nsa325:green:sata2/trigger 
fi

And for this box:

Quote
ls -l /sys/class/leds/
total 0
drwxr-xr-x 2 root root 0 Jan 27 15:58 .
drwxr-xr-x 49 root root 0 Jan 27 15:56 ..
lrwxrwxrwx 1 root root 0 Jan 27 15:58 nsa325:green:copy -> ../../devices/platform/gpio-leds/leds/nsa325:green:copy
lrwxrwxrwx 1 root root 0 Jan 27 15:58 nsa325:green:sata1 -> ../../devices/platform/gpio-leds/leds/nsa325:green:sata1
lrwxrwxrwx 1 root root 0 Jan 27 15:58 nsa325:green:sata2 -> ../../devices/platform/gpio-leds/leds/nsa325:green:sata2
lrwxrwxrwx 1 root root 0 Jan 27 15:58 nsa325:green:sys -> ../../devices/platform/gpio-leds/leds/nsa325:green:sys
lrwxrwxrwx 1 root root 0 Jan 27 15:58 nsa325:green:usb -> ../../devices/platform/gpio-leds/leds/nsa325:green:usb
lrwxrwxrwx 1 root root 0 Jan 27 15:58 nsa325:orange:sys -> ../../devices/platform/gpio-leds/leds/nsa325:orange:sys
lrwxrwxrwx 1 root root 0 Jan 27 15:58 nsa325:red:copy -> ../../devices/platform/gpio-leds/leds/nsa325:red:copy
lrwxrwxrwx 1 root root 0 Jan 27 15:58 nsa325:red:sata1 -> ../../devices/platform/gpio-leds/leds/nsa325:red:sata1
lrwxrwxrwx 1 root root 0 Jan 27 15:58 nsa325:red:sata2 -> ../../devices/platform/gpio-leds/leds/nsa325:red:sata2

So to turn on the red LED flashing

echo none > /sys/class/leds/nsa325:green:sata1/trigger 
echo ide-disk1  > /sys/class/leds/nsa325:red:sata1/trigger
or to make it stay solid red:
echo default-on > /sys/class/leds/nsa325:red:sata1/trigger

And for brightness, usually you can echo a value to brightness (0-255). But IIRC, this box does not allow LED brightness change. You can play with it to see if it works.

Quote
ls -l /sys/class/leds/nsa325\:red\:sata1/
total 0
drwxr-xr-x 3 root root 0 Jan 27 16:03 .
drwxr-xr-x 11 root root 0 Jan 27 16:03 ..
-rw-r--r-- 1 root root 4096 Jan 27 16:03 brightness
lrwxrwxrwx 1 root root 0 Jan 27 16:03 device -> ../../../gpio-leds
-r--r--r-- 1 root root 4096 Jan 27 16:03 max_brightness
drwxr-xr-x 2 root root 0 Jan 27 16:03 power
lrwxrwxrwx 1 root root 0 Jan 27 16:03 subsystem -> ../../../../../class/leds
-rw-r--r-- 1 root root 0 Jan 27 16:03 trigger
-rw-r--r-- 1 root root 4096 Jan 27 16:03 uevent

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: LEDs on NSA325v2
January 28, 2021 01:25AM
Hello,

> I don't think the buzzer works on this box.

Strange, because IIRC it worked when I was using stock OS long time ago (it played beep sound when I long-pressed the power button to shut the box down), but it's not a problem, it is a small price to pay for getting rid of the original OS.


> Look in your rootfs /etc/rc.local for example how
> to manipulate the GPIO.

Thank you, there are many other examples in this file. I figured not all are for my system, but looking at files in /sys/class/leds it is easy to figure out what examples apply to me.


> And for brightness, usually you can echo a value
> to brightness (0-255). But IIRC, this box does
> not allow LED brightness change. You can play with
> it to see if it works.

Yeah it does not support brightness change, but that was expected (it was a cheap box). I just thought I have to manually set the brightness in those files in order to turn on leds.

Thank you again for helping me out, and thank you for the awesome work you are doing here!
Re: LEDs on NSA325v2
January 28, 2021 07:02AM
One last question came to my mind. My power button is not working when the device is running. Is there a way to execute shutdown command when I press (or hold) the power button?
Re: LEDs on NSA325v2
January 28, 2021 03:49PM
Dyce,

> One last question came to my mind. My power button
> is not working when the device is running. Is
> there a way to execute shutdown command when I
> press (or hold) the power button?


See the Wiki topic


Quote

Key daemon (button control)

Multimedia keyboard daemon for Linux
How to use set up button to reboot or shutdown with Key Daemon (esekeyd)

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: LEDs on NSA325v2
January 31, 2021 04:46AM
Sorry for the late reply.

bodhi Wrote:
> See
> the
> Wiki topic

>
>
>
Quote

Key daemon (button control)
>
> Multimedia keyboard daemon for Linux
> How to use set up button to reboot or shutdown
> with Key Daemon (esekeyd)


I will look into it, thank you very much!
Re: LEDs on NSA325v2
February 02, 2021 09:42AM
Hi guys!
@Dyce have you found out how to report degraded raid using red leds?
Please share it.
Thank you.

Ivan
Re: LEDs on NSA325v2
April 12, 2021 01:53PM
I know it's not Christmas, but I accidentally wrote this script after reading this thread. It will randomly switch on and off random LEDs.

#!/bin/bash

cd /sys/class/leds

LEDS=(*)
ONOFF=('none' 'default-on')

while true ; do
  LED=${LEDS[$((0 + $RANDOM % ${#LEDS[@]} ))]}
  VALUE=${ONOFF[$RANDOM % 2]}
  echo $VALUE > ${LED}/trigger
  sleep 0.1
done
Re: LEDs on NSA325v2
April 13, 2021 02:27AM
antrew Wrote:
-------------------------------------------------------
> I know it's not Christmas, but I accidentally
> wrote this script after reading this thread. It
> will randomly switch on and off random LEDs.
>
>
> #!/bin/bash
> 
> cd /sys/class/leds
> 
> LEDS=(*)
> ONOFF=('none' 'default-on')
> 
> while true ; do
>   LED=${LEDS[$((0 + $RANDOM % ${#LEDS[@]} ))]}
>   VALUE=${ONOFF[$RANDOM % 2]}
>   echo $VALUE > ${LED}/trigger
>   sleep 0.1
> done
>

Cool :)

-bodhi
===========================
Forum Wiki
bodhi's corner
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: