forked from hd-zero/hdzero-goggle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request hd-zero#346 from SumolX/online_update_pr
Online Firmware Downloader (Goggle & VTX)
- Loading branch information
Showing
40 changed files
with
1,079 additions
and
242 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,101 @@ | ||
#!/bin/sh | ||
|
||
version_gt() { test "$(echo "$@" | tr " " "\n" | sort -g | head -n 1)" != "$1"; } | ||
version_le() { test "$(echo "$@" | tr " " "\n" | sort -g | head -n 1)" == "$1"; } | ||
version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rg | head -n 1)" != "$1"; } | ||
version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rg | head -n 1)" == "$1"; } | ||
|
||
download() { | ||
dst_path="$1" | ||
fw_links="$2" | ||
fw_sizes="$3" | ||
fw_notes="$4" | ||
fw_total=1 | ||
fw_counter=1 | ||
|
||
# Do we have a SD Card mounted? | ||
if [ ! -z "$(mount | grep /mnt/extsd)" ]; then | ||
dst_path="/mnt/extsd/FIRMWARE/$dst_path" | ||
else | ||
dst_path="/tmp/FIRMWARE/$dst_path" | ||
fi | ||
|
||
# Check if we need to download? | ||
if test -f $dst_path/release.notes; then | ||
echo "Local storage contains latest release!" | ||
return 0 | ||
fi | ||
|
||
# Blindly create directory, errors checking handled below. | ||
mkdir -p $dst_path 2> /dev/null | ||
|
||
# The real download work is performed here! | ||
for link in $fw_links; do | ||
file="$(basename "$link")" | ||
target="$dst_path/$file" | ||
if test -f "$target"; then | ||
current_size=$(wc -c < "$target") | ||
archive_size=$(echo $fw_sizes | cut -d" " -f$fw_counter) | ||
if [ $current_size -ne $archive_size ]; then | ||
echo "Resuming download: $target ...." | ||
curl -s -k -C $current_size -L $link -o "$target" && \ | ||
fw_total=$((fw_total + 1)) && \ | ||
echo "Resuming download: $target DONE!" | ||
else | ||
fw_total=$((fw_total + 1)) | ||
fi | ||
else | ||
echo "Downloading firmware: $target ...." | ||
curl -s -k -L $link -o "$target" && \ | ||
fw_total=$((fw_total + 1)) && \ | ||
echo "Downloading firmware: $target DONE!" | ||
fi | ||
fw_counter=$((fw_counter + 1)) | ||
done | ||
|
||
# Having release notes identify a successful download. | ||
if [ $fw_total -eq $fw_counter ]; then | ||
printf "$fw_notes" | tr -d '\r' > $dst_path/release.notes && \ | ||
echo "Completed downloading latest release!" | ||
fi | ||
} | ||
|
||
app_version_check() { | ||
if version_gt $1 $2; then | ||
echo "Goggle running older firmware!" | ||
return 0 | ||
else | ||
echo "Goggle running latest firmware!" | ||
return 1 | ||
fi | ||
} | ||
|
||
online_goggle_fw_check() { | ||
fw_info="/tmp/hdz_goggle_fw.latest" | ||
echo "Checking Goggle Releases" && \ | ||
curl -ks -o $fw_info https://api.github.com/repos/hd-zero/hdzero-goggle/releases/latest && \ | ||
fw_link=$(cat $fw_info | grep 'browser_' | cut -d\" -f4) && \ | ||
fw_note=$(cat $fw_info | grep 'body' | cut -d\" -f4) && \ | ||
fw_size=$(cat $fw_info | grep 'size' | cut -d\" -f4) && \ | ||
fw_file=$(basename $fw_link) && \ | ||
rversion="$(echo ${fw_file%%.bin} | cut -d "-" -f4)" && \ | ||
lversion="$(cat /mnt/app/version | cut -d "-" -f1)" && \ | ||
app_version_check $rversion $lversion && \ | ||
echo "Searching local storage for latest release..." && \ | ||
download "GOGGLE/$rversion" "$fw_link" "$fw_size" "$fw_note" | ||
} | ||
|
||
online_vtx_fw_check() { | ||
fw_info="/tmp/hdz_vtx_fw.latest" | ||
echo "Checking VTX Releases" && \ | ||
curl -ks -o $fw_info https://api.github.com/repos/hd-zero/hdzero-vtx/releases/latest && \ | ||
fw_links=$(cat $fw_info | grep 'browser_' | cut -d\" -f4) && \ | ||
fw_notes=$(cat $fw_info | grep 'body' | cut -d\" -f4) && \ | ||
fw_sizes=$(cat $fw_info | grep 'size' | cut -d: -f2 | cut -d, -f1) && \ | ||
rversion=$(cat $fw_info | grep 'tag_name' | cut -d\" -f4) && \ | ||
echo "Searching local storage for latest release..." && \ | ||
download "VTX/$rversion" "$fw_links" "$fw_sizes" "$fw_notes" | ||
} | ||
|
||
online_goggle_fw_check | ||
online_vtx_fw_check |
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 |
---|---|---|
@@ -1,59 +1,72 @@ | ||
#!/bin/sh | ||
|
||
function gpio_export() | ||
VTX_BIN="$1" | ||
|
||
gpio_export() | ||
{ | ||
if [ ! -f /sys/class/gpio/gpio224/direction ] | ||
then | ||
echo "224">/sys/class/gpio/export | ||
echo "out">/sys/class/gpio/gpio224/direction | ||
fi | ||
|
||
|
||
if [ ! -f /sys/class/gpio/gpio228/direction ] | ||
then | ||
echo "228">/sys/class/gpio/export | ||
echo "out">/sys/class/gpio/gpio228/direction | ||
fi | ||
} | ||
|
||
function gpio_set_reset() | ||
gpio_set_reset() | ||
{ | ||
echo "0">/sys/class/gpio/gpio224/value | ||
echo "1">/sys/class/gpio/gpio228/value | ||
} | ||
|
||
function gpio_clear_reset() | ||
gpio_clear_reset() | ||
{ | ||
echo "1">/sys/class/gpio/gpio224/value | ||
echo "0">/sys/class/gpio/gpio228/value | ||
} | ||
|
||
function gpio_set_send() | ||
gpio_set_send() | ||
{ | ||
echo "1">/sys/class/gpio/gpio224/value | ||
echo "0">/sys/class/gpio/gpio228/value | ||
} | ||
|
||
if [ -e /mnt/extsd/HDZERO_TX.bin ] | ||
then | ||
gpio_export | ||
gpio_set_send | ||
# If firmware file was NOT supplied then default to primary location for emergency restore | ||
if [ -z "$VTX_BIN" ]; then | ||
if [ `ls /mnt/extsd/HDZERO_TX.bin | grep bin | wc -l` -eq 1 ] | ||
then | ||
VTX_BIN="/mnt/extsd/HDZERO_TX.bin" | ||
fi | ||
fi | ||
|
||
if [ -e $VTX_BIN ] | ||
then | ||
echo "Flashing $VTX_BIN" | ||
gpio_export | ||
gpio_set_send | ||
insmod /mnt/app/ko/w25q128.ko | ||
valude=`mtd_debug info /dev/mtd8 | grep mtd.size | grep 1M` | ||
if [ "$valude" != "" ];then | ||
filesize=`ls -l /mnt/extsd/HDZERO_TX.bin| awk '{print $5}'` | ||
value=`mtd_debug info /dev/mtd8 | grep mtd.size | grep 1M` | ||
|
||
if [ ! -z "$value" ] | ||
then | ||
filesize=`ls -l $VTX_BIN | awk '{print $5}'` | ||
mtd_debug erase /dev/mtd8 0 65536 > /dev/null | ||
cp /mnt/extsd/HDZERO_TX.bin /tmp/. | ||
mtd_debug write /dev/mtd8 0 $filesize /mnt/extsd/HDZERO_TX.bin > /dev/null | ||
mtd_debug read /dev/mtd8 0 $filesize /tmp/HDZERO_TX_RB.bin > /dev/null | ||
cp $VTX_BIN /tmp/ | ||
mtd_debug write /dev/mtd8 0 $filesize $VTX_BIN > /dev/null | ||
mtd_debug read /dev/mtd8 0 $filesize /tmp/HDZERO_TX_RB.bin > /dev/null | ||
echo "all done" | ||
else | ||
echo "detect device failed" | ||
fi | ||
gpio_clear_reset | ||
fi | ||
|
||
gpio_clear_reset | ||
sleep 1 | ||
rmmod w25q128.ko | ||
rmmod w25q128.ko | ||
else | ||
echo "skip" | ||
fi | ||
echo "skip" | ||
fi | ||
|
Binary file not shown.
File renamed without changes.
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,3 @@ | ||
#!/bin/sh | ||
|
||
ln -sfn /mnt/app/services/bearssl/lib/libbearssl.so /lib/libbearssl.so |
File renamed without changes.
File renamed without changes.
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,3 @@ | ||
#!/bin/sh | ||
|
||
ln -sfn /mnt/app/services/tinycurl/curl /bin/curl |
Binary file not shown.
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
Oops, something went wrong.