summaryrefslogtreecommitdiff
path: root/recipes-core/mlinux-scripts
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2019-08-14 18:05:49 -0500
committerJohn Klug <john.klug@multitech.com>2019-08-14 18:05:49 -0500
commita4704d2afa37fe9d063a33dad83f1398cb924f40 (patch)
treeb6054b6da9cf970d5339ed7208a666aac30c39d6 /recipes-core/mlinux-scripts
parent1eea5c652209d93746318e80a48d178ffd2905ac (diff)
downloadmeta-mlinux-atmel-a4704d2afa37fe9d063a33dad83f1398cb924f40.tar.gz
meta-mlinux-atmel-a4704d2afa37fe9d063a33dad83f1398cb924f40.tar.bz2
meta-mlinux-atmel-a4704d2afa37fe9d063a33dad83f1398cb924f40.zip
Firmware switching for L4N1
Diffstat (limited to 'recipes-core/mlinux-scripts')
-rwxr-xr-xrecipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-switch-apn26
-rwxr-xr-xrecipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-switch-cell-fw128
2 files changed, 117 insertions, 37 deletions
diff --git a/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-switch-apn b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-switch-apn
index 689b0a4..be056eb 100755
--- a/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-switch-apn
+++ b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-switch-apn
@@ -23,6 +23,18 @@
MTMODEMS=(LNA3 L4N1)
MODEMS=(LE910-NA1 LE910C4-NF)
+function getactivefirmware
+{
+ /usr/bin/radio-query ${RADIOOPTION} --active-firmware
+# FW=$(/usr/bin/radio-cmd ${RADIOOPTION} 'AT#FWSWITCH?' 2>/dev/null)
+# if (($? != 0)) ; then
+# >&2 echo "FW Query failed"
+# return 1
+# fi
+# [[ $FW =~ \#FWSWITCH:[[:space:]]*([^,]*) ]]
+# echo "${BASH_REMATCH[1]}"
+}
+
# See if string is in array of strings
# parm 1 String
# parm 2 Arrays of strings
@@ -118,8 +130,14 @@ else
>&2 echo Try again later
exit 1
fi
- MODEL=$(radio-query --model)
- if (($? != 0)) ; then
+ MODEL=$(radio-query ${RADIOOPTION} --model 2>&1)
+ result=$?
+ if [[ $MODEL =~ [Ee][Rr][Rr][Oo][Rr] ]] ; then
+ RADIOOPTION="${RADIOOPTION2}"
+ MODEL=$(radio-query ${RADIOOPTION} --model 2>&1)
+ result=$?
+ fi
+ if ((result != 0)) ; then
>&2echo "No radio on this device."
usage
exit 1
@@ -130,11 +148,11 @@ else
fi
if fwreply=$(/usr/sbin/mlinux-switch-cell-fw -1); then
- if [[ $fwreply =~ Cellular[[:space:]]+radio[[:space:]]+firmware[[:space:]]+has[[:space:]]+(already[[:space:]]+)been[[:space:]]+switched[[:space:]]+to[[:space:]]+([^[:space:]]*)[[:space:]]+image\. ]] ; then
+ if [[ $fwreply =~ Cellular[[:space:]]+radio[[:space:]]+firmware[[:space:]]+has[[:space:]]+(already[[:space:]]+)*been[[:space:]]+switched[[:space:]]+to[[:space:]]+([^[:space:]]*)[[:space:]]+image\. ]] ; then
fw=${BASH_REMATCH[2]}
setchat "${mymtmodem}" $fw 0
else
- fw=$(radio-query --active-firmware)
+ fw=$(getactivefirmware)
if (($? == 0)) ; then
setchat "${mymtmodem}" $fw 0
fi
diff --git a/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-switch-cell-fw b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-switch-cell-fw
index 9edacac..4065ccb 100755
--- a/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-switch-cell-fw
+++ b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-switch-cell-fw
@@ -1,11 +1,53 @@
#!/bin/bash
-lna3_chat_link=/etc/ppp/peers/lna3_chat
-lna3_readme=/etc/ppp/peers/README.lna3
+# This script assumes Verizon SIMS ICCID start with 89148 and is firmware 1.
+# This script assumes T-Mobile SIMS start with 8901260 and is firmware 2.
+
+fwsw_modems=(LE910-NA1 LE910C4-NF)
+mt_modems=(lna3 l4n1)
+readme=/etc/ppp/peers/README.fwswitch
+function setactivefirmware
+{
+ radio-cmd ${RADIOOPTION} --set-active-firmware $1
+# RESULT=$(radio-cmd ${RADIOOPTION} 'AT#FWSWITCH='$1',1' 2>&1)
+# if (($? != 0)) ; then
+# >&2 echo "FW Set failed"
+# return 1
+# fi
+# if [[ $RESULT =~ [Ee][Rr][Rr][Oo][Rr] ]] ; then
+# >&2 echo "FW Set failed"
+# return 1
+# fi
+}
+
+function getactivefirmware
+{
+ /usr/bin/radio-query ${RADIOOPTION} --active-firmware
+# FW=$(/usr/bin/radio-cmd ${RADIOOPTION} 'AT#FWSWITCH?' 2>/dev/null)
+# if (($? != 0)) ; then
+# >&2 echo "FW Query failed"
+# return 1
+# fi
+# [[ $FW =~ \#FWSWITCH:[[:space:]]*([^,]*) ]]
+# echo "${BASH_REMATCH[1]}"
+}
+
+# See if string is in array of strings
+# parm 1 String
+# parm 2 Arrays of strings
+function findItem {
+ local s check="$1"
+ shift
+ for s ; do
+ [[ "$s" == "$check" ]] && return 0;
+ done
+ return 1
+}
+
+
function usage {
->&2 echo "\
+>&2 echo "
Usage: $0 <image_id> [timeout]
- image_id <0|1|-1> : for dual FW image SKU-s, the id of the image to switch to
- (LTE910-NA1 is the only supported radio for now).
+ image_id <0|1|2|-1> : for dual FW image SKU-s, the id of the image to switch to
-1 is based on SIM
timeout : wait time for radio to come up if set (default : 15 sec)
@@ -18,10 +60,26 @@ if [ $# -gt 2 ] ; then
fi
#
+# Check if the radio present
+#
+MODEL=$(radio-query ${RADIOOPTION} --model 2>&1)
+result=$?
+if [[ $MCONTEXT =~ [Ee][Rr][Rr][Oo][Rr] ]] ; then
+ RADIOOPTION="${RADIOOPTION2}"
+ MODEL=$(radio-query ${RADIOOPTION} --model 2>&1)
+ result=$?
+fi
+
+if ((result != 0)) ; then
+ [ "$VERBOSE" ] && >&2 echo "Assume no radio on this device."
+ exit 0
+fi
+
+#
# Load args (don't wait for the radio by default)
#
FWIMAGE=$1
-if ((FWIMAGE < -2)) || ((FWIMAGE > 1)) ; then
+if ((FWIMAGE < -2)) || ((FWIMAGE > 2)) ; then
usage
fi
if ! >&2 /usr/sbin/mlinux-cell-radio-ready ; then
@@ -30,16 +88,27 @@ if ! >&2 /usr/sbin/mlinux-cell-radio-ready ; then
exit 1
fi
if ((FWIMAGE == -1)) ; then
- iccid=$(radio-query --iccid)
+ iccid=$(radio-query ${RADIOOPTION} --iccid)
if (($? == 0)); then
if ((${#iccid} == 0)) ; then
[ "$VERBOSE" ] && >&2 echo "No carrier. Maybe no SIM?"
[ "$VERBOSE" ] && >&2 echo "ERROR: Cannot decide on firmware"
exit 1
fi
- if [[ "$iccid" =~ ^89148.* ]] ; then
+ if [[ $iccid =~ ^89148.* ]] ; then
+ # Verizon
+ logger -s -t mlinux-sw-firmware -p daemon.info "Assuming $iccid is a Verizon SIM ICCID using Firmware 1"
((FWIMAGE=1))
+ elif [[ $iccid =~ ^8901260.* ]] ; then
+ # T-Mobile
+ logger -s -t mlinux-sw-firmware -p daemon.info "Assuming $iccid is a T-Mobile SIM ICCID using Firmware 2"
+ ((FWMAGE=2))
+ if [[ $MODEL == LE910-NA1 ]] ; then # Assume LNA3 has no firmware image 2
+ ((FWIMAGE=0))
+ fi
else
+ # Everybody else
+ logger -s -t mlinux-sw-firmware -p daemon.info "Assuming $iccid is a possibly AT&T SIM using Firmware 0"
((FWIMAGE=0))
fi
else
@@ -58,47 +127,40 @@ fi
[ "$VERBOSE" ] && >&2 echo -n "Switching the radio firmware image: "
#
-# Check if the radio present
+# Applicable for LTE910-NA1 and LE910C4-NF with dual FW images only
#
-MODEL=$(radio-query --model)
-if [ $? -ne 0 ]; then
- [ "$VERBOSE" ] && >&2 echo "Assume no radio on this device."
- exit 0
-fi
-
-#
-# Applicable for LTE910-NA1 with dual FW images only
-#
-productid=$(/usr/sbin/mts-io-sysfs show product-id)
-if [[ $MODEL != LE910-NA1 ]] || ! [[ $productid =~ -LNA3- ]] ; then
- [ "$VERBOSE" ] && >&2 echo "Firmware switch is supported only on LE910-NA1 models with product-id containing -LNA3-."
- exit 0
+if ! findItem "$MODEL" "${fwsw_modems[@]}" ; then
+ echo "Firmware switch is not supported on ${MODEL}."
+ exit 1
fi
#
# Check if firmware switch is required
#
-FWACTIVE=$(radio-query --active-firmware)
+FWACTIVE=$(getactivefirmware)
if [ $? -ne 0 ] || [ "$FWACTIVE" == "" ]; then
- [ "$VERBOSE" ] && >&2 echo "The $MODEL radio does not support firmware switching."
- exit 0
+ [ "$VERBOSE" ] && >&2 echo "The $MODEL radio does not support firmware switching."
+ exit 0
fi
if (( FWACTIVE == FWIMAGE )); then
- echo "Cellular radio firmware has already been switched to $FWIMAGE image."
- exit 0
+ echo "Cellular radio firmware has already been switched to $FWIMAGE image."
+ exit 0
fi
# Disable the LNA3 chat script in case of failure.
-if ! [[ -L $lna3_chat_link ]] || [[ $(basename $(readlink -f $lna3_chat_link)) != README.lna3 ]] ; then
- ln -sf "${lna3_readme}" "${lna3_chat_link}"
- echo "Chat script is now disabled."
-fi
+for f in $mt_modems ; do
+ linkf=/etc/ppp/peers/${f}_chat
+ if ! [[ -L ${linkf} ]] || [[ $(basename $(readlink -f ${linkf})) != ${readme} ]] ; then
+ ln -sf "${readme}" "${linkf}"
+ echo "Chat script is now disabled."
+ fi
+done
#
# Switch the firmware
#
-RESULT=$(radio-cmd --set-active-firmware "$FWIMAGE")
+RESULT=$(setactivefirmware "$FWIMAGE")
if [ $? -ne 0 ]; then
[ "$VERBOSE" ] && >&2 echo "$RESULT"
exit 1
@@ -130,7 +192,7 @@ COUNTER=0
sleep 5
while [ $COUNTER -lt $TIMEOUT ]; do
- MODEL=$(radio-query --model)
+ MODEL=$(radio-query ${RADIOOPTION} --model)
if [ $? -eq 0 ]; then
echo "Cellular radio firmware has been switched to $FWIMAGE image."
exit 0