support cvitek bsp spinor flash

This commit is contained in:
flyingcys 2024-04-09 22:48:57 +08:00 committed by Meco Man
parent cbf316a5f7
commit 62cd7ad961
15 changed files with 209 additions and 53 deletions

View File

@ -32,7 +32,9 @@ $ scons --menuconfig
```shell
Board Type (milkv-duo) --->
( ) milkv-duo
( ) milkv-duo-spinor
(X) milkv-duo256m
( ) milkv-duo256m-spinor
```
2. 编译
@ -75,6 +77,8 @@ $ wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1u
$ sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
```
3. 如发现切换开发板编译正常,但无法正常打包,请切换至自动下载的 `cvi_bootloader` 目录,并手工运行 `git pull` 更新,或删除该目录后重新自动下载。
## 联系人信息
维护人:[flyingcys](https://github.com/flyingcys)

45
bsp/cvitek/board_env.sh Executable file
View File

@ -0,0 +1,45 @@
#!/bin/bash
function get_board_type()
{
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")
BOARD_VALUE=("milkv-duo" "milkv-duo-spinor" "milkv-duo-spinand" "milkv-duo256m" "milkv-duo256m-spinor" "milkv-duo256m-spinand")
STORAGE_VAUE=("sd" "spinor" "spinand" "sd" "spinor" "spinand")
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}
}
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
fi
if [ ! -d cvitek_bootloader ]; then
echo "cvitek_bootloader not exist, clone it from ${BOOTLOADER_URL}"
git clone ${BOOTLOADER_URL}
if [ $? -ne 0 ]; then
echo "Failed to clone ${BOOTLOADER_URL} !"
exit 1
fi
fi
}

View File

@ -45,6 +45,14 @@ choice
config BOARD_TYPE_MILKV_DUO
bool "milkv-duo"
config BOARD_TYPE_MILKV_DUO_SPINOR
bool "milkv-duo-spinor"
config BOARD_TYPE_MILKV_DUO256M
bool "milkv-duo256m"
config BOARD_TYPE_MILKV_DUO256M_SPINOR
bool "milkv-duo256m-spinor"
endchoice

View File

@ -33,7 +33,9 @@ $ scons --menuconfig
```shell
Board Type (milkv-duo) --->
( ) milkv-duo
( ) milkv-duo-spinor
(X) milkv-duo256m
( ) milkv-duo256m-spinor
```
它会自动下载 env 相关脚本到 ~/.env 目录,然后执行

View File

@ -32,7 +32,9 @@ Choose the target development board type that needs to be compiled:
```shell
Board Type (milkv-duo) --->
( ) milkv-duo
( ) milkv-duo-spinor
(X) milkv-duo256m
( ) milkv-duo256m-spinor
```
It will automatically download env related scripts to the ~/.env directory, then execute

View File

@ -11,47 +11,12 @@ fi
ROOT_PATH=$(pwd)
echo $ROOT_PATH
function get_board_type()
{
BOARD_CONFIG=("CONFIG_BOARD_TYPE_MILKV_DUO" "CONFIG_BOARD_TYPE_MILKV_DUO_SPINOR" "CONFIG_BOARD_TYPE_MILKV_DUO_SPINAND" "CONFIG_BOARD_TYPE_MILKV_DUO256M")
BOARD_VALUE=("milkv-duo" "milkv-duo-spinor" "milkv-duo-spinand" "milkv-duo256m")
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]}
break
fi
done
}
. board_env.sh
get_board_type
echo "board_type: ${BOARD_TYPE}"
COUNTRY=China
function get_country()
{
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
cvitek_bootloader_url=https://gitee.com/flyingcys/cvitek_bootloader
else
cvitek_bootloader_url=https://github.com/flyingcys/cvitek_bootloader
fi
if [ ! -d cvitek_bootloader ]; then
echo "cvitek_bootloader not exist, clone it from ${cvitek_bootloader_url}"
git clone ${cvitek_bootloader_url}
if [ $? -ne 0 ]; then
echo "Failed to clone ${cvitek_bootloader_url} !"
exit 1
fi
fi
check_bootloader || exit 0
export BLCP_2ND_PATH=${PROJECT_PATH}/${IMAGE_NAME}

View File

@ -53,6 +53,13 @@ choice
config BOARD_TYPE_MILKV_DUO
bool "milkv-duo"
config BOARD_TYPE_MILKV_DUO_SPINOR
bool "milkv-duo-spinor"
config BOARD_TYPE_MILKV_DUO256M
bool "milkv-duo256m"
config BOARD_TYPE_MILKV_DUO256M_SPINOR
bool "milkv-duo256m-spinor"
endchoice

View File

@ -79,7 +79,9 @@ RT-Thread Kernel --->
```shell
Board Type (milkv-duo) --->
( ) milkv-duo
( ) milkv-duo-spinor
(X) milkv-duo256m
( ) milkv-duo256m-spinor
```
它会自动下载env相关脚本到~/.env目录然后执行

View File

@ -78,7 +78,9 @@ RT-Thread Kernel --->
```shell
Board Type (milkv-duo) --->
( ) milkv-duo
( ) milkv-duo-spinor
(X) milkv-duo256m
( ) milkv-duo256m-spinor
```
It will automatically download relevant scripts to the ~/.env directory, then execute:

View File

@ -0,0 +1,56 @@
/*
* U-Boot uImage source file with multiple kernels, ramdisks and FDT blobs
*/
/dts-v1/;
/ {
description = "Various kernels, ramdisks and FDT blobs";
#address-cells = <2>;
images {
kernel-1 {
description = "cvitek kernel";
data = /incbin/("./Image.lzma");
type = "kernel";
arch = "riscv";
os = "linux";
compression = "lzma";
load = <0x0 0x80200000>;
entry = <0x0 0x80200000>;
hash-2 {
algo = "crc32";
};
};
/*FDT*/
fdt-cv1800b_milkv_duo_spinor {
description = "cvitek device tree - cv1800b_milkv_duo_spinor";
data = /incbin/("./cv1800b_milkv_duo_spinor.dtb");
type = "flat_dt";
arch = "riscv";
compression = "none";
hash-1 {
algo = "sha256";
};
};
};
/*CFG*/
configurations {
config-cv1800b_milkv_duo_spinor {
description = "boot cvitek system with board cv1800b_milkv_duo_spinor";
kernel = "kernel-1";
fdt = "fdt-cv1800b_milkv_duo_spinor";
};
};
};

View File

@ -0,0 +1,56 @@
/*
* U-Boot uImage source file with multiple kernels, ramdisks and FDT blobs
*/
/dts-v1/;
/ {
description = "Various kernels, ramdisks and FDT blobs";
#address-cells = <2>;
images {
kernel-1 {
description = "cvitek kernel";
data = /incbin/("./Image.lzma");
type = "kernel";
arch = "riscv";
os = "linux";
compression = "lzma";
load = <0x0 0x80200000>;
entry = <0x0 0x80200000>;
hash-2 {
algo = "crc32";
};
};
/*FDT*/
fdt-cv1812cp_milkv_duo256m_spinor {
description = "cvitek device tree - cv1812cp_milkv_duo256m_spinor";
data = /incbin/("./cv1812cp_milkv_duo256m_spinor.dtb");
type = "flat_dt";
arch = "riscv";
compression = "none";
hash-1 {
algo = "sha256";
};
};
};
/*CFG*/
configurations {
config-cv1812cp_milkv_duo256m_spinor {
description = "boot cvitek system with board cv1812cp_milkv_duo256m_spinor";
kernel = "kernel-1";
fdt = "fdt-cv1812cp_milkv_duo256m_spinor";
};
};
};

View File

@ -10,7 +10,7 @@ CPPDEFINES = []
CPPPATH = [cwd]
CHIP_TYPE = 'cv180x'
if GetDepend('BOARD_TYPE_MILKV_DUO256M'):
if GetDepend('BOARD_TYPE_MILKV_DUO256M') or GetDepend('BOARD_TYPE_MILKV_DUO256M_SPINOR') or GetDepend('BOARD_TYPE_MILKV_DUO256M_SPINAND'):
CHIP_TYPE = 'cv181x'
elif GetDepend('BOARD_TYPE_MILKV_DUO') or GetDepend('BOARD_TYPE_MILKV_DUO_SPINOR') or GetDepend('BOARD_TYPE_MILKV_DUO_SPINAND'):
CHIP_TYPE = 'cv180x'

View File

@ -12,20 +12,7 @@ fi
ROOT_PATH=$(pwd)
echo ${ROOT_PATH}
function get_board_type()
{
BOARD_CONFIG=("CONFIG_BOARD_TYPE_MILKV_DUO" "CONFIG_BOARD_TYPE_MILKV_DUO_SPINOR" "CONFIG_BOARD_TYPE_MILKV_DUO_SPINAND" "CONFIG_BOARD_TYPE_MILKV_DUO256M")
BOARD_VALUE=("milkv-duo" "milkv-duo-spinor" "milkv-duo-spinand" "milkv-duo256m")
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]}
break
fi
done
}
. board_env.sh
get_board_type
@ -34,4 +21,24 @@ echo "start compress kernel..."
lzma -c -9 -f -k ${PROJECT_PATH}/${IMAGE_NAME} > ${PROJECT_PATH}/dtb/${BOARD_TYPE}/Image.lzma
mkdir -p ${ROOT_PATH}/output/${BOARD_TYPE}
./mkimage -f ${PROJECT_PATH}/dtb/${BOARD_TYPE}/multi.its -r ${ROOT_PATH}/output/${BOARD_TYPE}/boot.sd
./mkimage -f ${PROJECT_PATH}/dtb/${BOARD_TYPE}/multi.its -r ${ROOT_PATH}/output/${BOARD_TYPE}/boot.${STORAGE_TYPE}
if [ "${STORAGE_TYPE}" == "spinor" ] || [ "${STORAGE_TYPE}" == "spinand" ]; then
check_bootloader || exit 0
pushd cvitek_bootloader
. env.sh
get_build_board ${BOARD_TYPE}
CHIP_ARCH_L=$(echo $CHIP_ARCH | tr '[:upper:]' '[:lower:]')
echo "board: ${MV_BOARD_LINK}"
IMGTOOL_PATH=build/tools/common/image_tool
FLASH_PARTITION_XML=build/boards/"${CHIP_ARCH_L}"/"${MV_BOARD_LINK}"/partition/partition_"${STORAGE_TYPE}".xml
python3 "$IMGTOOL_PATH"/raw2cimg.py "${ROOT_PATH}"/output/"${BOARD_TYPE}"/boot."$STORAGE_TYPE" "${ROOT_PATH}/output/${BOARD_TYPE}" "$FLASH_PARTITION_XML"
popd
fi