Skip to content

Commit

Permalink
add h616 build command
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasVon2021 committed May 21, 2023
1 parent 9da3e7d commit 0c7312a
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 32 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
.DS_Store
*.bin
.vscode
32 changes: 22 additions & 10 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,36 @@ def main():
doArgParse()
sh_path = os.path.split(os.path.realpath(__file__))[0]
make_path = sh_path + '/src'
release_folder_path = sh_path + '/release'
if os.path.exists(release_folder_path):
os.system(f'rm -rf {release_folder_path}')
print("Release folder deleted.")

# build demo.bin
cmd = ""
cmd_make = ""
cmd_pack = "mkdir release && "
if gArgs.platform == "pi":
cmd += "make RPI=1 SSD1306=1"
cmd_make += "make RPI=1 SSD1306=1"
cmd_pack += "cp package/kvmd-web/binary/pi/* release/ && cp package/ustreamer/binary/pi/* release/ && "
elif gArgs.platform == "h616":
cmd += "make H616=1 ST7789=1"
cmd_make += "make H616=1 ST7789=1"
cmd_pack += "cp package/kvmd-web/binary/h616/* release/ && cp package/ustreamer/binary/h616/* release/ && "
else:
print("input error platform")
return
output = subprocess.check_output(cmd, shell = True, cwd=make_path )
print("command: ",cmd_make, " start to make")
output = subprocess.check_output(cmd_make, shell = True, cwd=make_path )
print("make success")

# package binary rm -rf release && rm -r release.tar.gz &&
cmd = "mkdir release && cp package/kvmd-hid/* release/ && cp package/kvmd-main/* release/ && \
cp package/kvmd-web/* release/ && cp package/ustreamer/* release/ && \
cp src/kvmd-main release/ && cp -R package/kvmd-msd/* release/ && \
cp src/config/package.json release/ && tar -zcvf release.tar.gz release && rm -rf release"
output = subprocess.check_output(cmd, shell = True, cwd=sh_path )
cmd_pack += "cp package/kvmd-hid/* release/ && cp package/kvmd-main/* release/ && \
find package/kvmd-web/ -maxdepth 1 -type f -exec cp {} release/ \; && \
find package/ustreamer/ -maxdepth 1 -type f -exec cp {} release/ \; && \
cp src/kvmd-main release/ && cp -R package/kvmd-msd/* release/ && \
cp src/config/package.json release/ && tar -zcvf release.tar.gz release && rm -rf release"

print("pack relase package, command: ", cmd_pack)
output = subprocess.check_output(cmd_pack, shell = True, cwd=sh_path )
print("pack success")

# modify package.json
file_path = sh_path + "/src/config/package.json"
Expand Down
Binary file added package/kvmd-web/binary/h616/kvm-link
Binary file not shown.
File renamed without changes.
Binary file added package/ustreamer/binary/h616/ustreamer.bin
Binary file not shown.
File renamed without changes.
54 changes: 51 additions & 3 deletions package/ustreamer/kvmd-video.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
#!/bin/bash

# Define board types
pi4b_board="Raspberry Pi 4 Model B"
cm4b_board="Raspberry Pi Compute Module 4"
h616_board="Mango Pi Mcore"

# Define board type values
v2_hat="V2_HAT"
v3_pcie="V3_PCIE"
v4_h616="V4_H616"
unknown="UNKNOWN"

# Function to execute command and get output
exec_cmd() {
output=$(eval "$1")
echo "$output"
}

# Function to get board type
get_board_type() {
# Check if the board is Raspberry Pi 4 Model B
if [[ $(exec_cmd "cat /proc/cpuinfo") == *"$pi4b_board"* ]] || [[ $(exec_cmd "cat /run/machine.id") == *"$pi4b_board"* ]]; then
type=$v2_hat
# Check if the board is Raspberry Pi Compute Module 4
elif [[ $(exec_cmd "cat /proc/cpuinfo") == *"$cm4b_board"* ]] || [[ $(exec_cmd "cat /run/machine.id") == *"$cm4b_board"* ]]; then
type=$v3_pcie
# Check if the board is Mango Pi Mcore
elif [[ $(exec_cmd "cat /proc/cpuinfo") == *"$h616_board"* ]] || [[ $(exec_cmd "cat /run/machine.id") == *"$h616_board"* ]]; then
type=$v4_h616
else
type=$unknown
fi
echo "$type"
}

str1="UP"
while (true)
do
Expand All @@ -13,6 +48,19 @@ do
echo "network not ok"
fi
done
v4l2-ctl --set-edid=file=/usr/bin/blikvm/edid.txt --fix-edid-checksums
v4l2-ctl --set-dv-bt-timings query
/usr/bin/blikvm/ustreamer.bin --device=/dev/video0 --persistent --dv-timings --format=uyvy --encoder=omx --workers=3 --quality=80 --desired-fps=30 --drop-same-frames=30 --last-as-blank=0 --h264-sink=demo::ustreamer::h264 &

# Call the function to get the board type
board_type=$(get_board_type)
echo "Board type: $board_type"

