summaryrefslogtreecommitdiffstats
path: root/boiler-monster/mr3020/etc
diff options
context:
space:
mode:
authorfishsoupisgood <github@madingley.org>2020-09-09 11:53:37 +0100
committerfishsoupisgood <github@madingley.org>2020-09-09 11:53:37 +0100
commit9d87c925a9eaa4fc256be3173c14a20d1469472d (patch)
tree50d63f87a47a0eac3f5b8058850184bcd4e6ee95 /boiler-monster/mr3020/etc
parentdafd8cf2fdcdd637cc06f760d318cf8391b1a294 (diff)
downloadheating-9d87c925a9eaa4fc256be3173c14a20d1469472d.tar.gz
heating-9d87c925a9eaa4fc256be3173c14a20d1469472d.tar.bz2
heating-9d87c925a9eaa4fc256be3173c14a20d1469472d.zip
everything, mostly, working
Diffstat (limited to 'boiler-monster/mr3020/etc')
-rwxr-xr-xboiler-monster/mr3020/etc/init.d/stm327
l---------boiler-monster/mr3020/etc/rc.d/S99stm321
-rwxr-xr-xboiler-monster/mr3020/etc/stm32/startup50
3 files changed, 58 insertions, 0 deletions
diff --git a/boiler-monster/mr3020/etc/init.d/stm32 b/boiler-monster/mr3020/etc/init.d/stm32
new file mode 100755
index 0000000..6dce9bf
--- /dev/null
+++ b/boiler-monster/mr3020/etc/init.d/stm32
@@ -0,0 +1,7 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=99
+boot() {
+ /etc/stm32/startup > /var/log/stm32.log
+}
diff --git a/boiler-monster/mr3020/etc/rc.d/S99stm32 b/boiler-monster/mr3020/etc/rc.d/S99stm32
new file mode 120000
index 0000000..a3b0774
--- /dev/null
+++ b/boiler-monster/mr3020/etc/rc.d/S99stm32
@@ -0,0 +1 @@
+../init.d/stm32 \ No newline at end of file
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}