Add compilation scripts and guidelines to simplify the compilation process

This commit is contained in:
BuGu
2025-03-04 16:31:15 +08:00
parent 8d8c57bc48
commit d94eba0ab1
5 changed files with 197 additions and 46 deletions

5
support/README.md Normal file
View File

@@ -0,0 +1,5 @@
# NanoKVM Support Instructions
`/support` contains auxiliary functions for NanoKVM, such as image subsystem, system status monitoring, system updates, screen key drivers, and a few system functions.
Currently, NanoKVM is divided into two versions based on the main control chip: SG2002 (which includes NanoKVM-Lite/Full/PCIe) and H618 (including NanoKVM-Pro). Different chips have significantly different projects and compilation environments. To distinguish between them, they are stored separately in `/support/sg2002` and `/support/h618`.

5
support/README_ZH.md Normal file
View File

@@ -0,0 +1,5 @@
# NanoKVM support 说明
`/support`包含NanoKVM辅助性的功能如图像子系统、系统状态监控、系统更新、屏幕按键驱动和少部分的系统功能
当前 NanoKVM 根据主控芯片的不同分为两个版本SG2002包含NanoKVM-Lite/Full/PCIe和H618包括NanoKVM-Pro不同的芯片有差异较大的工程和编译环境为做区分将它们分别存放在`/support/sg2002``/support/h618`

View File

