Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bsp/cvitek] Update packaging method #9457

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/bsp_buildings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,10 @@ jobs:
RTT_TOOL_CHAIN: "sourcery-i386-unknown-elf"
SUB_RTT_BSP:
- "x86"
- RTT_BSP: "xuantie-900"
RTT_TOOL_CHAIN: "sourcery-Xuantie-900-gcc-elf"
SUB_RTT_BSP:
- "cvitek/c906_little"
steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand Down Expand Up @@ -465,6 +469,14 @@ jobs:
/opt/i386-unknown-elf_for_x86_64-pc-linux-gnu/bin/i386-unknown-elf-gcc --version
echo "RTT_EXEC_PATH=/opt/i386-unknown-elf_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV

- name: Install Xuantie-900-gcc-elf Tools
if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-Xuantie-900-gcc-elf' && success() }}
run: |
wget -q https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1705395512373/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.1-20240115.tar.gz
sudo tar -zxvf Xuantie-900-gcc-elf-newlib-x86_64-V2.8.1-20240115.tar.gz -C /opt
/opt/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.1/bin/riscv64-unknown-elf-gcc --version
echo "RTT_EXEC_PATH=/opt/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.1/bin" >> $GITHUB_ENV

- name: Bsp Scons Compile
if: ${{ success() }}
shell: bash
Expand Down
54 changes: 19 additions & 35 deletions bsp/cvitek/board_env.sh
Original file line number Diff line number Diff line change
@@ -1,44 +1,28 @@
#!/bin/bash

