summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim 'timtim' Ellis <tim.ellis@foonas.org>2009-01-22 21:03:57 +0000
committerTim 'timtim' Ellis <tim.ellis@foonas.org>2009-01-22 21:03:57 +0000
commit8ae0d7e99946b21aa404eb61ce49c49d2d237020 (patch)
tree8d86a951d55b298d708e27b0212077598619fe9f
parentb5cd58e9ecc3c80e54222368e3c704a0b25d6e90 (diff)
avr-evtd: Add avr-evtd, LED/button/watchdog stuff for lsppchd, lsppchg and lsmipsel
-rw-r--r--packages/avr-evtd/avr-evtd_1.7.2.bb40
-rwxr-xr-xpackages/avr-evtd/files/EventScript110
-rw-r--r--packages/avr-evtd/files/avr_evtd.conf6
-rw-r--r--packages/avr-evtd/files/dont-ignore-config.patch11
-rwxr-xr-xpackages/avr-evtd/files/init124
-rw-r--r--packages/avr-evtd/files/mipsel/avr_evtd.conf6
6 files changed, 297 insertions, 0 deletions
diff --git a/packages/avr-evtd/avr-evtd_1.7.2.bb b/packages/avr-evtd/avr-evtd_1.7.2.bb
new file mode 100644
index 0000000000..51f8843693
--- /dev/null
+++ b/packages/avr-evtd/avr-evtd_1.7.2.bb
@@ -0,0 +1,40 @@
+DESCRIPTION = "A simple and small user space interface daemon to the Linkstation/Kuro AVR micro-controller"
+HOMEPAGE = "http://sourceforge.net/projects/ppc-evtd"
+SECTION = "console/network"
+PR = "r0"
+LICENSE = "GPL"
+SRC_URI = "${SOURCEFORGE_MIRROR}/ppc-evtd/avr_evtd_${PV}.release.tar.gz \
+ file://dont-ignore-config.patch;patch=1 \
+ file://avr_evtd.conf \
+ file://EventScript \
+ "
+S = "${WORKDIR}/usr/src/avr_evtd"
+
+COMPATIBLE_MACHINE = "(lsppchd|lsppchg|lsmipsel)"
+
+# This is a simple thing, and we will only ever need this for powerpc and mipsel
+# on the platforms above. Pretty important though to stop death by watchdog.
+
+do_compile_powerpc() {
+ ${CC} ${CFLAGS} ${LDFLAGS} -o PPC/avr_evtd avr_evtd.c -DNO_MELCO -DUBOOT
+}
+
+do_compile_mipsel() {
+ ${CC} ${CFLAGS} ${LDFLAGS} -o MIPS/avr_evtd avr_evtd.c -DNO_MELCO -DUBOOT -DMIPS
+}
+
+do_install() {
+ install -d ${D}${sbindir}
+ install -d ${D}${sysconfdir}/default
+ install -m 644 ${WORKDIR}/avr_evtd.conf ${D}${sysconfdir}/default/avr_evtd
+ install -d ${D}${sysconfdir}/avr_evtd
+ install -m 755 ${WORKDIR}/EventScript ${D}${sysconfdir}/avr_evtd/EventScript
+}
+
+do_install_append_powerpc() {
+ install -c -m 755 ${S}/PPC/avr_evtd ${D}${sbindir}/avr_evtd
+}
+
+do_install_append_mipsel() {
+ install -c -m 755 ${S}/MIPS/avr_evtd ${D}${sbindir}/avr_evtd
+}
diff --git a/packages/avr-evtd/files/EventScript b/packages/avr-evtd/files/EventScript
new file mode 100755
index 0000000000..f9824d37c8
--- /dev/null
+++ b/packages/avr-evtd/files/EventScript
@@ -0,0 +1,110 @@
+#!/bin/sh
+# Sample Event Script written by Bob Perry
+#
+# Enters via the avr_evtd daemon with the following command options:
+# 0 - Special event following double press of the 'red' reset button
+# 1 - AVR device has requested a halt due to error
+# 2 - Shutdown request from timed shutdown logic
+# 3 - User has released the power button
+# 4 - User has pressed the power button
+# 5 - User has released the 'red' reset button
+# 6 - User has pressed the reset button
+# 7 - User has held the power button > 3 seconds
+# 8 - User has held the reset button > 3 seconds
+# 9 - Disk used beyond DISKCHECK%
+# F - Fan failure event, fan stopped for > FANSTOP seconds
+# E - User selected EM-Mode
+# S - Five minute shutdown warning event
+# D - Error message handler
+
+DEVICE=$2
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
+tag=avr-daemon
+facility=user.info
+
+. /etc/default/avr_evtd
+
+if [ "$DEBUG" = "ON" ] && [ -d "$LOG" ]; then
+ echo "`date` command is $1[$3] for $DEVICE" >> $LOG/avr_evtd.log
+fi
+
+if [ -f "/tmp/.inst-instflashing" ] ; then
+ if [ ! -f "/tmp/.inst-instdone" ] ; then
+ NOCMD="1"
+ fi
+fi
+
+case "$1" in
+ 0) case "$3" in
+ 1) # Indicate this mode by flashing the DISK FULL LED
+ echo -n "YYYY" > $DEVICE
+ # Add an EM IP address or if no ethernet, start it up
+ FAIL=1
+ route -n | grep -q eth0 && FAIL=0
+ if [ "$FAIL" -eq 0 ]; then
+ FAIL=1
+ route -n | grep -q 192.168.11.0 && FAIL=0
+ if [ "$FAIL" -eq 1 ]; then
+ ifconfig eth0:EM 192.168.11.150 netmask 255.255.255.0 up
+ fi
+ else
+ /sbin/ifup --force -a -i /etc/avr_evtd/emergency_eth0
+ sleep 1
+ route add -net 192.168.11.0 netmask 255.255.255.255.0 eth0:EM
+ fi
+ if [ -e /sbin/utelnetd ]; then
+ utelnetd -p 1234 -l /bin/bash &
+ fi ;;
+ 3) # Flash more lights to indicate we are desperate
+ echo -n "SSSS" > $DEVICE
+ ;;
+ *) exit -2 ;;
+ esac ;;
+ 3) echo -n "[avr_evtd]: Power Button Up"
+ ;;
+ 4) echo -n "[avr_evtd]: Power Button Down"
+ ;;
+ 5) echo -n "[avr_evtd]: Reset Button Up"
+ ;;
+ 6) echo -n "[avr_evtd]: Reset Button Down"
+ ;;
+ 1|2|7) echo -n "[avr_evtd]: Shutdown"
+ if [ ! "$NOCMD" = "1" ] ; then
+ echo -n "EEEE" > $DEVICE
+ halt
+ fi ;;
+ 8) echo -n "[avr_evtd]: User demanded reset"
+ if [ ! "$NOCMD" = "1" ] ; then
+ echo -n "CCCC" > $DEVICE
+ reboot
+ fi ;;
+ 9) if [ "$3" -eq 0 ]; then
+ echo -n "[avr_evtd]: Disk usage now safe"
+ else
+ echo -n "[avr_evtd]: Disk used $3% > Monitored $DISKCHECK%"
+ fi ;;
+ E) echo -n "[avr_evtd]: EM mode selected"
+ ;;
+ F) echo -n "[avr_evtd]: Fan failure detected"
+ if [ "$3" -eq 0 ]; then
+ logger -p user.emerg 'AVR Detected fan fault'
+ fi
+ if [ "$3" -eq 4 ]; then
+ # Illuminate relevant LED and wait for AVR halt message
+ echo -n "iiii" > $DEVICE
+ fi ;;
+ S) if [ "$3" -gt 100 ]; then
+ MESSAGE="System shutdown in less than 5 minutes"
+ else
+ MESSAGE="Shutdown delayed by $3 minutes"
+ fi
+ # Produce relevant message
+ logger -p user.emerg $MESSAGE ;;
+ D) MESSAGE="[$3] Error with configuration file"
+ logger -t $tag -p $facility $MESSAGE ;;
+ *) exit 1
+ ;;
+esac
+
+exit 0
diff --git a/packages/avr-evtd/files/avr_evtd.conf b/packages/avr-evtd/files/avr_evtd.conf
new file mode 100644
index 0000000000..c48d28d081
--- /dev/null
+++ b/packages/avr-evtd/files/avr_evtd.conf
@@ -0,0 +1,6 @@
+LOG=/var/log
+DEBUG=ON
+TIMER=OFF
+DISKCHECK=0
+EMMODE=NO
+REFRESH=0
diff --git a/packages/avr-evtd/files/dont-ignore-config.patch b/packages/avr-evtd/files/dont-ignore-config.patch
new file mode 100644
index 0000000000..77b3f92fab
--- /dev/null
+++ b/packages/avr-evtd/files/dont-ignore-config.patch
@@ -0,0 +1,11 @@
+--- avr_evtd.old/avr_evtd.c 2006-10-29 12:27:28.000000000 -0600
++++ avr_evtd/avr_evtd.c 2007-12-11 09:38:40.000000000 -0600
+@@ -108,7 +108,7 @@
+ TIMER* poffTimer=NULL;
+ TIMER* ponTimer=NULL;
+ int i_FileDescriptor = 0;
+-time_t tt_LastMelcoAcess = 0;
++time_t tt_LastMelcoAcess = -1;
+ int i_TimerFlag = 0;
+ long l_ShutdownTimer=9999; /* Careful here */
+ char c_FirstTimeFlag=1;
diff --git a/packages/avr-evtd/files/init b/packages/avr-evtd/files/init
new file mode 100755
index 0000000000..34ea528926
--- /dev/null
+++ b/packages/avr-evtd/files/init
@@ -0,0 +1,124 @@
+#!/bin/sh
+#
+# avr_evtd Linkstation/Kuro AVR daemon
+#
+# Other files used are:
+# /etc/default/avr_evtd - Optional configuration file
+# /etc/avr_evtd/EventScript - Provides user with scripted
+# AVR event points
+# Optional files:
+# /etc/melco/timer_Sleep - Standard Melco sleep settings
+#
+# Written by Bob Perry (2006) lb-source@users.sourceforge.net
+#
+
+#
+# Location of the avr watchdog daemon and the init directory
+#
+DAEMON=/usr/sbin/avr_evtd
+initdir=/etc/init.d
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
+tag=linkstation
+facility=user.info
+
+test -e $DAEMON || exit 0
+
+getDevice()
+{
+ #
+ # Load custom settings
+ #
+ MIPS=NO
+
+ #
+ # Populate the configured settings
+ #
+ [ -f /etc/default/avr_evtd ] && . /etc/default/avr_evtd > /dev/null 2>&1
+
+ # Try and determine the UART used. The MIPS only has one UART
+ # available and the process is built accordingly. To support modified
+ # kernel's/kuro systems with polled over UARTs, drill into kernel
+ # configuration for the memory configuration of the UART to determine
+ # which tty to use if not set in the configuration file
+ uname -m | grep -q mips && MIPS=YES && DEVICE=/dev/ttyS0
+
+ if [ -z "$DEVICE" ] && [ "$MIPS" = "NO" ]
+ then
+ DEVICE=/dev/ttyS0
+ # Search for valid port address
+ PORT_ADDRESS=`$DAEMON -i -d /dev/ttyS1`
+ if [ $PORT_ADDRESS -eq 80004500 ] ; then DEVICE=/dev/ttyS1 ; fi
+ fi
+}
+
+start()
+{
+ #
+ # Daemon options
+ # e.g -d /dev/ttyS1
+ #
+ daemonoptions=
+
+ CONSOLE=OFF
+
+ getDevice
+
+ # Establish daemon startup options based on configuration settings
+ if [ "$EMMODE" = "YES" ]; then daemonoptions=-e ; fi
+
+ if [ -n "$DEVICE" ] && [ "$MIPS" = "NO" ]
+ then
+ [ -n "$daemonoptions" ] && daemonoptions="$daemonoptions "
+ daemonoptions="$daemonoptions-d $DEVICE"
+ fi
+
+ # Is this a MIPSEL box?
+ if [ "$MIPS" = "YES" ]
+ then
+ if [ -e /proc/linkstation ]
+ then
+ # Determine if console ttyS0 is in-use
+ CONSOLE=`cat /proc/linkstation | grep CONSOLE | awk -F "=" '{print $2}'`
+ fi
+ fi
+
+ if [ "$CONSOLE" = "ON" ]
+ then
+ echo "[avr_evtd]: Not started services as console in-use"
+ logger -t $tag -p $facility 'Not started avr_evtd as kernel still has console'
+ else
+ echo "Start services: avr_evtd"
+ /sbin/start-stop-daemon --start --quiet --exec $DAEMON -- $daemonoptions
+ logger -t $tag -p $facility 'Started daemon avr_evtd'
+ fi
+}
+
+stop()
+{
+ echo "Stop services: avr_evtd"
+ /sbin/start-stop-daemon --stop --quiet --exec $DAEMON
+ logger -t $tag -p $facility 'Stopped daemon avr_evtd'
+}
+
+# Check request
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ sleep 1
+ start
+ ;;
+ *)
+ echo "Usage: $DAEMON {start|stop|restart}" >&2
+ ;;
+esac
+
+exit 0
+
+
diff --git a/packages/avr-evtd/files/mipsel/avr_evtd.conf b/packages/avr-evtd/files/mipsel/avr_evtd.conf
new file mode 100644
index 0000000000..c48d28d081
--- /dev/null
+++ b/packages/avr-evtd/files/mipsel/avr_evtd.conf
@@ -0,0 +1,6 @@
+LOG=/var/log
+DEBUG=ON
+TIMER=OFF
+DISKCHECK=0
+EMMODE=NO
+REFRESH=0