forked from AndyTaylorTweet/Pi-Star_Binaries_sbin
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpistar-mmdvmhshatflash
executable file
·158 lines (155 loc) · 7.09 KB
/
pistar-mmdvmhshatflash
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
#
###############################################################################
# #
# Pi-Star Firmware Update Tool #
# #
# Version 1.0, Code, Design and Development by Andy Taylor (MW0MWZ). #
# #
# Make it simple to update the Firmware #
# #
###############################################################################
#
if [ "$(id -u)" != "0" ]; then
echo -e "You need to be root to run this command...\n"
exit 1
fi
#
# Output some usefull information when no variables are passed
#
if [ -z "$1" ]
then
echo "This tool is used to flash your MMDVM_HS Hat Modem"
echo "to use the command, you will need to pass the name of your modem,"
echo "please choose form the list below..."
echo ""
echo "To flash HS_HAT (14.7456MHz TCXO) connected to GPIO, run: pistar-mmdvmhshatflash hs_hat"
echo "To flash HS_HAT (12.2880MHz TCXO) connected to GPIO, run: pistar-mmdvmhshatflash hs_hat-12mhz"
echo "To flash HS_DUAL_HAT (14.7456MHz TCXO) connected to GPIO, run: pistar-mmdvmhshatflash hs_dual_hat"
echo "To flash HS_DUAL_HAT (12.2880MHz TCXO) connected to GPIO, run: pistar-mmdvmhshatflash hs_dual_hat-12mhz"
echo "To flash HS_HAT_AMBE (14.7456MHz TCXO) connected to GPIO, run: pistar-mmdvmhshatflash hs_hat_ambe"
echo ""
echo "To flash ZumSPOT devices by please use pistar-zumspotflash"
echo "To flash MMDVM_HS Nano Hat devices please use pistar-vyehsflash"
echo "To flash your BD7KLE/BG3MDO devices please use pistar-mdoflash"
echo ""
# Get the pretty name for the chosen Modem according to the dashboard.
if [ -f '/etc/dstar-radio.mmdvmhost' ]; then
# Get the modem that the user has selected.
modemSelected=$(grep 'Hardware=' /etc/dstar-radio.mmdvmhost)
modemSelected=${modemSelected#*=}
# Get the user friendly version of the selected Modem.
modemSelectedHuman=$(grep value=\"${modemSelected}\" /var/www/dashboard/admin/configure.php | head -n 1)
modemSelectedHuman=${modemSelectedHuman#*\">}
modemSelectedHuman=${modemSelectedHuman::-9}
echo "Selected Modem: ${modemSelectedHuman}"
fi
# Get the Modem info from the Log
numLogs=$(ls -1rt /var/log/pi-star/MMDVM-*.log | wc -l)
if [[ ${numLogs} -gt 0 ]]; then
# Get the physically connected modem from the logs
modemLog=$(tac $(ls -1rt /var/log/pi-star/MMDVM-*.log | tail -n1 ) | grep "protocol" -m 1 | sed -n 's/description: /&\n/;s/.*\n//p')
echo "Connected Hardware: ${modemLog}"
# Get the TCXO data
if [[ ${modemLog} == *"MHz"* ]]; then
tcxoData=$(echo ${modemLog} | awk '{print $3}')
echo "TCXO Value: ${tcxoData}"
fi
fi
exit 0
fi
#
# OK we know what the modem is, let get the firmware string from the log...
#
tac $(ls -1rt /var/log/pi-star/MMDVM-*.log | tail -n1 ) | grep "protocol" -m 1 | sed -n 's/description: /&\n/;s/.*\n//p'
read -n 1 -s -r -p "Press any key to write the ${1} firmware to this modem or Ctrl-C to quit..."
echo ""
#
# Download the correct firmware
#
if [ "$1" ]
then
case ${1} in
hs_hat)
# Flashing MMDVM_HS Hat Modem
rm -rf /tmp/mmdvmhshatfirmware 2> /dev/null
mkdir /tmp/mmdvmhshatfirmware 2> /dev/null
echo "Flashing your ${1} modem to the latest version"
curl -s -L https://github.com/juribeparada/MMDVM_HS/releases/latest | egrep -o '/juribeparada/MMDVM_HS/releases/download/v[0-9.]*/install_fw_hshat.sh' | wget --base=http://github.com/ -i - -O /tmp/mmdvmhshatfirmware/flash.sh
chmod +x /tmp/mmdvmhshatfirmware/flash.sh
cd /tmp/mmdvmhshatfirmware
./flash.sh
echo ""
rm -rf /tmp/mmdvmhshatfirmware 2> /dev/null
read -n 1 -s -r -p "Flashing your ${1} modem complete, press any key to reboot your Pi-Star System..."
shutdown -r now
exit 0
;;
hs_hat-12mhz)
# Flashing MMDVM_HS Hat Modem with 12.288 MHz TCXO
rm -rf /tmp/mmdvmhshatfirmware 2> /dev/null
mkdir /tmp/mmdvmhshatfirmware 2> /dev/null
echo "Flashing your ${1} modem to the latest version"
curl -s -L https://github.com/juribeparada/MMDVM_HS/releases/latest | egrep -o '/juribeparada/MMDVM_HS/releases/download/v[0-9.]*/install_fw_hshat-12mhz.sh' | wget --base=http://github.com/ -i - -O /tmp/mmdvmhshatfirmware/flash.sh
chmod +x /tmp/mmdvmhshatfirmware/flash.sh
cd /tmp/mmdvmhshatfirmware
./flash.sh
echo ""
rm -rf /tmp/mmdvmhshatfirmware 2> /dev/null
read -n 1 -s -r -p "Flashing your ${1} modem complete, press any key to reboot your Pi-Star System..."
shutdown -r now
exit 0
;;
hs_dual_hat)
# Flashing MMDVM_HS_DUAL Modem
rm -rf /tmp/mmdvmhshatfirmware 2> /dev/null
mkdir /tmp/mmdvmhshatfirmware 2> /dev/null
echo "Flashing your ${1} modem to the latest version"
curl -s -L https://github.com/juribeparada/MMDVM_HS/releases/latest | egrep -o '/juribeparada/MMDVM_HS/releases/download/v[0-9.]*/install_fw_hsdualhat.sh' | wget --base=http://github.com/ -i - -O /tmp/mmdvmhshatfirmware/flash.sh
chmod +x /tmp/mmdvmhshatfirmware/flash.sh
cd /tmp/mmdvmhshatfirmware
./flash.sh
echo ""
rm -rf /tmp/mmdvmhshatfirmware 2> /dev/null
read -n 1 -s -r -p "Flashing your ${1} modem complete, press any key to reboot your Pi-Star System..."
shutdown -r now
exit 0
;;
hs_dual_hat-12mhz)
# Flashing MMDVM_HS_DUAL Modem with 12.288 MHz TCXO
rm -rf /tmp/mmdvmhshatfirmware 2> /dev/null
mkdir /tmp/mmdvmhshatfirmware 2> /dev/null
echo "Flashing your ${1} modem to the latest version"
curl -s -L https://github.com/juribeparada/MMDVM_HS/releases/latest | egrep -o '/juribeparada/MMDVM_HS/releases/download/v[0-9.]*/install_fw_hsdualhat-12mhz.sh' | wget --base=http://github.com/ -i - -O /tmp/mmdvmhshatfirmware/flash.sh
chmod +x /tmp/mmdvmhshatfirmware/flash.sh
cd /tmp/mmdvmhshatfirmware
./flash.sh
echo ""
rm -rf /tmp/mmdvmhshatfirmware 2> /dev/null
read -n 1 -s -r -p "Flashing your ${1} modem complete, press any key to reboot your Pi-Star System..."
shutdown -r now
exit 0
;;
hs_hat_ambe)
# Flashing MMDVM_HS Hat Modem
rm -rf /tmp/mmdvmhshatfirmware 2> /dev/null
mkdir /tmp/mmdvmhshatfirmware 2> /dev/null
echo "Flashing your ${1} modem to the latest version"
curl -s -L https://github.com/juribeparada/MMDVM_HS/releases/latest | egrep -o '/juribeparada/MMDVM_HS/releases/download/v[0-9.]*/install_fw_d2rg_mmdvmhs.sh' | wget --base=http://github.com/ -i - -O /tmp/mmdvmhshatfirmware/flash.sh
chmod +x /tmp/mmdvmhshatfirmware/flash.sh
cd /tmp/mmdvmhshatfirmware
./flash.sh
echo ""
rm -rf /tmp/mmdvmhshatfirmware 2> /dev/null
read -n 1 -s -r -p "Flashing your ${1} modem complete, press any key to reboot your Pi-Star System..."
shutdown -r now
exit 0
;;
*)
# Un-recognised modem choice
echo "Your Choice of ${1} modem is not supported by this update tool"
exit 1
;;
esac
fi
exit 0