blob: 861532b5e549f958394fabb8345205c2d35f0c2c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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
|