function get_board_type()
function check_board()
{
BOARD_CONFIG=("CONFIG_BOARD_TYPE_MILKV_DUO" "CONFIG_BOARD_TYPE_MILKV_DUO_SPINOR" "CONFIG_BOARD_TYPE_MILKV_DUO_SPINAND" "CONFIG_BOARD_TYPE_MILKV_DUO256M" "CONFIG_BOARD_TYPE_MILKV_DUO256M_SPINOR" "CONFIG_BOARD_TYPE_MILKV_DUO256M_SPINAND" "CONFIG_BOARD_TYPE_MILKV_DUOS")
BOARD_VALUE=("milkv-duo" "milkv-duo-spinor" "milkv-duo-spinand" "milkv-duo256m" "milkv-duo256m-spinor" "milkv-duo256m-spinand" "milkv-duos-sd")
STORAGE_VAUE=("sd" "spinor" "spinand" "sd" "spinor" "spinand" "sd")
local config_file=$1/.config

for ((i=0;i<${#BOARD_CONFIG[@]};i++))
do
config_value=$(grep -w "${BOARD_CONFIG[i]}" ${PROJECT_PATH}/.config | cut -d= -f2)
if [ "$config_value" == "y" ]; then
BOARD_TYPE=${BOARD_VALUE[i]}
STORAGE_TYPE=${STORAGE_VAUE[i]}
break
fi
done
export BOARD_TYPE=${BOARD_TYPE}
export STORAGE_TYPE=${STORAGE_TYPE}
}
board_type=$(grep -E '^CONFIG_BOARD_TYPE_.*=y' "$config_file" | sed 's/CONFIG_BOARD_TYPE_//;s/=y$//')

function check_bootloader()
{
restult=$(curl -m 10 -s http://www.ip-api.com/json)
COUNTRY=$(echo $restult | sed 's/.*"country":"\([^"]*\)".*/\1/')
echo "Country: $COUNTRY"

if [ "$COUNTRY" == "China" ]; then
BOOTLOADER_URL=https://gitee.com/flyingcys/cvitek_bootloader
else
BOOTLOADER_URL=https://github.com/flyingcys/cvitek_bootloader
if [ -z "$board_type" ]; then
echo "No board type found in the config file."
return 1
fi

if [ ! -d cvitek_bootloader ]; then
echo "cvitek_bootloader not exist, clone it from ${BOOTLOADER_URL}"
git clone ${BOOTLOADER_URL}
BOARD_TYPE=$(echo "$board_type" | tr '[:upper:]' '[:lower:]')
STORAGE_TYPE="${BOARD_TYPE##*_}"

soc_type=$(grep -E '^CONFIG_SOC_TYPE_.*=y' "$config_file" | sed 's/CONFIG_SOC_TYPE_//;s/=y$//')
if [ -z "$soc_type" ]; then
echo "No soc type found in the config file."
return 1
fi

if [ $? -ne 0 ]; then
echo "Failed to clone ${BOOTLOADER_URL} !"
exit 1
fi
fi
}
SOC_TYPE=$(echo "$soc_type" | tr '[:upper:]' '[:lower:]')

export BOARD_TYPE STORAGE_TYPE SOC_TYPE

return 0
}
8 changes: 6 additions & 2 deletions bsp/cvitek/c906_little/.config
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ CONFIG_ARCH_RISCV=y
CONFIG_ARCH_RISCV_FPU=y
CONFIG_ARCH_RISCV_FPU_D=y
CONFIG_ARCH_RISCV64=y
CONFIG_ARCH_USING_NEW_CTX_SWITCH=y

#
# RT-Thread Components
Expand Down Expand Up @@ -934,6 +935,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_ARDUINO_MSGQ_C_CPP_DEMO is not set
# CONFIG_PKG_USING_ARDUINO_SKETCH_LOADER_DEMO is not set
# CONFIG_PKG_USING_ARDUINO_ULTRASOUND_RADAR is not set
# CONFIG_PKG_USING_ARDUINO_RTDUINO_SENSORFUSION_SHIELD is not set
# CONFIG_PKG_USING_ARDUINO_NINEINONE_SENSOR_SHIELD is not set
# CONFIG_PKG_USING_ARDUINO_SENSOR_KIT is not set
# CONFIG_PKG_USING_ARDUINO_MATLAB_SUPPORT is not set
Expand Down Expand Up @@ -1175,6 +1177,7 @@ CONFIG_BSP_UART_IRQ_BASE=30
# CONFIG_BSP_USING_ADC is not set
# CONFIG_BSP_USING_SPI is not set
# CONFIG_BSP_USING_WDT is not set
# CONFIG_BSP_USING_TIMER is not set
# CONFIG_BSP_USING_PWM is not set
# CONFIG_BSP_USING_RTC is not set
# end of General Drivers Configuration
Expand All @@ -1186,7 +1189,8 @@ CONFIG_BSP_TIMER_CLK_FREQ=25000000
CONFIG_BSP_GPIO_IRQ_BASE=41
CONFIG_BSP_SYS_GPIO_IRQ_BASE=47
CONFIG_SOC_TYPE_SG2002=y
# CONFIG_BOARD_TYPE_MILKV_DUO is not set
# CONFIG_BOARD_TYPE_MILKV_DUO_SD is not set
# CONFIG_BOARD_TYPE_MILKV_DUO_SPINOR is not set
CONFIG_BOARD_TYPE_MILKV_DUO256M=y
CONFIG_BOARD_TYPE_MILKV_DUO256M_SD=y
# CONFIG_BOARD_TYPE_MILKV_DUO256M_SPINOR is not set
# CONFIG_BOARD_TYPE_MILKV_DUOS_SD is not set
14 changes: 7 additions & 7 deletions bsp/cvitek/c906_little/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,26 @@ config SOC_TYPE_SG2002

choice
prompt "Board Type"
default BOARD_TYPE_MILKV_DUO256M
default BOARD_TYPE_MILKV_DUO256M_SD

config BOARD_TYPE_MILKV_DUO
config BOARD_TYPE_MILKV_DUO_SD
select SOC_TYPE_CV180X
bool "milkv-duo"
bool "milkv-duo-sd"

config BOARD_TYPE_MILKV_DUO_SPINOR
select SOC_TYPE_CV180X
bool "milkv-duo-spinor"

config BOARD_TYPE_MILKV_DUO256M
config BOARD_TYPE_MILKV_DUO256M_SD
select SOC_TYPE_SG2002
bool "milkv-duo256m"
bool "milkv-duo256m-sd"

config BOARD_TYPE_MILKV_DUO256M_SPINOR
select SOC_TYPE_SG2002
bool "milkv-duo256m-spinor"

config BOARD_TYPE_MILKV_DUOS
config BOARD_TYPE_MILKV_DUOS_SD
select SOC_TYPE_SG2000
bool "milkv-duos"
bool "milkv-duos-sd"

endchoice
2 changes: 1 addition & 1 deletion bsp/cvitek/c906_little/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ objs = PrepareBuilding(env, RTT_ROOT, has_libcpu = False)
# include libraries
objs.extend(SConscript(drivers_path_prefix + '/SConscript', variant_dir='build/drivers', duplicate=0))

if GetDepend('BOARD_TYPE_MILKV_DUO256M') or GetDepend('BOARD_TYPE_MILKV_DUOS'):
if GetDepend('BOARD_TYPE_MILKV_DUO256M_SD') or GetDepend('BOARD_TYPE_MILKV_DUOS_SD'):
env['LINKFLAGS'] = env['LINKFLAGS'].replace('cv180x_lscript.ld', 'cv181x_lscript.ld')
env['LINKFLAGS'] = env['LINKFLAGS'].replace('-L board/script/cv180x', '-L board/script/cv181x')

Expand Down
3 changes: 2 additions & 1 deletion bsp/cvitek/c906_little/rtconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#define ARCH_RISCV_FPU
#define ARCH_RISCV_FPU_D
#define ARCH_RISCV64
#define ARCH_USING_NEW_CTX_SWITCH

/* RT-Thread Components */

Expand Down Expand Up @@ -335,6 +336,6 @@
#define BSP_GPIO_IRQ_BASE 41
#define BSP_SYS_GPIO_IRQ_BASE 47
#define SOC_TYPE_SG2002
#define BOARD_TYPE_MILKV_DUO256M
#define BOARD_TYPE_MILKV_DUO256M_SD

#endif
83 changes: 53 additions & 30 deletions bsp/cvitek/combine-fip.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -e

PROJECT_PATH=$1
IMAGE_NAME=$2
Expand All @@ -8,42 +9,64 @@ if [ -z "$PROJECT_PATH" ] || [ -z "$IMAGE_NAME" ]; then
exit 1
fi

function do_combine()
{
local PROJECT_PATH=$1
local IMAGE_NAME=$2

BLCP_IMG_RUNADDR=0x05200200
BLCP_PARAM_LOADADDR=0
NAND_INFO=00000000
NOR_INFO='FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'
FIP_COMPRESS=lzma

BUILD_PLAT=${ROOT_PATH}/pre-build/fsbl/build/${SOC_TYPE}

CHIP_CONF_PATH=${BUILD_PLAT}/chip_conf.bin
DDR_PARAM_TEST_PATH=${ROOT_PATH}/pre-build/fsbl/test/ddr_param.bin
BLCP_PATH=${ROOT_PATH}/pre-build/fsbl/test/empty.bin

MONITOR_PATH=${ROOT_PATH}/pre-build/opensbi/${BOARD_TYPE}/fw_dynamic.bin
LOADER_2ND_PATH=${ROOT_PATH}/pre-build/u-boot-2021.10/${BOARD_TYPE}/u-boot-raw.bin

BLCP_2ND_PATH=$PROJECT_PATH/$IMAGE_NAME

echo "Combining fip.bin..."
. ./pre-build/fsbl/build/${SOC_TYPE}/blmacros.env && \
python3 ./pre-build/fsbl/plat/fiptool.py -v genfip \
${ROOT_PATH}/output/${BOARD_TYPE}/fip.bin \
--MONITOR_RUNADDR="${MONITOR_RUNADDR}" \
--BLCP_2ND_RUNADDR="${BLCP_2ND_RUNADDR}" \
--CHIP_CONF=${CHIP_CONF_PATH} \
--NOR_INFO=${NOR_INFO} \
--NAND_INFO=${NAND_INFO} \
--BL2=${BUILD_PLAT}/bl2.bin \
--BLCP_IMG_RUNADDR=${BLCP_IMG_RUNADDR} \
--BLCP_PARAM_LOADADDR=${BLCP_PARAM_LOADADDR} \
--BLCP=${BLCP_PATH} \
--DDR_PARAM=${DDR_PARAM_TEST_PATH} \
--BLCP_2ND=${BLCP_2ND_PATH} \
--MONITOR=${MONITOR_PATH} \
--LOADER_2ND=${LOADER_2ND_PATH} \
--compress=${FIP_COMPRESS}
}

ROOT_PATH=$(pwd)
echo $ROOT_PATH

. board_env.sh

get_board_type
echo "board_type: ${BOARD_TYPE}"

check_bootloader || exit 0

export BLCP_2ND_PATH=${PROJECT_PATH}/${IMAGE_NAME}

pushd cvitek_bootloader

. env.sh

get_build_board ${BOARD_TYPE}

echo "board: ${MV_BOARD_LINK}"

if [ ! -d opensbi/build/platform/generic ] || [ ! -d fsbl/build/${MV_BOARD_LINK} ] || [ ! -d u-boot-2021.10/build/${MV_BOARD_LINK} ]; then
do_build

CHIP_ARCH_L=$(echo $CHIP_ARCH | tr '[:upper:]' '[:lower:]')
cp -rf build/output/${MV_BOARD_LINK}/cvi_board_memmap.ld ${ROOT_PATH}/c906_little/board/script/${CHIP_ARCH_L}
if check_board ${PROJECT_PATH} ; then
echo "board type: ${BOARD_TYPE}"
echo "storage type: ${STORAGE_TYPE}"
else
echo "Build already done, skip build"

do_combine

if [ $? -ne 0 ]; then
do_build
fi
echo "board type not found"
exit 1
fi

popd
mkdir -p output/${BOARD_TYPE}
do_combine $PROJECT_PATH $IMAGE_NAME

echo "=== Done fip combine for ${BOARD_TYPE} successfully! ==="

mkdir -p output/${MV_BOARD}
cp -rf cvitek_bootloader/install/soc_${MV_BOARD_LINK}/fip.bin output/${MV_BOARD}/fip.bin
exit 0
6 changes: 3 additions & 3 deletions bsp/cvitek/cv18xx_aarch64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ config SOC_TYPE_SG2002

choice
prompt "Board Type"
default BOARD_TYPE_MILKV_DUO256M
default BOARD_TYPE_MILKV_DUO256M_SD

config BOARD_TYPE_MILKV_DUO256M
config BOARD_TYPE_MILKV_DUO256M_SD
select SOC_TYPE_SG2002
bool "milkv-duo256m"
bool "milkv-duo256m-sd"

config BOARD_TYPE_MILKV_DUO256M_SPINOR
select SOC_TYPE_SG2002
Expand Down
Loading
Loading