AVR watch-dog daemon for Linkstation
WORK IN PROGRESS
avr_evtd is an operating system daemon and should be started from /etc/init.d or /usr/local/sbin. It will return immediately, so you don't need to start it with '&'.
avr_evtd is a simple and small user space interface to the Linkstation AVR micro-controller. It doesn't have a lot of special features, but it's main task is to provide 'keep-alive' messages to the Linkstation's on-board AVR device. This device controls/monitors the fan, various LEDs, timed power up and two buttons. This daemon provides the necessary initialisation to the device and also stimulates the LEDs depending on various fault conditions. It also monitors a power button (located at the front) and a reset button (located at the rear).
avr_evtd searches for a configuration file located within the /etc/melco at start-up time. If this file does not exist, then it reverts to reading the file located at /etc/default/avr_evtd. Additionally, it periodically checks the root /dev/hda1 partition and the user data partition /dev/hda3 to ensure they are mounted. Also, if requested, it will determine if sufficient space remains and if not then the AVR is requested to illuminate the DISK LED. This periodic checking also takes place on the configuration files. If they are deemed to have been updated, then the daemon will respond accordingly.
Any failures are normally routed through the log files. With timed shutdown/power up, a warning will be broadcast to all users (console message) when within 5 or less minutes of power off. Also, fan failure alerts will be broadcast in this fashion. Failure to determine mounted partition /dev/hda3 will result in the DIAG LED flashing three times, repeatedly.
A new feature of this daemon is the ability to code events for single or groups of days. This allows the user to add any number of power-on/off events as required. This also has the added benifit of being able to shut down the device for longer periods. The internal AVR timer has a 12-bit resolution timer which can power up the linkstation from a maximum of a sixty eight hour sleep: from time of invocation. The AVR is updated again at time of power down/shutdown to re-validate the timer, in case of time updates (either by user or ntp). This will also preserve the 68 hour sleep resolution.
Get the latest version from https://sourceforge.net/projects/ppc-evtd
cd / wget <link to latest version from sourcecforge site> tar -xfvj <filename from wget download>
- build the source and install process daemon and configuration files
cd /usr/src/avr_evtd make install avr_evtd
- modify /etc/default/avr_evtd.sample to suit your needs (refer to below for more information) and save as avr_evtd.
- remove current daemon ppc_evtd (or mc_ctld for MIPS) if applicable
update-rc.d -f ppc_uartd remove
- add the new daemon links
update-rc.d avr_evtd start 12 2 . stop 95 0 6 .
- check the daemon is running
ps aux | grep avr_evtd
- observe /usr/local/sbin/avr_evtd in the output line
/etc/default/avr_evtd configuration file is the fallback file in the event that the stock melco files do not exist. The file is read at initial start-up in order to determine if timed shutdown is required and if the disk usage is to be monitored. The file should be always located within the /etc/default directory and a sample file is provided. The file format is similar to other Unix configuration files - comments begin with a # character and extend to the end of the line; blank lines are ignored. Configuration commands consist of an initial keyword followed by an argument. Arguments may be strings or times written in HH:MM (UTC) format. Optional arguments are delimited by [ ] in the following descriptions, while alternatives are separated by |.
This is an example configuration file:
# Sample avr_evtd daemon configuration file # PLEASE EDIT THIS FILE TO SUIT DEBUG=ON # # Timed shutdown flag (ON enables timed power down/up only # or use days of the week MONWEDSAT etc # if SHUTDOWN and POWERON are also specified) TIMER=ON # To override the device scan, specify the desired # serial port connection to the AVR below and remove the # comment #DEVICE=/dev/ttyS1 # MACRO day/group switching ON/OFF times in 24hr HH:MM MON=ON=08:00,OFF=21:00,ON=23:30 TUE=OFF=02:30,ON=09:00,OFF=21:45 WED-FRI=ON=08:00,OFF=22:00 SAT=ON=07:30,OFF=08:30 # Shutdown (default) time specified in 24hr format HH:MM SHUTDOWN= # Power on (default) time specified in 24hr format HH:MM POWERON= # Disk check, set to OFF or a value (0-100) specifying a # percentage used at which the disk LED will illuminate DISKCHECK=90 # Disk/AVR refresh rate (seconds), default 40 REFRESH=40 # Hold time (seconds) for button power-off, default 3 HOLD=3 # Enable/disable continous disk full messages, default off DISKNAG=OFF # Fan stationary fault timer (seconds), default 30 FANSTOP=30
In this example:
- Debug data is displayed
- Timed shutdown/power on is enabled
- For monday, the box will power on at 08:00, off at 21:00 and on again at 23:30
- Tuesday, the box will power off at 02:30, on at 09:00 and off at 21:45
- Wednesday throught friday, the box will power on at 08:00 and off at 22:00
- Saturday, the box will power on at 07:30 and off at 08:30
- Sunday, the box will not power up
- No default shutdown or power on time is defined
- The disk led will illuminate if either /dev/hda1 or /dev/hda3 is above 90% used.
- The avr refresh rate is set to 40 seconds
- The button hold time for power off is set to 3 seconds
- Continous disk event messages on disk full is disabled
- A fan event will be generated if stationary for more than 30 seconds.