summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2021-02-15 16:02:33 -0600
committerJohn Klug <john.klug@multitech.com>2021-02-15 16:02:33 -0600
commit909ffd14b4b3c02ee85d8c382f043b5ebab6fa0d (patch)
treeb1c850187755ab0b189f606dbc7a62179bc99442
parent8f533895110c11516053c9bc11fe245d251dd769 (diff)
downloadmeta-multitech-909ffd14b4b3c02ee85d8c382f043b5ebab6fa0d.tar.gz
meta-multitech-909ffd14b4b3c02ee85d8c382f043b5ebab6fa0d.tar.bz2
meta-multitech-909ffd14b4b3c02ee85d8c382f043b5ebab6fa0d.zip
Wait for supercap charge up to 3 minutes. Poweroff if no power
-rw-r--r--recipes-bsp/multitech/mts-io.inc2
-rw-r--r--recipes-bsp/multitech/mts-io/mts-io.conf10
-rw-r--r--recipes-bsp/multitech/mts-io/mts-io.mtcap.init38
3 files changed, 49 insertions, 1 deletions
diff --git a/recipes-bsp/multitech/mts-io.inc b/recipes-bsp/multitech/mts-io.inc
index e33ae00..65cb00c 100644
--- a/recipes-bsp/multitech/mts-io.inc
+++ b/recipes-bsp/multitech/mts-io.inc
@@ -7,7 +7,7 @@ LIC_FILES_CHKSUM = "file://io-module/COPYING;md5=94d55d512a9ba36caa9b7df079bae19
file://io-tool/COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
"
do_fetch[depends] += "virtual/kernel:do_shared_workdir"
-INC_PR = "r3"
+INC_PR = "r4"
SRCREV = "${PV}"
PR = "${INC_PR}.0-${KERNEL_MODULE_PACKAGE_SUFFIX}"
diff --git a/recipes-bsp/multitech/mts-io/mts-io.conf b/recipes-bsp/multitech/mts-io/mts-io.conf
index b5b4275..4ed5e31 100644
--- a/recipes-bsp/multitech/mts-io/mts-io.conf
+++ b/recipes-bsp/multitech/mts-io/mts-io.conf
@@ -7,3 +7,13 @@ GPSGNSSRESET=1
# 0 is off
# 1 is on
DEBUG=0
+
+# Supercap Feature
+# Do not let boot proceed until supercap is full.
+# Prevents loss of data when power is out.
+SUPERCAPFULL=1
+
+# Maximum wait time for SUPERCAPFULL
+#
+SUPERCAPFULL_MAXWAIT=180
+
diff --git a/recipes-bsp/multitech/mts-io/mts-io.mtcap.init b/recipes-bsp/multitech/mts-io/mts-io.mtcap.init
index 19bfa4a..ff0e947 100644
--- a/recipes-bsp/multitech/mts-io/mts-io.mtcap.init
+++ b/recipes-bsp/multitech/mts-io/mts-io.mtcap.init
@@ -103,6 +103,42 @@ cell_init() {
start_lora_led_updater() {
lora-led-updater &
}
+gettime() {
+ [[ $(cat /proc/uptime) =~ ([^[:space:]]+) ]]
+ echo ${BASH_REMATCH[1]}
+}
+wait_for_supercap() {
+ supercap=$(mts-io-sysfs show capability/supercap 2>/dev/null)
+ if ((supercap != 1)) ; then
+ return
+ fi
+ if ((SUPERCAPFULL != 1)) ; then
+ break
+ fi
+ t0=$(gettime)
+ maxwait=$(awk "BEGIN {print ${t0}+${SUPERCAPFULL_MAXWAIT}}")
+ while : ; do
+ if (($(mts-io-sysfs show power-fail) == 1)) ; then
+ # If we are booting, then go down.
+ # This will not work with systemd.
+ if [[ $(ps -h -o cmd -p $PPID) =~ /bin/sh[[:space:]]/etc/init.d/rc[[:space:]]S$ ]] ; then
+ logger -s -t 'mts-io' -p daemon.err "No power during boot, so power off"
+ exec /sbin/poweroff
+ # NOT REACHED
+ fi
+ fi
+ if (($(mts-io-sysfs show supercap-full) == 1)) ; then
+ logger -s -t 'mts-io' -p daemon.err 'Supercap Charged'
+ return
+ fi
+ t1=$(gettime)
+ if awk "BEGIN { if($t1<$maxwait)exit 1 }" ; then
+ break
+ fi
+ sleep 1
+ done
+ logger -s -t 'mts-io' -p daemon.err 'Supercap not full but timer expired -- continuing boot'
+}
case $1 in
start)
@@ -129,6 +165,8 @@ case $1 in
(($WIFICAP)) && modprobe wilc1000-sdio
set_hw_name
set_gpslink
+ wait_for_supercap
+
;;
stop)