summaryrefslogtreecommitdiff
path: root/recipes-core/mlinux-scripts
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2017-08-28 15:25:44 -0500
committerJohn Klug <john.klug@multitech.com>2017-09-14 17:31:50 -0500
commitbab089e8a10852a6262c26b67459a8b7045fd0a6 (patch)
tree848c254f0bee9616758c0e18d6a03220204e2471 /recipes-core/mlinux-scripts
parent1e07a786112f7217bca318c55a37f4123e9a2b45 (diff)
downloadmeta-mlinux-atmel-bab089e8a10852a6262c26b67459a8b7045fd0a6.tar.gz
meta-mlinux-atmel-bab089e8a10852a6262c26b67459a8b7045fd0a6.tar.bz2
meta-mlinux-atmel-bab089e8a10852a6262c26b67459a8b7045fd0a6.zip
Move fwswitch script to mlinux-scripts, and call it mlinux-switch-cell-fw
Diffstat (limited to 'recipes-core/mlinux-scripts')
-rwxr-xr-xrecipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-cell-fw114
-rw-r--r--recipes-core/mlinux-scripts/mlinux-scripts.inc1
2 files changed, 115 insertions, 0 deletions
diff --git a/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-cell-fw b/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-cell-fw
new file mode 100755
index 0000000..a101e56
--- /dev/null
+++ b/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-cell-fw
@@ -0,0 +1,114 @@
+#!/bin/sh
+
+
+if [ $# -gt 2 ] || [ $# -lt 1 ]; then
+echo "\
+Usage: $0 <image_id> [timeout]
+ image_id <0|1> : for dual FW image SKU-s, the id of the image to switch to
+ (LTE910-NA1 is the only supported radio for now).
+ timeout : wait time for radio to come up if set (default : 15 sec)
+"
+ exit 1
+fi
+
+#
+# Load args (don't wait for the radio by default)
+#
+FWIMAGE=$1
+TIMEOUT=${2:-15}
+if [ "$VERBOSE" != "yes" ]; then
+ VERBOSE=""
+fi
+
+[ "$VERBOSE" ] && echo -n "Switching the radio firmware image: "
+
+#
+# Check if the radio present
+#
+MODEL=$(radio-query --model)
+if [ $? -ne 0 ]; then
+ [ "$VERBOSE" ] && echo "Assume no radio on this device."
+ exit 0
+fi
+
+#
+# Applicable for LTE910-NA1 with dual FW images only
+#
+if [ "$MODEL" != "LE910-NA1" ]; then
+ [ "$VERBOSE" ] && echo "Firmware switch is supported only on LE910-NA1 models."
+ exit 0
+fi
+
+#
+# Check if firmware switch is required
+#
+FWACTIVE=$(radio-query --active-firmware)
+if [ $? -ne 0 ] || [ "$FWACTIVE" == "" ]; then
+ [ "$VERBOSE" ] && echo "The $MODEL radio does not support firmware switching."
+ exit 0
+fi
+
+if [ "$FWACTIVE" == "$FWIMAGE" ]; then
+ [ "$VERBOSE" ] && echo "The radio firmware image is already set."
+ exit 0
+fi
+
+# Verizon does not want an APN, so remove first
+if ((FWIMAGE == 1)) ; then
+ /usr/sbin/mlinux-switch-apn $FWIMAGE
+fi
+
+
+#
+# Switch the firmware
+#
+RESULT=$(radio-cmd --set-active-firmware "$FWIMAGE")
+if [ $? -ne 0 ]; then
+ echo "$RESULT"
+ exit 1
+fi
+
+
+#
+# Exit if no TIMEOUT set
+#
+# This is somewhat dangerous in that we assume the radio
+# will switch.
+if ((TIMEOUT == 0)) ; then
+ if ((FWIMAGE == 0)) ; then
+ echo "Use mlinux-switch-apn to switch the APN when the radio is ready, before dialing"
+ exit 0
+ fi
+fi
+
+#
+# Wait for the radio to be ready before continuing
+#
+COUNTER=0
+
+[ "$VERBOSE" ] && echo -n "Wait..."
+
+#
+# Give it some time
+#
+sleep 5
+
+while [ $COUNTER -lt $TIMEOUT ]; do
+ MODEL=$(radio-query --model)
+ if [ $? -eq 0 ]; then
+ echo "Cellular radio firmware has been switched to $FWIMAGE image."
+ ((FWIMAGE == 0)) && /usr/sbin/mlinux-switch-apn $FWIMAGE
+ exit 0
+ fi
+
+ let COUNTER=COUNTER+1
+
+ [ "$VERBOSE" ] && echo -n "."
+
+ sleep 1
+done
+
+echo "Cellular radio is not ready."
+echo "When it becomes ready, invoke /usr/sbin/mlinux-switch-apn"
+echo "to set the APN"
+exit 1
diff --git a/recipes-core/mlinux-scripts/mlinux-scripts.inc b/recipes-core/mlinux-scripts/mlinux-scripts.inc
index e7f4b94..f0320bf 100644
--- a/recipes-core/mlinux-scripts/mlinux-scripts.inc
+++ b/recipes-core/mlinux-scripts/mlinux-scripts.inc
@@ -20,6 +20,7 @@ do_install() {
install -m 755 ${WORKDIR}/mlinux-dhcpd ${D}${sbindir}
install -m 755 ${WORKDIR}/mlinux-set-apn ${D}${sbindir}
install -m 755 ${WORKDIR}/mlinux-switch-apn ${D}${sbindir}
+ install -m 755 ${WORKDIR}/mlinux-switch-cell-fw ${D}${sbindir}
install -m 755 ${WORKDIR}/mlinux-cell-router ${D}${sbindir}
install -m 755 ${WORKDIR}/mlinux-firmware-upgrade ${D}${sbindir}
}