Skip to content

Commit

Permalink
Merge branch 'main' into feature/fix-emulator-bug-seg-fault
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasrenman authored Jun 30, 2024
2 parents 3b9cef0 + 84fdd30 commit f910ef0
Show file tree
Hide file tree
Showing 168 changed files with 3,418 additions and 837 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ FROM --platform=linux/x86_64 mcr.microsoft.com/devcontainers/base:ubuntu

RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get -y install --no-install-recommends cmake build-essential ninja-build
apt-get -y install --no-install-recommends cmake build-essential ninja-build libsdl2-dev
6 changes: 3 additions & 3 deletions .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true

Expand All @@ -21,13 +21,13 @@ jobs:
run: echo "firmware_name=$(basename out/*bin)" >> $GITHUB_ENV

- name: Upload Firmware Package
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ env.firmware_name }}
path: out/${{ env.firmware_name }}

- name: Upload Firmware Binary
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: HDZGOGGLE
path: out/HDZGOGGLE
Expand Down
14 changes: 12 additions & 2 deletions lib/log/src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <stdatomic.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>

#define get_filename(file) (strrchr(file, '/') ? strrchr(file, '/') + 1 : file)
Expand Down Expand Up @@ -78,10 +79,19 @@ int log_printf(const char *file, const char *func, int line, const int level, co
va_end(args2);
static char buffer[1024];

int bytes =
// Timestamp
struct timeval now;
gettimeofday(&now, NULL);
int milli = now.tv_usec / 1000;
char timestamp[sizeof "YYYY-MM-DD HH:MM:SS.sss"];
int bytes = strftime(timestamp, sizeof timestamp, "%F %T.", gmtime(&now.tv_sec));
snprintf(&timestamp[bytes], sizeof(timestamp) - bytes, "%03d", milli);

bytes =
snprintf(buffer,
sizeof(buffer),
"[%s][%s:%s:%d] %s\r\n",
"%s [%s][%s:%s:%d] %s\r\n",
timestamp,
log_level_names[level + 2],
get_filename(file),
func,
Expand Down
Binary file modified mkapp/app/resource/OSD/FC/ARDU_000.bmp
Binary file not shown.
Binary file modified mkapp/app/resource/OSD/FC/ARDU_FHD_000.bmp
Binary file not shown.
Binary file added mkapp/app/resource/OSD/GOGGLE/alert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 101 additions & 0 deletions mkapp/app/script/online_downloader.sh
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
59 changes: 31 additions & 28 deletions mkapp/app/script/update_goggle.sh
Original file line number Diff line number Diff line change
@@ -1,63 +1,61 @@
#!/bin/sh

GOGGLE_BIN="$1"
TMP_DIR=/tmp/goggle_update

function gpio_export()
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
echo "228">/sys/class/gpio/export
echo "out">/sys/class/gpio/gpio228/direction
fi

if [ ! -f /sys/class/gpio/gpio258/direction ]
then
echo "258">/sys/class/gpio/export
echo "out">/sys/class/gpio/gpio258/direction
fi
echo "258">/sys/class/gpio/export
echo "out">/sys/class/gpio/gpio258/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
}


function disconnect_fpga_flash()
disconnect_fpga_flash()
{
echo "1">/sys/class/gpio/gpio258/value
}

function connect_fpga_flash()
connect_fpga_flash()
{
echo "0">/sys/class/gpio/gpio258/value
}


FILE_TARGET=/mnt/extsd/HDZERO_GOGGLE*.bin
TMP_DIR=/tmp/goggle_update

function untar_fils()
untar_file()
{
FILE_TARGET="$1"

if [ ! -e ${TMP_DIR} ]
then
mkdir ${TMP_DIR}
Expand All @@ -71,10 +69,8 @@ function untar_fils()
mv ${TMP_DIR}/HDZGOGGLE_VA*.bin ${TMP_DIR}/HDZGOGGLE_VA.bin
}


function update_rx()
update_rx()
{

echo "find RX update file, start update"
filesize=`ls -l ${TMP_DIR}/HDZGOGGLE_RX*.bin| awk '{print $5}'`
gpio_export
Expand All @@ -85,15 +81,14 @@ function update_rx()
mtd_debug write /dev/mtd8 0 $filesize ${TMP_DIR}/HDZGOGGLE_RX.bin
mtd_debug erase /dev/mtd9 0 65536
mtd_debug write /dev/mtd9 0 $filesize ${TMP_DIR}/HDZGOGGLE_RX.bin


echo "update finish RX, running"
gpio_clear_reset
sleep 1
rmmod /mnt/app/ko/w25q128.ko
}

function update_fpga()
update_fpga()
{
echo "find VA update file, start update"
filesize2=`ls -l ${TMP_DIR}/HDZGOGGLE_VA*.bin| awk '{print $5}'`
Expand All @@ -110,12 +105,20 @@ function update_fpga()
rmmod /mnt/app/ko/w25q128.ko
}

# If firmware file was NOT supplied then default to primary location for emergency restore
if [ -z "$GOGGLE_BIN" ]; then
if [ `ls /mnt/extsd/HDZERO_GOGGLE*.bin | grep bin | wc -l` -eq 1 ]
then
GOGGLE_BIN="/mnt/extsd/HDZERO_GOGGLE*.bin"
fi
fi

if [ `ls /mnt/extsd/HDZERO_GOGGLE*.bin |grep bin |wc -l` == "1" ]
if [ ! -z "$GOGGLE_BIN" ]
then
echo "Flashing $GOGGLE_BIN"
echo "0" > /tmp/progress_goggle
echo "0"
untar_fils
untar_file "$GOGGLE_BIN"
mv ${TMP_DIR}/hdzgoggle_app_ota*.tar ${TMP_DIR}/hdzgoggle_app_ota.tar
cp -f /mnt/app/setting.ini /mnt/UDISK/
#disable it66021
Expand All @@ -130,12 +133,12 @@ then
echo "100"
echo "100" > /tmp/progress_goggle
echo "all done"

else
if [ `ls /mnt/extsd/HDZERO_GOGGLE*.bin |grep bin |wc -l` == "0" ]
if [ `ls /mnt/extsd/HDZERO_GOGGLE*.bin | grep bin | wc -l` -eq 0 ]
then
echo "skip"
echo "skip"
else
echo "repeat"
fi
fi

Loading

0 comments on commit f910ef0

Please sign in to comment.