diff options
| author | Chen Wang <[email protected]> | 2025-01-16 15:45:44 +0800 |
|---|---|---|
| committer | Rbb666 <[email protected]> | 2025-01-26 10:55:44 +0800 |
| commit | 7e0acaa2541f8351744185da1dd8f1ede2067f23 (patch) | |
| tree | dfbf9abd9e8e46542e86aaf7335f720f0107172c | |
| parent | 2a18d6873b6f3b22e9900197f2ea480d1e0fa4f4 (diff) | |
bsp: cvitek: use rttpkgtool to replace cvitek_bootloader
Originally, for riscv big and little cores under bsp/cvitek,
after generating rtthread.bin, the cvitek_bootloader tool
would be used to package it and generate fip.bin and boot.sd
files that can be burned into sdcard. However, the
cvitek_bootloader tool repository is relatively large, and
it compiles and generates firmware such as fsbl, opensbi and
uboot from the source code level. And when using it, it
needs to be downloaded to the bsp/cvitek directory, which
will introduce pollution to source files in the RTT repository
under the original working path.
The new solution uses rttpkgtool, which is similar to
cvitek_bootloader, but it uses prebuilt firmware, so it is
very small and does not introduce pollution to the source file.
Signed-off-by: Chen Wang <[email protected]>
| -rwxr-xr-x | bsp/cvitek/.gitignore | 6 | ||||
| -rwxr-xr-x | bsp/cvitek/build.sh | 68 | ||||
| -rwxr-xr-x | bsp/cvitek/c906_little/rtconfig.py | 2 | ||||
| -rwxr-xr-x | bsp/cvitek/cv18xx_risc-v/rtconfig.py | 2 | ||||
| -rw-r--r-- | bsp/cvitek/tools.sh | 53 |
5 files changed, 125 insertions, 6 deletions
diff --git a/bsp/cvitek/.gitignore b/bsp/cvitek/.gitignore index c4ea9348dd..adb46db0ab 100755 --- a/bsp/cvitek/.gitignore +++ b/bsp/cvitek/.gitignore @@ -1,5 +1,3 @@ -cvitek_bootloader -fip.bin -boot.sd -output +rttpkgtool/ +output/ Image.lzma
\ No newline at end of file diff --git a/bsp/cvitek/build.sh b/bsp/cvitek/build.sh new file mode 100755 index 0000000000..c163ccc738 --- /dev/null +++ b/bsp/cvitek/build.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +source ./tools.sh + +function usage() { + echo "Usage:" + echo " ./build.sh [-h|-l|-b]" + echo " -h: display usage" + echo " -l: build c906L" + echo " -b: build c906B" +} + +function build_c906b() { + echo "build_c906b" + + BOARD_TYPE=`get_board_type $BSP_PATH/cv18xx_risc-v` + echo "BOARD_TYPE: $BOARD_TYPE" + + DPT_PATH_KERNEL=$BSP_PATH/../../ DPT_BOARD_TYPE=$BOARD_TYPE DPT_PATH_OUTPUT=$BSP_PATH/output ./rttpkgtool/script/mkpkg.sh -b +} + +function build_c906l() { + echo "build_c906l" + + BOARD_TYPE=`get_board_type $BSP_PATH/c906_little` + echo "BOARD_TYPE: $BOARD_TYPE" + + DPT_PATH_KERNEL=$BSP_PATH/../../ DPT_BOARD_TYPE=$BOARD_TYPE DPT_PATH_OUTPUT=$BSP_PATH/output ./rttpkgtool/script/mkpkg.sh -l +} + +while getopts ":hbl" opt +do + case $opt in + h) + O_HELP=y + ;; + b) + O_MAKE_BIG=y + ;; + l) + O_MAKE_LITTLE=y + ;; + ?) + echo "Unrecognized parameter." + usage + exit 1 + ;; + esac +done + +if [ "$O_HELP" = "y" ]; then + usage + exit 0 +fi + +BSP_PATH=$(realpath $(dirname $0)) +echo "BSP_PATH: $BSP_PATH" + +download_rttpkgtool $BSP_PATH + +if [ "$O_MAKE_BIG" = "y" ]; then + build_c906b +fi + +if [ "$O_MAKE_LITTLE" = "y" ]; then + build_c906l +fi + diff --git a/bsp/cvitek/c906_little/rtconfig.py b/bsp/cvitek/c906_little/rtconfig.py index 50c32d5561..9d139d9e94 100755 --- a/bsp/cvitek/c906_little/rtconfig.py +++ b/bsp/cvitek/c906_little/rtconfig.py @@ -64,4 +64,4 @@ if PLATFORM == 'gcc': DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtt.asm\n' POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' -POST_ACTION += 'cd .. && bash combine-fip.sh ' + os.getcwd() + ' rtthread.bin' + ' \n'
\ No newline at end of file +POST_ACTION += 'cd .. && bash ./build.sh -l' + ' \n'
\ No newline at end of file diff --git a/bsp/cvitek/cv18xx_risc-v/rtconfig.py b/bsp/cvitek/cv18xx_risc-v/rtconfig.py index 8137d1d922..91ccaa795b 100755 --- a/bsp/cvitek/cv18xx_risc-v/rtconfig.py +++ b/bsp/cvitek/cv18xx_risc-v/rtconfig.py @@ -57,4 +57,4 @@ if PLATFORM == 'gcc': DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtthread.asm\n' POST_ACTION = OBJCPY + ' -O binary $TARGET Image \n' + SIZE + ' $TARGET \n' -POST_ACTION += 'cd .. && bash mksdimg.sh ' + os.getcwd() + ' Image \n' +POST_ACTION += 'cd .. && bash ./build.sh -b' + ' \n' diff --git a/bsp/cvitek/tools.sh b/bsp/cvitek/tools.sh new file mode 100644 index 0000000000..d022e2a8ca --- /dev/null +++ b/bsp/cvitek/tools.sh @@ -0,0 +1,53 @@ +# NOTE: Don't execute this script directly. It should be sourced by another script. +# Description: This script contains utility functions. + +function get_board_type() +{ + local project_path=$1 + local supported_board_configs=("CONFIG_BOARD_TYPE_MILKV_DUO" "CONFIG_BOARD_TYPE_MILKV_DUO256M" "CONFIG_BOARD_TYPE_MILKV_DUOS") + local supported_board_types=("duo" "duo256m" "duos") + + local board_type="N/A" + + for ((i=0; i< ${#supported_board_configs[@]}; i++)) + do + config_value=$(grep -w "${supported_board_configs[i]}" ${project_path}/.config | cut -d= -f2) + if [ "$config_value" == "y" ]; then + board_type=${supported_board_types[i]} + break + fi + done + + echo ${board_type} +} + +function download_rttpkgtool() +{ + local project_path=$1 + local restult=$(curl -m 10 -s http://www.ip-api.com/json) + local country=$(echo $restult | sed 's/.*"country":"\([^"]*\)".*/\1/') + #echo "Country: $country" + + if [ "$country" == "China" ]; then + local url_rttpkgtool="https://gitee.com/unicornx/rttpkgtool.git" + else + local url_rttpkgtool="https://github.com/plctlab/rttpkgtool.git" + fi + #echo "rttpkgtool URL: ${url_rttpkgtool}" + + if [ ! -d ${project_path}/rttpkgtool ]; then + echo "rttpkgtool does not exist, clone it from ${url_rttpkgtool}" + git clone ${url_rttpkgtool} ${project_path}/rttpkgtool + + if [ $? -ne 0 ]; then + echo "Failed to clone ${url_rttpkgtool} !" + exit 1 + fi + else + echo "rttpkgtool already exists" + pushd ${project_path}/rttpkgtool + git checkout main + git pull + popd + fi +}
\ No newline at end of file |