@@ -1,8 +1,26 @@
## If you need to compile `kvm_system` yourself, please follow the steps below: # NanoKVM Support Instructions
1. The `kvm_system` project is compiled under the [MaixCDK](https://github.com/sipeed/MaixCDK) framework. Before compiling, please ensure that the `MaixCDK` environment is correctly configured. For the configuration tutorial, click [here](https://github.com/sipeed/MaixCDK/blob/main/docs/doc_zh/README.md). ## Environment Preparation
1. NanoKVM-Lite/Full/PCIe is based on the SG2002 as the main control chip. The projects in the support section are compiled under the [MaixCDK](https://github.com/sipeed/MaixCDK) framework. Before compiling, please ensure that the `MaixCDK` environment is correctly configured. For configuration instructions, click [here](https://github.com/sipeed/MaixCDK/blob/main/docs/doc_zh/README.md).
## kvm_system Compilation Instructions
> The `kvm_system` is responsible for monitoring the NanoKVM system status, system updates, screen key drivers, and a few system functions, compiled with MaixCDK.
1. Before compiling, please ensure that the above-mentioned `MaixCDK` environment is correctly configured.
2. Modify the paths of `MAIXCDK_PATH` and `NanoKVM_PATH` in `./build`. 2. Modify the paths of `MAIXCDK_PATH` and `NanoKVM_PATH` in `./build`.
3. Execute `./build kvm_system` to compile `kvm_system`. 3. Execute `./build kvm_system` to compile `kvm_system`.
4. Use `scp ./kvm_system/dist/kvm_system_release/kvm_system root@192.168.x.x:/kvmapp/kvm_system` to copy it into NanoKVM for testing. 4. Use `scp ./kvm_system/dist/kvm_system_release/kvm_system root@192.168.x.x:/kvmapp/kvm_system` to copy it to NanoKVM for testing.
5. Use `./build add_to_kvmapp` to place the executable files into the `/kvmapp` installation package. 5. Use `./build add_to_kvmapp` to place the executable file into the `/kvmapp` installation package.
6. Use `./build clean` to clean up the compilation of `kvm_system`. 6. Use `./build kvm_system clean` to clean the compilation of `kvm_system`.
## kvm_vision Compilation Instructions
> `kvm_vision` refers to the image acquisition and encoding subsystem of NanoKVM, compiled with MaixCDK to produce dynamic libraries for Go calls. Use `kvm_vision_test` to compile and test the dynamic library.
1. Before compiling, please ensure that the above-mentioned `MaixCDK` environment is correctly configured.
2. Modify the paths of `MAIXCDK_PATH` and `NanoKVM_PATH` in `./build`.
3. Execute `./build kvm_vision` to compile `kvm_vision_test`.
4. You can test the dynamic libraries in `kvm_vision_test/dist/kvm_vision_test_release/dl_lib/`.
5. Use `./build add_to_kvmapp` to place the dynamic libraries into the `/kvmapp` installation package.
6. Use `./build kvm_vision clean` to clean the compilation of `kvm_vision`.

View File

@@ -1,8 +1,26 @@
## 如果需要自己编译 kvm_system 请按以下步骤完成编译 # NanoKVM support 说明
1. `kvm_system`工程在[MaixCDK](https://github.com/sipeed/MaixCDK) 框架下编译。编译前,请保证`MaixCDK`环境已正确配置,配置教程点击[这里](https://github.com/sipeed/MaixCDK/blob/main/docs/doc_zh/README.md) ## 环境准备
1. NanoKVM-Lite/Full/PCIe 以SG2002为主控芯片support 部分的工程在[MaixCDK](https://github.com/sipeed/MaixCDK) 框架下编译。编译前,请保证`MaixCDK`环境已正确配置,配置教程点击[这里](https://github.com/sipeed/MaixCDK/blob/main/docs/doc_zh/README.md)
## kvm_system 编译说明
> `kvm_system` 负责 NanoKVM 系统状态监控、系统更新、屏幕按键驱动和少部分的系统功能,借助 MaixCDK 编译
1. 编译前,请保证上述 1.`MaixCDK`环境已正确配置
2. 修改 `./build``MAIXCDK_PATH``NanoKVM_PATH`的路径 2. 修改 `./build``MAIXCDK_PATH``NanoKVM_PATH`的路径
3. 执行 `./build kvm_system` 编译 kvm_system 3. 执行 `./build kvm_system` 编译 kvm_system
4. 使用 `scp ./kvm_system/dist/kvm_system_release/kvm_system root@192.168.x.x:/kvmapp/kvm_system` 拷贝入 NanoKVM 测试 4. 使用 `scp ./kvm_system/dist/kvm_system_release/kvm_system root@192.168.x.x:/kvmapp/kvm_system` 拷贝入 NanoKVM 测试
5. 使用 `./build add_to_kvmapp` 可以将可执行文件放入 `/kvmapp` 安装包内 5. 使用 `./build add_to_kvmapp` 可以将可执行文件放入 `/kvmapp` 安装包内
6. 使用 `./build clean` 可以清除 kvm_system 的编译 6. 使用 `./build kvm_system clean` 可以清除 kvm_system 的编译
## kvm_vision 编译说明
> `kvm_vision` 是 NanoKVM 图像获取编码子系统的统称使用MaixCDK编译出动态库供Go调用使用 `kvm_vision_test` 编译和测试动态库
1. 编译前,请保证上述 1.`MaixCDK`环境已正确配置
2. 修改 `./build``MAIXCDK_PATH``NanoKVM_PATH`的路径
3. 执行 `./build kvm_vision` 编译 kvm_vision_test
4. 可使用 `kvm_vision_test/dist/kvm_vision_test_release/dl_lib/` 中的动态库测试
5. 使用 `./build add_to_kvmapp` 可以将动态库放入 `/kvmapp` 安装包内
6. 使用 `./build kvm_vision clean` 可以清除 kvm_system 的编译

View File

@@ -1,18 +1,37 @@
#!/bin/bash #!/bin/bash
export MAIXCDK_PATH=~/Git_Project/MaixCDK export MAIXCDK_PATH=~/MaixCDK
export NanoKVM_PATH=~/NanoKVM export NanoKVM_PATH=~/NanoKVM
kvm_system_PATH="$NanoKVM_PATH/support/sg2002/kvm_system" Project_Name="None"
Project_PATH="None"
Project_Action="None"
KVMAPP_PATH="$NanoKVM_PATH/kvmapp"
maixcdk_build_from_zero(){ maixcdk_build() {
maixcdk build <<EOF local input_value="$1"
DIST_PATH="./dist"
rm -rf $DIST_PATH
if [ "$input_value" = "from_zero" ]
then
maixcdk build <<EOF
2 2
EOF EOF
else
maixcdk build
fi
} }
maixcdk_build(){ chack_build(){
maixcdk build DIST_PATH="./dist"
if [ -d "$DIST_PATH" ]
then
echo "SUCCESS"
else
echo "FAILURE"
fi
} }
maixcdk_clean(){ maixcdk_clean(){
@@ -22,38 +41,124 @@ maixcdk_clean(){
case "$1" in case "$1" in
kvm_system) kvm_system)
echo "Start using MaixCDK to compile kvm_system..." Project_Name="kvm_system"
cd $kvm_system_PATH Project_PATH="$NanoKVM_PATH/support/sg2002/kvm_system"
if [ -f "$kvm_system_PATH/build/config/project_vars.json" ] echo -e "\e[36m[build] \e[32mProject: kvm_system \e[0m"
then
if grep -q "\"PLATFORM\": \"maixcam\"" "$kvm_system_PATH/build/config/project_vars.json"; then
maixcdk_build
else
maixcdk_clean
maixcdk_build_from_zero
fi
else
maixcdk_build_from_zero
fi
echo -e "\e[36m[build] \e[32mbuild completed! Use \e[34m./build add_to_kvmapp\e[32m to add components to kvmapp.\e[0m"
;; ;;
clean) kvm_vision)
cd $kvm_system_PATH Project_Name="kvm_vision"
maixcdk_clean Project_PATH="$NanoKVM_PATH/support/sg2002/kvm_vision_test"
echo -e "\e[36m[build] \e[32mkvm_system cleanup completed!\e[0m" echo -e "\e[36m[build] \e[32mProject: kvm_system \e[0m"
;;
add_to_kvmapp)
source_PATH="$kvm_system_PATH/dist/kvm_system_release/kvm_system"
target_PATH="$NanoKVM_PATH/kvmapp/kvm_system/kvm_system"
if [ -f $source_PATH ]
then
cp -f $source_PATH $target_PATH
echo -e "\e[36m[build] \e[32mkvm_system has been moved to kvmapp.\e[0m"
else
echo -e "\e[36m[build] \e[31mThe source file does not exist. Please compile using \e[34m./build kvm_system \e[31mfirst.\e[0m"
fi
;; ;;
*) *)
echo -e "\e[36m[build] \e[33mUsage: $0 {kvm_system|clean|add_to_kvmapp}" echo -e "\e[36m[build] \e[31mInvalid project name \e[0m"
exit 1 echo -e "\e[36m[build] \e[32mPlease select a project:\e[0m"
esac echo -e "0: kvm_system"
echo -e "1: kvm_vision"
while true; do
read -p "Please enter 0 or 1 : " input
if [[ "$input" -eq 0 ]]
then
Project_Name="kvm_system"
Project_PATH="$NanoKVM_PATH/support/sg2002/kvm_system"
break
elif [[ "$input" -eq 1 ]]
then
Project_Name="kvm_vision"
Project_PATH="$NanoKVM_PATH/support/sg2002/kvm_vision_test"
break
else
echo -e "\e[36m[build] \e[31mInvalid Index \e[0m"
fi
done
esac
if [ -z "$2" ]
then
Project_Action="build"
else
Project_Action=$2
fi
if [ ! "$Project_Name" = "None" ]
then
case "$Project_Action" in
build)
# echo -e "\e[36m[build] \e[32mStart using MaixCDK to compile kvm_system...\e[0m"
JSON_PATH="$Project_PATH/build/config/project_vars.json"
Platform_Char="\"PLATFORM\": \"maixcam\""
if [ ! -e "$MAIXCDK_PATH/components/kvm" ]
then
echo -e "\e[36m[build] \e[32mDetected that the library has not been modified; first, move the library\e[0m"
mv -f $MAIXCDK_PATH/components/vision $NanoKVM_PATH/support/sg2002/additional/original
# mv $MAIXCDK_PATH/components/maixcam_lib $NanoKVM_PATH/support/sg2002/additional/original
mv -f $MAIXCDK_PATH/components/peripheral/port/maixcam/maix_i2c.cpp $NanoKVM_PATH/support/sg2002/additional/original
mv -f $MAIXCDK_PATH/components/3rd_party/sophgo-middleware/sophgo-middleware/v2/sample/common/sample_common_sensor.c $NanoKVM_PATH/support/sg2002/additional/original
cp -rf $NanoKVM_PATH/support/sg2002/additional/kvm $MAIXCDK_PATH/components
cp -rf $NanoKVM_PATH/support/sg2002/additional/kvm_mmf $MAIXCDK_PATH/components
cp -rf $NanoKVM_PATH/support/sg2002/additional/vision $MAIXCDK_PATH/components
cp -f $NanoKVM_PATH/support/sg2002/additional/peripheral/port/maixcam/maix_i2c.cpp $MAIXCDK_PATH/components/peripheral/port/maixcam/maix_i2c.cpp
cp -f $NanoKVM_PATH/support/sg2002/additional/sophgo-middleware/v2/sample/common/sample_common_sensor.c $MAIXCDK_PATH/components/3rd_party/sophgo-middleware/sophgo-middleware/v2/sample/common/
echo -e "\e[36m[build] \e[32mMove the library completed!\e[0m"
fi
cd $Project_PATH
if [ -f $JSON_PATH ]
then
if grep -q $Platform_Char $JSON_PATH; then
maixcdk_build
else
maixcdk_clean
maixcdk_build "from_zero"
fi
else
maixcdk_build "from_zero"
fi
RES=$(chack_build)
if [ "$RES" = "SUCCESS" ]
then
echo -e "\e[36m[build] \e[32mBuild completed! Use \e[34m./build $Project_Name add_to_kvmapp\e[32m to add it to kvmapp.\e[0m"
else
echo -e "\e[36m[build] \e[31mBuild Error!\e[0m"
fi
;;
clean)
cd $Project_PATH
maixcdk_clean
echo -e "\e[36m[build] \e[32m$Project_Name cleanup completed!\e[0m"
;;
add_to_kvmapp)
if [ "$Project_Name" = "kvm_system" ]
then
SOURCE_PATH="$Project_PATH/dist/kvm_system_release/kvm_system"
TARGET_PATH="$KVMAPP_PATH/kvm_system/kvm_system"
chmod +x $SOURCE_PATH
rm -f $TARGET_PATH
else
SOURCE_PATH="$Project_PATH/dist/kvm_vision_test_release/dl_lib"
TARGET_PATH="$KVMAPP_PATH/server/"
fi
if [ -e $SOURCE_PATH ]
then
cp -rf $SOURCE_PATH $TARGET_PATH
echo -e "\e[36m[build] \e[32mkvm_system has been moved to kvmapp.\e[0m"
else
echo -e "\e[36m[build] \e[31mThe source file does not exist. Please compile using \e[34m./build kvm_system \e[31mfirst.\e[0m"
fi
;;
*)
echo -e "\e[36m[build] \e[31mInvalid Action: \e[34m$2 \e[0m"
echo -e "\e[36m[build] \e[31mUsage: $0 [Project Name]{kvm_system|kvm_vision} [Action]{-/build|clean|add_to_kvmapp} e.g. \e[34m./build kvm_system clean \e[0m"
exit 1
esac
else
echo -e "\e[36m[build] \e[31mInvalid Name \e[0m"
exit 1
fi