# Perform different actions based on the board type
if [[ "$board_type" == "$v2_hat" ]] || [[ "$board_type" == "$v3_pcie" ]]; then
v4l2-ctl --set-edid=file=/usr/bin/blikvm/edid.txt --fix-edid-checksums
v4l2-ctl --set-dv-bt-timings query
/usr/bin/blikvm/ustreamer.bin --device=/dev/video0 --persistent --dv-timings --format=uyvy --encoder=omx --workers=3 --quality=80 --desired-fps=30 --drop-same-frames=30 --last-as-blank=0 --h264-sink=demo::ustreamer::h264 &
elif [[ "$board_type" == "$v4_h616" ]]; then
/usr/bin/blikvm/ustreamer.bin --format=MJPEG --device=/dev/video1 --resolution=1920x1080 --host=0.0.0.0 --port=8008 &
else
echo "Unknown board type. No action performed."
fi

37 changes: 22 additions & 15 deletions script/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
cm4b_board = "Raspberry Pi Compute Module 4"
h616_board = "Mango Pi Mcore"

code_owner = "ThomasVon2021"
code_repo = "blikvm"
file_name = ""

class BoardType(Enum):
UNKNOWN = 0
V1_CM4 = 1
Expand Down Expand Up @@ -69,7 +73,6 @@ def download_release_file(owner, repo, tag_name, file_name, download_path):
print(f'Error getting release information: {response.content}')
return False
release_data = response.json()

# Find the file in the release assets
asset = next((a for a in release_data['assets'] if a['name'] == file_name), None)
if asset is None:
Expand Down Expand Up @@ -123,6 +126,7 @@ def main():
print("The latest release tag for blikvm is ", latest_version)
else:
print("Cannot find the latest release tag")
return
# get local tag
run_json = '/usr/bin/blikvm/package.json'
if not os.path.exists(run_json):
Expand All @@ -138,27 +142,30 @@ def main():
print("Upgrading ", run_version , " ==> ", latest_version)
# download tar pack
cmd = ""
if board_type == BoardType.V1_CM4 or BoardType.board_type == V2_HAT or BoardType.board_type == V3_PCIE:
cmd = "curl -kLJo release.tar.gz https://github.com/ThomasVon2021/blikvm/releases/download/" + tag[0:-1] + "/release.tar.gz"
if board_type == BoardType.V1_CM4 or board_type == BoardType.V2_HAT or board_type == BoardType.V3_PCIE:
# cmd = "curl -kLJo release.tar.gz https://github.com/ThomasVon2021/blikvm/releases/download/" + tag[0:-1] + "/release.tar.gz"
file_name = "release.tar.gz"
elif board_type == BoardType.V4_H616:
cmd = "curl -kLJo release.tar.gz https://github.com/ThomasVon2021/blikvm/releases/download/" + tag[0:-1] + "/release-h616-v4.tar.gz"
# cmd = "curl -kLJo release.tar.gz https://github.com/ThomasVon2021/blikvm/releases/download/" + tag[0:-1] + "/release-h616-v4.tar.gz"
file_name = "release-h616-v4.tar.gz"
else:
print("get unknow board")
try:
print("download package ", cmd)
output = subprocess.check_output(cmd, shell = True, cwd=download_path)
print("download package ", file_name, " waitting ")
download_release_file(code_owner,code_repo,latest_version, file_name, download_path)
# output = subprocess.check_output(cmd, shell = True, cwd=download_path)
except subprocess.CalledProcessError as e:
print("Download release package failed, check network")
break
return
# release_tar = download_path + "release.tar.gz"
# if os.path.exists(release_tar):
# cmd = "tar -zxvf release.tar.gz"
# output = subprocess.check_output(cmd, shell = True, cwd=download_path)
# cmd = "python3 install_release.py"
# output = subprocess.check_output(cmd, shell = True, cwd=sh_path)
# update_result = True
# print("Upgrade success")
print("Download release package success, start to install, waitting")
release_tar = download_path + file_name
if os.path.exists(release_tar):
cmd = "tar -zxvf " + file_name
output = subprocess.check_output(cmd, shell = True, cwd=download_path)
cmd = "python3 install_release.py"
output = subprocess.check_output(cmd, shell = True, cwd=sh_path)
update_result = True
print("Upgrade success")
else:
print("Don't need update")
a = 0
Expand Down
2 changes: 1 addition & 1 deletion src/config/package.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version": "Develop-1.1.0", "version_int": 110, "md5value": "4f4e69a0ca321812b66d51b4f60294e2", "oled_type": 0}
{"version": "Develop-1.1.1", "version_int": 111, "md5value": "ecbba91e1976765b490e7d54194199fb", "oled_type": 0}
4 changes: 2 additions & 2 deletions third_lib/SPI_LCD/oled_run.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ int oled_240_240_run()
while(1)
{
Paint_Clear(WHITE);
Paint_SetRotate(ROTATE_180);
Paint_SetRotate(ROTATE_270);
GUI_ReadBmp("/usr/bin/blikvm/oled_info.bmp");
Paint_DrawString_EN( 70, 10, "BliKVM", &Font24, WHITE ,BLACK);
Paint_DrawString_EN( 60, 10, "BliKVM V4", &Font24, WHITE ,BLACK);

// IP addresss
char ip[20]={0};
Expand Down

0 comments on commit 0c7312a

Please sign in to comment.