From 8dbc08a6f98fba1f61a8505791e0682112420302 Mon Sep 17 00:00:00 2001 From: John Klug Date: Fri, 15 Sep 2017 11:00:54 -0500 Subject: Do not do flash upgrade when /var/volatile is full, and blink LEDS --- recipes-core/initscripts/initscripts-1.0/umountfs | 39 +++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/recipes-core/initscripts/initscripts-1.0/umountfs b/recipes-core/initscripts/initscripts-1.0/umountfs index 8c12ebe..f371554 100644 --- a/recipes-core/initscripts/initscripts-1.0/umountfs +++ b/recipes-core/initscripts/initscripts-1.0/umountfs @@ -49,6 +49,33 @@ blink_leds() { done } +err_leds() { + led_dir=/sys/class/leds + # blink all programmable LEDs except status + leds=$(ls $led_dir/ | grep -v status) + nleds=$(echo "$leds" | wc -w) + + # turn LEDs off + for led in $leds; do + echo "timer" > $led_dir/$led/trigger + echo 0 > $led_dir/$led/delay_off + done + + int=200 + total=$(( int * (nleds+1) )) + on=$(( total - int )) + off=$(( total - on )) + + # make a pattern + for led in $leds; do + echo "$on" > $led_dir/$led/delay_on + echo "$off" > $led_dir/$led/delay_off + done + sleep 5 +} + + + flash_upgrade() { if [ $# -ne 1 ]; then echo "need to specify flash-root" @@ -188,8 +215,16 @@ flash_upgrade() { blink_leds - cp ${reboot_cmd} ${flash_dir}/upgrade-reboot - cp ${nandwrite_cmd} ${flash_dir}/nandwrite.static + if ! cp ${reboot_cmd} ${flash_dir}/upgrade-reboot ; then + echo "Aborting upgrade. Failed \"cp ${reboot_cmd} ${flash_dir}/upgrade-reboot\"" + err_leds + return 1 + fi + if ! cp ${nandwrite_cmd} ${flash_dir}/nandwrite.static ; then + echo "Aborting upgrade. Failed \"cp ${nandwrite_cmd} ${flash_dir}/nandwrite.static\"" + err_leds + return 1 + fi sync sleep 2 mount -o remount,ro ${flash_root} -- cgit v1.2.3