-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pluto-sdr: enable easy updating of firmware from github
When plutosdr is on the internet (via a USB<->Ethernet dongle), it can talk directly to github, and automagically update to the latest firmware. Signed-off-by: Robin Getz <[email protected]>
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/sh | ||
|
||
cd /root | ||
rm -f /root/latest /root/*.zip /root/*.frm | ||
|
||
# get the location of the latest release | ||
wget https://api.github.com/repos/analogdevicesinc/plutosdr-fw/releases/latest | ||
if [ "$?" -ne "0" ] ; then | ||
echo "Error talking to github - is this pluto on the internet?" | ||
exit | ||
fi | ||
if [ ! -f "latest" ] ; then | ||
echo "downloaded file missing" | ||
exit | ||
fi | ||
# get the FIRMWARE file name | ||
FIRMWARE=$(grep "name.*plutosdr-fw-" latest | cut -d : -f 2,3 | tr -d \", | sed 's/^ //g') | ||
if [ -z "${FIRMWARE}" ] ; then | ||
echo "Error parsing download file name - please report a bug" | ||
exit | ||
fi | ||
# get the FIRMWARE URL | ||
URL=$(grep "browser_download_url.*plutosdr-fw-" latest | cut -d : -f 2,3 | awk '{print $1}' | tr -d \") | ||
if [ -z "${URL}" ] ; then | ||
echo "Error parsing download url - please report a bug" | ||
exit | ||
fi | ||
# get the URL | ||
wget ${URL} | ||
if [ "$?" -ne "0" ] ; then | ||
echo "Error talking to github - is this pluto on the internet?" | ||
exit | ||
fi | ||
if [ ! -f "${FIRMWARE}" ] ; then | ||
echo "Can not find downloaded file - report a bug" | ||
exit | ||
fi | ||
# find the frm inside the zip file | ||
FILE=$(unzip -l "${FIRMWARE}" | grep frm | sort -nr | head -1 | awk '{print $NF}') | ||
if [ -z "${FILE}" ] ; then | ||
echo "not sure which file to extract - report a bug" | ||
exit | ||
fi | ||
# upzip it | ||
unzip ${FIRMWARE} ${FILE} | ||
if [ "$?" -ne "0" ] ; then | ||
echo "Error unzipping ${FILE} from ${FIRMWARE}" | ||
exit | ||
fi | ||
if [ ! -f ${FILE} ] ; then | ||
echo "Can not file file to write to flash" | ||
exit | ||
fi | ||
|
||
# write to flash | ||
update_frm.sh /root/${FILE} | ||
|
||
echo "Reboot your system to run the new firmware" |