Skip to content

Commit 7e0acaa

Browse files
unicornxRbb666
authored andcommitted
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 <unicorn_wang@outlook.com>
1 parent 2a18d68 commit 7e0acaa

File tree

5 files changed

+125
-6
lines changed

5 files changed

+125
-6
lines changed

bsp/cvitek/.gitignore

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
cvitek_bootloader
2-
fip.bin
3-
boot.sd
4-
output
1+
rttpkgtool/
2+
output/
53
Image.lzma

bsp/cvitek/build.sh

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
3+
source ./tools.sh
4+
5+
function usage() {
6+
echo "Usage:"
7+
echo " ./build.sh [-h|-l|-b]"
8+
echo " -h: display usage"
9+
echo " -l: build c906L"
10+
echo " -b: build c906B"
11+
}
12+
13+
function build_c906b() {
14+
echo "build_c906b"
15+
16+
BOARD_TYPE=`get_board_type $BSP_PATH/cv18xx_risc-v`
17+
echo "BOARD_TYPE: $BOARD_TYPE"
18+
19+
DPT_PATH_KERNEL=$BSP_PATH/../../ DPT_BOARD_TYPE=$BOARD_TYPE DPT_PATH_OUTPUT=$BSP_PATH/output ./rttpkgtool/script/mkpkg.sh -b
20+
}
21+
22+
function build_c906l() {
23+
echo "build_c906l"
24+
25+
BOARD_TYPE=`get_board_type $BSP_PATH/c906_little`
26+
echo "BOARD_TYPE: $BOARD_TYPE"
27+
28+
DPT_PATH_KERNEL=$BSP_PATH/../../ DPT_BOARD_TYPE=$BOARD_TYPE DPT_PATH_OUTPUT=$BSP_PATH/output ./rttpkgtool/script/mkpkg.sh -l
29+
}
30+
31+
while getopts ":hbl" opt
32+
do
33+
case $opt in
34+
h)
35+
O_HELP=y
36+
;;
37+
b)
38+
O_MAKE_BIG=y
39+
;;
40+
l)
41+
O_MAKE_LITTLE=y
42+
;;
43+
?)
44+
echo "Unrecognized parameter."
45+
usage
46+
exit 1
47+
;;
48+
esac
49+
done
50+
51+
if [ "$O_HELP" = "y" ]; then
52+
usage
53+
exit 0
54+
fi
55+
56+
BSP_PATH=$(realpath $(dirname $0))
57+
echo "BSP_PATH: $BSP_PATH"
58+
59+
download_rttpkgtool $BSP_PATH
60+
61+
if [ "$O_MAKE_BIG" = "y" ]; then
62+
build_c906b
63+
fi
64+
65+
if [ "$O_MAKE_LITTLE" = "y" ]; then
66+
build_c906l
67+
fi
68+

bsp/cvitek/c906_little/rtconfig.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@
6464

6565
DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtt.asm\n'
6666
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
67-
POST_ACTION += 'cd .. && bash combine-fip.sh ' + os.getcwd() + ' rtthread.bin' + ' \n'
67+
POST_ACTION += 'cd .. && bash ./build.sh -l' + ' \n'

bsp/cvitek/cv18xx_risc-v/rtconfig.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@
5757

5858
DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtthread.asm\n'
5959
POST_ACTION = OBJCPY + ' -O binary $TARGET Image \n' + SIZE + ' $TARGET \n'
60-
POST_ACTION += 'cd .. && bash mksdimg.sh ' + os.getcwd() + ' Image \n'
60+
POST_ACTION += 'cd .. && bash ./build.sh -b' + ' \n'

bsp/cvitek/tools.sh

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# NOTE: Don't execute this script directly. It should be sourced by another script.
2+
# Description: This script contains utility functions.
3+
4+
function get_board_type()
5+
{
6+
local project_path=$1
7+
local supported_board_configs=("CONFIG_BOARD_TYPE_MILKV_DUO" "CONFIG_BOARD_TYPE_MILKV_DUO256M" "CONFIG_BOARD_TYPE_MILKV_DUOS")
8+
local supported_board_types=("duo" "duo256m" "duos")
9+
10+
local board_type="N/A"
11+
12+
for ((i=0; i< ${#supported_board_configs[@]}; i++))
13+
do
14+
config_value=$(grep -w "${supported_board_configs[i]}" ${project_path}/.config | cut -d= -f2)
15+
if [ "$config_value" == "y" ]; then
16+
board_type=${supported_board_types[i]}
17+
break
18+
fi
19+
done
20+
21+
echo ${board_type}
22+
}
23+
24+
function download_rttpkgtool()
25+
{
26+
local project_path=$1
27+
local restult=$(curl -m 10 -s http://www.ip-api.com/json)
28+
local country=$(echo $restult | sed 's/.*"country":"\([^"]*\)".*/\1/')
29+
#echo "Country: $country"
30+
31+
if [ "$country" == "China" ]; then
32+
local url_rttpkgtool="https://gitee.com/unicornx/rttpkgtool.git"
33+
else
34+
local url_rttpkgtool="https://github.com/plctlab/rttpkgtool.git"
35+
fi
36+
#echo "rttpkgtool URL: ${url_rttpkgtool}"
37+
38+
if [ ! -d ${project_path}/rttpkgtool ]; then
39+
echo "rttpkgtool does not exist, clone it from ${url_rttpkgtool}"
40+
git clone ${url_rttpkgtool} ${project_path}/rttpkgtool
41+
42+
if [ $? -ne 0 ]; then
43+
echo "Failed to clone ${url_rttpkgtool} !"
44+
exit 1
45+
fi
46+
else
47+
echo "rttpkgtool already exists"
48+
pushd ${project_path}/rttpkgtool
49+
git checkout main
50+
git pull
51+
popd
52+
fi
53+
}

0 commit comments

Comments
 (0)