On 08/05/2014 23:18, Matthew Fatheree wrote: > From 3b2c4996441e2a73d48dd55edcd2d0ea123ffc87 Mon Sep 17 00:00:00 > 2001 From: Matthew Fatheree <matthew.fathe...@belkin.com> Date: > Sun, 4 May 2014 20:33:59 +0700 Subject: [PATCH 21/30] mamba mvebu: > enter FAILSAFE mode, in case the board boot up & Reset button is > pressed > > - Script to read Reset button status when the board boot up, then > export FAILSAFE to env. - Comment out #FAILSAFE= in file > lib/preinit/30_failsafe_wait to support enter FAILSAFE in case the > Reset button is pressed. > > Signed-off-by: Matthew Fatheree <matthew.fathe...@belkin.com> --- > .../files/lib/preinit/11_handler_reset_button | 10 ++ > .../files/lib/preinit/30_failsafe_wait | 96 > ++++++++++++++++++++ > .../linksys-base-files/files/usr/sbin/check_reset | 14 +++ 3 > files changed, 120 insertions(+) create mode 100644 > package/linksys-base-files/files/lib/preinit/11_handler_reset_button > > create mode 100644 package/linksys-base-files/files/lib/preinit/30_failsafe_wait > create mode 100755 > package/linksys-base-files/files/usr/sbin/check_reset > Hi,
nack, this mechanism already exists, in fact some of the code is copy pasted from the existinbg codepath. also the scritps added here are missing the Makefile patch to actually install them. namig a package linksys-base-files is also a bad idea as it implies you are adding features exclusive to your board. John > diff --git > a/package/linksys-base-files/files/lib/preinit/11_handler_reset_button > b/package/linksys-base-files/files/lib/preinit/11_handler_reset_button > > new file mode 100644 > index 0000000..88da37e --- /dev/null +++ > b/package/linksys-base-files/files/lib/preinit/11_handler_reset_button > > @@ -0,0 +1,10 @@ > +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 > Vertical Communications + +do_handler_reset() { + > /usr/sbin/check_reset + source /tmp/enter_failsafe +} + > +boot_hook_add preinit_essential do_handler_reset diff --git > a/package/linksys-base-files/files/lib/preinit/30_failsafe_wait > b/package/linksys-base-files/files/lib/preinit/30_failsafe_wait new > file mode 100644 index 0000000..4cf8355 --- /dev/null +++ > b/package/linksys-base-files/files/lib/preinit/30_failsafe_wait @@ > -0,0 +1,96 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# > Copyright (C) 2010 Vertical Communications + +fs_wait_for_key () { > + local timeout=$3 + local timer + local > do_keypress + local keypress_true="$(mktemp)" + local > keypress_wait="$(mktemp)" + local keypress_sec="$(mktemp)" + > if [ -z "$keypress_wait" ]; then + > keypress_wait=/tmp/.keypress_wait + touch > $keypress_wait + fi + if [ -z "$keypress_true" ]; then > + keypress_true=/tmp/.keypress_true + > touch $keypress_true + fi + if [ -z "$keypress_sec" ]; > then + keypress_sec=/tmp/.keypress_sec + > touch $keypress_sec + fi + + trap "echo 'true' > >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" > INT + trap "echo 'true' >$keypress_true; lock -u > $keypress_wait ; rm -f $keypress_wait" USR1 + + [ -n > "$timeout" ] || timeout=1 + [ $timeout -ge 1 ] || timeout=1 + > timer=$timeout + lock $keypress_wait + { + > while [ $timer -gt 0 ]; do + echo "$timer" > >$keypress_sec + timer=$(($timer - 1)) + > sleep 1 + done + lock -u > $keypress_wait + rm -f $keypress_wait + } & + + > echo "Press the [$1] key and hit [enter] $2" + echo "Press > the [1], [2], [3] or [4] key and hit [enter] to select the debug > level" + # if we're on the console we wait for input + > { + while [ -r $keypress_wait ]; do + > timer="$(cat $keypress_sec)" + + [ -n > "$timer" ] || timer=1 + timer="${timer%%\ > *}" + [ $timer -ge 1 ] || timer=1 + > do_keypress="" + { + > read -t "$timer" do_keypress + case > "$do_keypress" in + $1) + > echo "true" >$keypress_true + > ;; + 1 | 2 | 3 | 4) + > echo "$do_keypress" >/tmp/debug_level + > ;; + *) + > continue; + ;; + > esac + lock -u $keypress_wait + > rm -f $keypress_wait + } + > done + } + lock -w $keypress_wait + + > keypressed=1 + [ "$(cat $keypress_true)" = "true" ] && > keypressed=0 + + rm -f $keypress_true + rm -f > $keypress_wait + rm -f $keypress_sec + + return > $keypressed +} + +failsafe_wait() { + #FAILSAFE= + grep > -q 'failsafe=' /proc/cmdline && FAILSAFE=true && export FAILSAFE + > if [ "$FAILSAFE" != "true" ]; then + > pi_failsafe_net_message=true + preinit_net_echo > "Please press button now to enter failsafe" + > pi_failsafe_net_message=false + fs_wait_for_key f 'to > enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true + > [ -f "/tmp/failsafe_button" ] && FAILSAFE=true && echo "- failsafe > button "`cat /tmp/failsafe_button`" was pressed -" + > [ "$FAILSAFE" = "true" ] && export FAILSAFE && touch /tmp/failsafe > + fi +} + +boot_hook_add preinit_main failsafe_wait diff > --git a/package/linksys-base-files/files/usr/sbin/check_reset > b/package/linksys-base-files/files/usr/sbin/check_reset new file > mode 100755 index 0000000..a5a0346 --- /dev/null +++ > b/package/linksys-base-files/files/usr/sbin/check_reset @@ -0,0 > +1,14 @@ +#!/bin/sh + +GPIO_RESET=33 + +echo $GPIO_RESET > > /sys/class/gpio/export + +value=`cat /sys/class/gpio/gpio33/value` > + +if [ $value -le 0 ] +then + echo "export FAILSAFE=true" > > /tmp/enter_failsafe +else + echo "export FAILSAFE=" > > /tmp/enter_failsafe +fi -- 1.7.9.5 > > > > __________________________________________________________________ > Confidential This e-mail and any files transmitted with it are the > property of Belkin International, Inc. and/or its affiliates, are > confidential, and are intended solely for the use of the individual > or entity to whom this e-mail is addressed. If you are not one of > the named recipients or otherwise have reason to believe that you > have received this e-mail in error, please notify the sender and > delete this message immediately from your computer. Any other use, > retention, dissemination, forwarding, printing or copying of this > e-mail is strictly prohibited. Pour la version française: > http://www.belkin.com/email-notice/French.html Für die deutsche > Übersetzung: http://www.belkin.com/email-notice/German.html > __________________________________________________________________ > _______________________________________________ openwrt-devel > mailing list openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel > _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel