diff options
Diffstat (limited to 'boiler-monster/mr3020/etc/stm32/startup')
-rwxr-xr-x | boiler-monster/mr3020/etc/stm32/startup | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/boiler-monster/mr3020/etc/stm32/startup b/boiler-monster/mr3020/etc/stm32/startup new file mode 100755 index 0000000..9422745 --- /dev/null +++ b/boiler-monster/mr3020/etc/stm32/startup @@ -0,0 +1,50 @@ +#!/bin/sh + +logger -t stm32 "startup" + +LOCK=/var/lock/LCK..ttyATH0 +echo $$ > ${LOCK}.tmp + +#killall -9 ser2net + +FW="/etc/stm32/boiler.fw" +TFW="/tmp/stm32.fw" + +PORT="/dev/ttyATH0" + +echo 5 > /sys/class/gpio/export +echo out > /sys/class/gpio/gpio5/direction + +for i in $(seq 0 20); do + echo 1 > /sys/class/leds/tp-link\:green\:wps/brightness + echo 0 > /sys/class/leds/tp-link\:green\:wps/brightness + + if stm32flash "${PORT}"; then + break + fi + sleep 1 +done + +if [ -z "$1" ]; then + logger -t stm32 "reading ROM" + if ! stm32flash -r "${TFW}" "${PORT}" ; then + exit 1 + fi + + if diff -q "${TFW}" "${FW}"; then + logger -t stm32 "Code in ROM matches file" + echo "Code in ROM matches file" + else + logger -t stm32 "Flashing" + echo "Code in ROM doesn't match file, flashing" + stm32flash -w "${FW}" "${PORT}" + fi +else + echo "Flashing..." + stm32flash -w "$1" "${PORT}" +fi + +logger -t stm32 "Booting" +stm32flash -g 0 "${PORT}" + +rm -f ${LOCK} |