summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2017-08-25 19:34:07 -0500
committerJohn Klug <john.klug@multitech.com>2017-08-25 19:34:07 -0500
commit71044a738cb70f9936500ff6ec8eb520c78a99c1 (patch)
tree5f8f51aadfac6144904db8dce84b79b0108a15f5
parent3c621a98ce76c16f6e6bed08c74044a3792095dc (diff)
downloadmeta-mlinux-71044a738cb70f9936500ff6ec8eb520c78a99c1.tar.gz
meta-mlinux-71044a738cb70f9936500ff6ec8eb520c78a99c1.tar.bz2
meta-mlinux-71044a738cb70f9936500ff6ec8eb520c78a99c1.zip
Initial integration of cell-radio-fwswitch
-rw-r--r--recipes-core/multitech/cell-radio-fwswitch/cell-radio-fwswitch.default2
-rw-r--r--recipes-core/multitech/cell-radio-fwswitch/cell-radio-fwswitch.init57
-rwxr-xr-xrecipes-core/multitech/cell-radio-fwswitch/cell-radio-fwswitch.sh98
-rw-r--r--recipes-core/multitech/cell-radio-fwswitch_1.0.bb34
4 files changed, 191 insertions, 0 deletions
diff --git a/recipes-core/multitech/cell-radio-fwswitch/cell-radio-fwswitch.default b/recipes-core/multitech/cell-radio-fwswitch/cell-radio-fwswitch.default
new file mode 100644
index 0000000..a19e18e
--- /dev/null
+++ b/recipes-core/multitech/cell-radio-fwswitch/cell-radio-fwswitch.default
@@ -0,0 +1,2 @@
+# set to "yes" to enable cell-radio-fwswitch on boot
+ENABLED="no"
diff --git a/recipes-core/multitech/cell-radio-fwswitch/cell-radio-fwswitch.init b/recipes-core/multitech/cell-radio-fwswitch/cell-radio-fwswitch.init
new file mode 100644
index 0000000..82b5cb5
--- /dev/null
+++ b/recipes-core/multitech/cell-radio-fwswitch/cell-radio-fwswitch.init
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+# no firmware switch by default
+ENABLED="no"
+# radio come up timeout
+TIMEOUT=15
+# default radio firmware image id
+FWIMAGE="0"
+
+[ -r /etc/default/cell-radio-fwswitch ] && source /etc/default/cell-radio-fwswitch
+[ "$ENABLED" == "yes" ] || exit 0
+
+function start() {
+ FWACTIVE=$(radio-query --active-firmware)
+ if [[ $? != 0 || x"$FWACTIVE" == x"" ]]; then
+ # radio does not support firmware switching.
+ exit 0
+ fi
+
+ FWSWITCH=$(curl -s 127.0.0.1/api/ppp/modem/fwSwitch | jsparser -p /result/)
+ if [[ x"$FWSWITCH" == x"" ]]; then
+ echo "Failed to obtain the radio firmware image id to use."
+ exit 1
+ fi
+
+ if [[ "$FWSWITCH" == "att" ]]; then
+ FWIMAGE="0"
+ elif [[ "$FWSWITCH" == "vz" ]]; then
+ FWIMAGE="1"
+ else
+ # autodetect
+ ICCID=$(radio-query --iccid)
+ if [ $? -ne 0 ]; then
+ exit 0
+ fi
+ if [[ "$ICCID" =~ ^89148.* ]]; then
+ #
+ # Switch to FW image #1 for Verizon SIMs
+ #
+ FWIMAGE="1"
+ fi
+ fi
+
+ cell-radio-fwswitch $FWIMAGE $TIMEOUT
+}
+
+case $1 in
+ start)
+ start
+ ;;
+
+ *)
+ echo "Usage: $0 {start}"
+ exit 2
+ ;;
+esac
+
diff --git a/recipes-core/multitech/cell-radio-fwswitch/cell-radio-fwswitch.sh b/recipes-core/multitech/cell-radio-fwswitch/cell-radio-fwswitch.sh
new file mode 100755
index 0000000..861532b
--- /dev/null
+++ b/recipes-core/multitech/cell-radio-fwswitch/cell-radio-fwswitch.sh
@@ -0,0 +1,98 @@
+#!/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
+
+#
+# Switch the firmware
+#
+RESULT=$(radio-cmd --set-active-firmware "$FWIMAGE")
+if [ $? -ne 0 ]; then
+ echo "$RESULT"
+ exit 1
+fi
+
+
+#
+# Exit if no TIMEOUT set
+#
+[ $TIMEOUT -eq 0 ] && exit 0
+
+#
+# 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."
+ exit 0
+ fi
+
+ let COUNTER=COUNTER+1
+
+ [ "$VERBOSE" ] && echo -n "."
+
+ sleep 1
+done
+
+echo "Cellular radio is not ready."
+exit 1
diff --git a/recipes-core/multitech/cell-radio-fwswitch_1.0.bb b/recipes-core/multitech/cell-radio-fwswitch_1.0.bb
new file mode 100644
index 0000000..8c19029
--- /dev/null
+++ b/recipes-core/multitech/cell-radio-fwswitch_1.0.bb
@@ -0,0 +1,34 @@
+DESCRIPTION = "Radio firmware switching functionality for dual image units (only LNA3 radios for now)"
+SECTION = "base"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+PR = "r1"
+
+RDEPENDS_${PN} = "radio-query radio-cmd"
+
+inherit update-rc.d
+
+INITSCRIPT_NAME = "cell-radio-fwswitch"
+INITSCRIPT_PARAMS = "start 63 5 ."
+
+SRC_URI = "\
+ file://cell-radio-fwswitch.default \
+ file://cell-radio-fwswitch.init \
+ file://cell-radio-fwswitch.sh \
+"
+
+do_install () {
+ install -d ${D}${sysconfdir}/init.d
+ install -m 0755 ${WORKDIR}/cell-radio-fwswitch.init ${D}${sysconfdir}/init.d/cell-radio-fwswitch
+
+ install -d ${D}${sysconfdir}/default
+ install -m 0644 ${WORKDIR}/cell-radio-fwswitch.default ${D}${sysconfdir}/default/cell-radio-fwswitch
+
+ install -d ${D}${sbindir}
+ install -m 0755 ${WORKDIR}/cell-radio-fwswitch.sh ${D}${sbindir}/cell-radio-fwswitch
+}
+
+do_install_append_mtcap() {
+ # enable cell-radio-fwswitch init script on boot for MTCAP
+ sed -i 's/ENABLED="no"/ENABLED="yes"/g' ${D}${sysconfdir}/default/cell-radio-fwswitch
+}