bsp: cvitek: improve documentation

Currently, the documents under bsp/cvitek are a bit
messy. There are currently four readme files:

- bsp/cvitek/README.md (Chinese)
- bsp/cvitek/c906_little/README.md (Chinese/English)
- bsp/cvitek/cv18xx_aarch64/README.md (Chinese)
- bsp/cvitek/cv18xx_risc-v/README.md (Chinese/English)

Regarding the working mode of the big + small cores, it
is meaningless to describe the small core alone, or the
large core alone. This can also be seen in the existing
files. The readme of the small core will also introduce
the programming of the large core, and vice versa.

Considering that the official default mode is
C906B + C906L. ARM large core can be treataed as a
special case. So the document structure is modified as
follows:
- Remove `bsp/cvitek/c906_little/README.md` and
  `bsp/cvitek/cv18xx_risc-v/README.md`, merge them all
  into `bsp/cvitek/README.md`
- Add a link to `bsp/cvitek/cv18xx_aarch64/README.md`
  in `bsp/cvitek/README.md`

FIXME: The modified document does not provide English
version. Is it really necessary?

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
This commit is contained in:
Chen Wang 2024-07-22 16:30:06 +08:00 committed by Meco Man
parent e726b93016
commit 04cad7f9c6
5 changed files with 99 additions and 479 deletions

View File

@ -1,25 +1,99 @@
# cvitek bsp
<!-- TOC -->
- [参考文档](#参考文档)
- [概述](#概述)
- [BSP 支持情况](#bsp-支持情况)
- [驱动支持列表](#驱动支持列表)
- [编译](#编译)
- [Toolchain 下载](#toolchain-下载)
- [依赖安装](#依赖安装)
- [构建](#构建)
- [运行](#运行)
- [FAQ](#faq)
- [联系人信息](#联系人信息)
<!-- /TOC -->
# 参考文档
- 【参考 1】CV1800B/CV1801B Datasheet中文版<https://github.com/milkv-duo/duo-files/blob/main/duo/datasheet/CV1800B-CV1801B-Preliminary-Datasheet-full-zh.pdf>
- 【参考 2】SG2002/SG2000 技术参考手册(中文版):<https://github.com/sophgo/sophgo-doc/releases>。官方定期发布 pdf 形式。可以下载下载最新版本的中文版本技术参考手册:`sg2002_trm_cn.pdf` 或者 `sg2000_trm_cn.pdf`
# 概述
支持开发板以及集成 SoC 芯片信息如下
- milk-v duo: [https://milkv.io/duo](https://milkv.io/duo)SoC 采用 CV1800B。
- milk-v duo256m: [https://milkv.io/duo256m](https://milkv.io/docs/duo/getting-started/duo256m)SoC 采用 SG2002。
Duo 家族开发板采用 CV18xx 系列芯片。芯片的工作模式总结如下:
- CV1800B支持一种工作模式
- 大核RISC-V C906@1GHz+ 小核RISC-V C906@700MHz
- SG2002原 CV181xC支持两种工作模式通过管脚 GPIO_RTX 的外围电路控制进行切换:
- 大核RISC-V C906@1GHz+ 小核RISC-V C906@700MHz
- 大核ARM Cortex-A53@1GHz+ 小核RISC-V C906@700MHz
- SG2000原 CV181xH支持两种工作模式通过管脚 GPIO_RTX 的外围电路控制进行切换:
- 大核RISC-V C906@1GHz+ 小核RISC-V C906@700MHz
- 大核ARM Cortex-A53@1GHz+ 小核RISC-V C906@700MHz
# BSP 支持情况
由于大小核的存在,以及不同 SoC 下不同工作模式的存在bsp/cvitek 提供了三种不同 BSP/OS需要单独编译。
| BSP 名称 | 大小核 | 芯片架构 | 默认串口控制台 | 备注 |
| ------------- | ------- |---------------- | -------------- | -------- |
| cv18xx_risc-v | 大核 | RISC-V C906 | uart0 | 支持 MMU支持 RT-Thread 标准版 和 RT-SMART 模式,默认运行 RT-Thread 标准版本 |
| c906-little | 小核 | RISC-V C906 | uart1 | 无 MMU运行 RT-Thread 标准版 |
| cv18xx_aarch64| 大核 | ARM Cortex A53 | uart0 | 支持 MMU 支持 RT-Thread 标准版 和 RT-SMART 版,默认运行 RT-Thread 标准版本 |
由于开发板默认运行的大核为 "cv18xx_risc-v", 所以本文将主要介绍 "cv18xx_risc-v" 和 "c906-little" 的构建和使用。有关 "cv18xx_aarch64" 的介绍请参考 [这里](./cv18xx_aarch64/README.md)。
## 驱动支持列表
| 驱动 | 支持情况 | 备注 |
| :---- | :------- | :---------------- |
| uart | 支持 | 默认波特率115200 |
| gpio | 支持 | |
| i2c | 支持 | |
| adc | 支持 | |
| spi | 支持 | 默认CS引脚每个数据之间CS会拉高请根据时序选择GPIO作为CS。若读取数据tx需持续dummy数据。|
| pwm | 支持 | |
| timer | 支持 | |
| wdt | 支持 | |
| sdio | 支持 | |
| eth | 支持 | |
# 编译
## Toolchain 下载
> 注:当前 bsp 只支持 Linux 编译,推荐 ubuntu 22.04
1. RT-Thread 标准版工具链:`riscv64-unknown-elf-gcc` 下载地址 [https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1705395512373/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.1-20240115.tar.gz](https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1705395512373/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.1-20240115.tar.gz)
2. RT-Smart 版工具链: `riscv64-unknown-linux-musl-gcc` 下载地址 [https://github.com/RT-Thread/toolchains-ci/releases/download/v1.7/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu_latest.tar.bz2](https://github.com/RT-Thread/toolchains-ci/releases/download/v1.7/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu_latest.tar.bz2)
## 支持芯片
针对算能系列 RISC-V 芯片的 bsp包括
正确解压后,在`rtconfig.py`中将 `riscv64-unknown-elf-gcc``riscv64-unknown-linux-musl-gcc` 工具链的本地路径加入 `EXEC_PATH` 或通过 `RTT_EXEC_PATH` 环境变量指定路径。
- 大核
```shell
# RT-Thread 标准版按照以下配置:
$ export RTT_CC_PREFIX=riscv64-unknown-elf-
$ export RTT_EXEC_PATH=/opt/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.1/bin
| 芯片名称 | 芯片架构 | 内存大小 | 默认日志串口 | 备注 |
| ------- | ------- |------- | -------- | -------- |
| cv180x | RISC-V C906 | 64MByte | uart0 | 支持 MMU 支持 RT-Thread 标准版 和 RT-SMART 模式,默认运行 RT-Thread 标准版本 |
| cv181x | RISC-V C906 或 Cortex A53 通过硬件 IO 二选一 | 64MByte | uart0 | 支持 MMU 支持 RT-Thread 标准版 和 RT-SMART 版,默认运行 RT-Thread 标准版本 |
# RT-Samrt 版按照以下配置:
$ export RTT_CC_PREFIX=riscv64-unknown-linux-musl-
$ export RTT_EXEC_PATH=/opt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/bin
```
- 小核
## 依赖安装
```shell
$ sudo apt install -y scons libncurses5-dev device-tree-compiler
```
| 目录 | 内存大小 | 默认日志串口 | 备注 |
| ---- | ------- | -------- | --- |
| c906-little | 与大核共享 | uart1 | 无 MMU运行 RT-Thread 标准版 |
## 构建
> 注:异构芯片需单独编译每个核的 OS
## 编译
异构芯片需单独编译每个核的 OS在大/小核对应的目录下,依次执行:
1. 开发板选择
@ -42,35 +116,21 @@ Board Type (milkv-duo) --->
$ scons
```
## 运行
编译成功后,会在 `bsp/cvitek/output` 对应开发板型号目录下自动生成 `fip.bin``boot.sd` 文件,其中大核运行文件在 `boot.sd` 中,小核的运行文件在 `fip.bin` 中。
- fip.binfsbl、opensbi、uboot、小核运行文件打包后的 bin 文件
- boot.sd大核打包后的 bin 文件
# 运行
1. 将 SD 卡分为 2 个分区,第 1 个分区用于存放 bin 文件,第 2 个分区用于作为数据存储分区,分区格式为 `FAT32`
2. 将根目录下的 `fip.bin``boot.sd` 复制 SD 卡第一个分区中。
- fip.binfsbl、 opensbi、uboot、小核运行文件打包后的 bin 文件
- boot.sd大核打包后的 bin 文件
## 驱动支持列表
2. 将根目录下的 `fip.bin``boot.sd` 复制到 SD 卡第一个分区中。两个固件文件可以独立修改更新,譬如后续只需要更新大核,只需要重新编译 "cv18xx_risc-v" 并复制 `boot.sd` 文件即可。
| 驱动 | 支持情况 | 备注 |
| :--- | :------- | :---------------- |
| uart | 支持 | 默认波特率115200 |
| gpio | 支持 | |
| i2c | 支持 | |
| adc | 支持 | |
| spi | 支持 | 默认CS引脚每个数据之间CS会拉高请根据时序选择GPIO作为CS。若读取数据tx需持续dummy数据。|
| pwm | 支持 | |
| timer | 支持 | |
| wdt | 支持 | |
| sdio | 支持 | |
| eth | 支持 | |
3. 更新完固件文件后, 重新上电可以看到串口的输出信息。
## 支持开发板
- milk-v duo: [https://milkv.io/duo](https://milkv.io/duo)
- milk-v duo256m: [https://milkv.io/duo256m](https://milkv.io/docs/duo/getting-started/duo256m)
# FAQ
## FAQ
1. 如遇到不能正常编译,请先使用 `scons --menuconfig` 重新生成配置。
2. 错误:./mkimage: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
@ -84,8 +144,8 @@ $ sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
3. 如发现切换开发板编译正常,但无法正常打包,请切换至自动下载的 `cvi_bootloader` 目录,并手工运行 `git pull` 更新,或删除该目录后重新自动下载。
## 联系人信息
# 联系人信息
维护人:[flyingcys](https://github.com/flyingcys)
更多信息请参考 [https://riscv-rtthread-programming-manual.readthedocs.io](https://riscv-rtthread-programming-manual.readthedocs.io)
更多信息请参考 [https://riscv-rtthread-programming-manual.readthedocs.io](https://riscv-rtthread-programming-manual.readthedocs.io)

View File

@ -1,73 +0,0 @@
# c906_little bsp
该 bsp 为 cv18xx 系列处理器中的协处理器,采用 RISCV C906 @ 700Mhz。
特性:
- 无 MMU
- 集成浮点运算单元 (FPU)
## Toolchain 下载
下载 `riscv64-unknown-elf-gcc` 的工具链: [https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1705395512373/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.1-20240115.tar.gz](https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1705395512373/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.1-20240115.tar.gz)
> 注:
当前 bsp 只支持 Linux 编译
正确解压后,在`rtconfig.py`中将 `riscv64-unknown-elf-gcc` 工具链的本地路径加入 `EXEC_PATH` 或通过 `RTT_EXEC_PATH` 环境变量指定路径。
```shell
$ export RTT_EXEC_PATH=/opt/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.1/bin
```
## 编译
1. 依赖安装
```shell
$ sudo apt install -y scons libncurses5-dev wget flex bison
```
2. Linux平台下先执行
```shell
$ scons --menuconfig
```
选择当前需要编译的目标开发板类型:
```shell
Board Type (milkv-duo) --->
( ) milkv-duo
( ) milkv-duo-spinor
(X) milkv-duo256m
( ) milkv-duo256m-spinor
```
它会自动下载 env 相关脚本到 ~/.env 目录,然后执行
```shell
$ source ~/.env/env.sh
$ pkgs --update
```
更新完软件包后,执行 `scons -j10``scons -j10 --verbose` 来编译这个板级支持包。或者通过 `scons --exec-path="GCC工具链路径"` 命令在指定工具链位置的同时直接编译。编译正确无误会产生rtthread.elf 文件。
编译完成后脚本自动调用 `combine-fip.sh` 脚本进行打包,并生成 `fip.sd`, 该文件即为 SD 卡启动的 c906_little 文件。
第一次调用 `combine-fip.sh` 脚本时会自动下载打包需要的 `opsbsbi`、`fsbl`、`uboot` 等相关文件至 `bsp/cvitek/cvitek_bootloader` 目录,请耐心等待。
下载完成后会自动解压、编译,后续再次编译同一类型开发板只会调用相关文件打包合成 `fip.bin`。如需手工编译相关 `cvitek_bootloader` 文件,可在 `bsp/cvitek/cvitek_bootloader` 目录下执行 `bash build.sh lunch` 选择对应的开发板编译。
## 运行
1. 将 SD 卡分为 2 个分区,第 1 个分区用于存放 bin 文件,第 2 个分区用于作为数据存储分区,分区格式为 `FAT32`
2. 将根目录下的 `fip.bin``boot.sd` 复制 SD 卡第一个分区中。后续更新固件只需要复制 `fip.sd` 文件即可。
其中:
- fip.binfsbl、 opensbi、 uboot、c906_little 打包后的 bin 文件
- boot.sd大核打包后的 bin 文件
更新完 `fip.sd` 后, 重新上电可以看到串口的输出信息:
```shell
HW_HEAP_BEGIN:83f74dc0 RT_HW_HEAP_END:84000000 size: 569920
\ | /
- RT - Thread Operating System
/ | \ 5.1.0 build Jan 27 2024 22:45:49
2006 - 2022 Copyright by RT-Thread team
Hello, RISC-V!
msh />
```
> 注c906 小核默认日志串口为 uart1

View File

@ -1,72 +0,0 @@
# c906_little bsp
This BSP is a coprocessor in the cv18xx series processor, using RISCV C906 @ 700Mhz.
Features:
- No MMU
- Integrated Floating-point Unit (FPU)
## Toolchain Download
Download the toolchain for `riscv64-unknown-elf-gcc`: [https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1705395512373/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.1-20240115.tar.gz](https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1705395512373/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.1-20240115.tar.gz)
> Note:
Current BSP only supports Linux compilation.
After correct decompression, add the local path of the `riscv64-unknown-elf-gcc` toolchain to `EXEC_PATH` in `rtconfig.py`, or specify the path through the `RTT_EXEC_PATH` environment variable.
```shell
$ export RTT_EXEC_PATH=/opt/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.1/bin
```
## Compilation
1. Dependency Installation
```shell
$ sudo apt install -y scons libncurses5-dev wget flex bison
```
2. On Linux platform, execute:
```shell
$ scons --menuconfig
```
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
```shell
$ source ~/.env/env.sh
$ pkgs --update
```
After updating the software packages, execute `scons -j10` or `scons -j10 --verbose` to compile this BSP. Or use the `scons --exec-path="GCC toolchain path"` command to compile directly while specifying the toolchain location. If the compilation is correct, the rtthread.elf file will be generated.
After the compilation is completed, the script automatically calls the `combine-fip.sh` script for packaging, and generates `fip.sd`, which is the c906_little file for SD card startup.
The first time the `combine-fip.sh` script is called, it will automatically download the required `opsbsbi`, `fsbl`, `uboot`, and other related files to the `bsp/cvitek/cvitek_bootloader` directory, please be patient.
After downloading, it will automatically decompress and compile. Subsequently, when compiling the same type of development board again, only the relevant files will be called to package and synthesize `fip.bin`. If you need to manually compile the related `cvitek_bootloader` files, you can execute `bash build.sh lunch` in the `bsp/cvitek/cvitek_bootloader` directory to choose the corresponding development board for compilation.
## Running
1. Divide the SD card into 2 partitions, the 1st partition is used to store bin files, and the 2nd partition is used as a data storage partition, with the partition format being `FAT32`.
2. Copy the `fip.bin` and `boot.sd` from the root directory into the 1st partition of the SD card. Subsequent firmware updates only require copying the `fip.sd` file.
Where:
- fip.bin: fsbl, opensbi, uboot, c906_little packaged bin file
- boot.sd: bin file packaged by the main kernel
After updating `fip.sd`, restarting will show the output information on the serial port:
```shell
HW_HEAP_BEGIN:83f74dc0 RT_HW_HEAP_END:84000000 size: 569920
\ | /
- RT - Thread Operating System
/ | \ 5.1.0 build Jan 27 2024 22:45:49
2006 - 2022 Copyright by RT-Thread team
Hello, RISC-V!
msh />
```
> Note: The default log serial port for the c906 little core is uart1

View File

@ -1,148 +0,0 @@
**中文** | [English](README_en.md)
## 概述
CV18xx 系列芯片面向民用消费监控 IP 摄像机、居家智能等多项产品领域而推出的高性能、低功耗芯片,集成了 H.264/H.265 视频压缩编码器和 ISP支持数字寛动态、 3D 降噪、除雾、镜头畸变校正等多种图像增强和矫正算法,为客户提供专业级的视频图像质量。
1. 处理器内核
- 主处理器 RISCV C906 @ 1.0Ghz
- 32KB I-cache, 64KB D-Cache
- 集成矢量(Vector)及浮点运算单元 (FPU) .
- 协处理器 RISCV C906 @ 700Mhz
- 集成浮点运算单元 (FPU)
2. 存储器接口
- 内建 DRAM : DDR2 16bitx1, 最高速率达 1333Mbps , 容量512Mbit (64MB)
- 支持SPI NOR flash 接口 (1.8V / 3.0V)
- 支持 1, 2, 4 线模式
- 最大支持 256MByte
- 支持 SPI Nand flash 接口 (1.8V / 3.0V)
- 支持 1KB/2KB/4KB page (对应的最大容量 16GB/32GB/64GB)
- 使用器件本身内建的 ECC 模块
3. 外设
- Up to 26 GPIO pins on the MilkV-Duo 40-pin header provide access to internal peripherals such as SDIO, I2C, PWM, SPI, J-TAG, and UART
- Up to 3x I2C
- Up to 5x UART
- Up to 1x SDIO1
- Up to 1x SPI
- Up to 2x ADC
- Up to 7x PWM
- Up to 1x RUN
- Up to 1x JTAG
- 集成 MAC PHY 支持 10/100Mbps 全双工或半双工模式
- 一个 USB Host / device 接口
4. [GPIO 引脚分布](https://milkv.io/zh/docs/duo/getting-started/duo256m#gpio-%E5%BC%95%E8%84%9A%E5%88%86%E5%B8%83)
## Toolchain 下载
1. RT-Thread 标准版工具链:`riscv64-unknown-elf-gcc` 下载地址 [https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1705395512373/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.1-20240115.tar.gz](https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1705395512373/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.1-20240115.tar.gz)
2. RT-Smart 版工具链: `riscv64-unknown-linux-musl-gcc` 下载地址 [https://github.com/RT-Thread/toolchains-ci/releases/download/v1.7/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu_latest.tar.bz2](https://github.com/RT-Thread/toolchains-ci/releases/download/v1.7/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu_latest.tar.bz2)
> 注:
当前 bsp 只支持 Linux 编译,推荐 ubuntu 22.04
正确解压后,在`rtconfig.py`中将 `riscv64-unknown-elf-gcc``riscv64-unknown-linux-musl-gcc` 工具链的本地路径加入 `EXEC_PATH` 或通过 `RTT_EXEC_PATH` 环境变量指定路径。
```shell
# RT-Thread 标准版按照以下配置:
$ export RTT_CC_PREFIX=riscv64-unknown-elf-
$ export RTT_EXEC_PATH=/opt/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.1/bin
# RT-Samrt 版按照以下配置:
$ export RTT_CC_PREFIX=riscv64-unknown-linux-musl-
$ export RTT_EXEC_PATH=/opt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/bin
```
## 编译
### 依赖安装
```shell
$ sudo apt install -y scons libncurses5-dev device-tree-compiler
```
## 修改当前工程配置
Linux平台下执行
```shell
$ scons --menuconfig
```
1. 默认编译为 RT-Thread 标准版,如果需要编译为 RT-Smart 版,请按照如下方式修改:
```shell
RT-Thread Kernel --->
[*] Enable RT-Thread Smart (microkernel on kernel/userland)
(0x80000000) The virtural address of kernel start
```
2. 选择当前需要编译的目标开发板类型:
```shell
Board Type (milkv-duo) --->
( ) milkv-duo
( ) milkv-duo-spinor
(X) milkv-duo256m
( ) milkv-duo256m-spinor
```
它会自动下载env相关脚本到~/.env目录然后执行
```shell
$ source ~/.env/env.sh
$ pkgs --update
```
更新完软件包后,执行 `scons -j10``scons -j10 --verbose` 来编译这个板级支持包,编译正确无误,会产生 rtthread.elf 文件。
编译完成后脚本自动调用 `./mksdimg.sh` 脚本进行打包,并生成 `boot.sd`, 该文件即为 SD 卡启动的 kernel 文件。
## 运行
1. 将 SD 卡分为 2 个分区,第 1 个分区用于存放 bin 文件,第 2 个分区用于作为数据存储分区,分区格式为 `FAT32`
2. 将根目录下的 `fip.bin``boot.sd` 复制 SD 卡第一个分区中。后续更新固件只需要复制 `boot.sd` 文件即可。
其中:
- fip.binfsbl、 opensbi 和 uboot 打包后的 bin 文件
- boot.sdkernel 打包后的 bin 文件
更新完 `boot.sd` 后, 重新上电可以看到串口的输出信息:
```shell
U-Boot 2021.10 (Jun 26 2023 - 14:09:06 +0800)cvitek_cv180x
DRAM: 63.3 MiB
gd->relocaddr=0x82435000. offset=0x2235000
MMC: cv-sd@4310000: 0
Loading Environment from <NULL>... OK
In: serial
Out: serial
Err: serial
Net:
Warning: ethernet@4070000 (eth0) using random MAC address - 62:80:19:6c:d4:64
eth0: ethernet@4070000
Hit any key to stop autoboot: 0
Boot from SD ...
switch to partitions #0, OK
mmc0 is current device
132692 bytes read in 12 ms (10.5 MiB/s)
## Loading kernel from FIT Image at 81400000 ...
Using 'config-cv1800b_milkv_duo_sd' configuration
Trying 'kernel-1' kernel subimage
Verifying Hash Integrity ... crc32+ OK
## Loading fdt from FIT Image at 81400000 ...
Using 'config-cv1800b_milkv_duo_sd' configuration
Trying 'fdt-cv1800b_milkv_duo_sd' fdt subimage
Verifying Hash Integrity ... sha256+ OK
Booting using the fdt blob at 0x8141b590
Uncompressing Kernel Image
Decompressing 296768 bytes used 42ms
Loading Device Tree to 0000000081be5000, end 0000000081becb60 ... OK
Starting kernel ...
heap: [0x802766b0 - 0x812766b0]
\ | /
- RT - Thread Operating System
/ | \ 5.1.0 build Apr 7 2024 23:33:20
2006 - 2024 Copyright by RT-Thread team
Hello RISC-V!
msh />
```

View File

@ -1,147 +0,0 @@
[中文](README.md) | **English**
## Overview
The CV18xx series of chips are high-performance, low-power chips launched for various products in the field of civilian consumer surveillance IP cameras, smart homes, and more. These chips integrate H.264/H.265 video compression encoders, as well as ISP; they support various image enhancement and correction algorithms such as digital wide dynamic range, 3D noise reduction, defogging, and lens distortion correction, providing customers with professional-level video image quality.
1. Processor Core
- Main Processor: RISC-V C906 @ 1.0Ghz
- 32KB I-cache, 64KB D-Cache
- Integrated Vector and Floating-Point Unit (FPU).
- Co-processor: RISC-V C906 @ 700Mhz
- Integrated Floating-Point Unit (FPU)
2. Storage Interface
- Built-in DRAM: DDR2 16bitx1, with a maximum speed of 1333Mbps, and a capacity of 512Mbit (64MB)
- Support for SPI NOR flash interface (1.8V / 3.0V)
- Supports 1, 2, 4 line modes
- Maximum support of 256MByte
- Support for SPI Nand flash interface (1.8V / 3.0V)
- Supports 1KB/2KB/4KB page (corresponding to maximum capacity of 16GB/32GB/64GB)
- Utilizes the device's built-in ECC module
3. Peripherals
- Up to 26 GPIO pins on the MilkV-Duo 40-pin header provide access to internal peripherals such as SDIO, I2C, PWM, SPI, J-TAG, and UART
- Up to 3x I2C
- Up to 5x UART
- Up to 1x SDIO1
- Up to 1x SPI
- Up to 2x ADC
- Up to 7x PWM
- Up to 1x RUN
- Up to 1x JTAG
- Integrated MAC PHY supports 10/100Mbps full or half duplex mode
- One USB host/device interface
4. [GPIO pinout](https://milkv.io/docs/duo/getting-started/duo256m#gpio-pinout)
## Toolchain Download
1. RT-Thread Standard Edition Toolchain: `riscv64-unknown-elf-gcc` Download Link [https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1705395512373/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.1-20240115.tar.gz](https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1705395512373/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.1-20240115.tar.gz)
2. RT-Smart Edition Toolchain: `riscv64-unknown-linux-musl-gcc` Download Link [https://github.com/RT-Thread/toolchains-ci/releases/download/v1.7/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu_latest.tar.bz2](https://github.com/RT-Thread/toolchains-ci/releases/download/v1.7/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu_latest.tar.bz2)
> Note:
The current bsp only supports Linux compilation, and it is recommended to use Ubuntu 22.04
After correctly extracting, add the local path of the `riscv64-unknown-elf-gcc` or `riscv64-unknown-linux-musl-gcc` toolchain to `EXEC_PATH` in `rtconfig.py` or specify the path through the `RTT_EXEC_PATH` environment variable.
```shell
# For RT-Thread Standard Edition, use the following configuration:
$ export RTT_CC_PREFIX=riscv64-unknown-elf-
$ export RTT_EXEC_PATH=/opt/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.1/bin
# For RT-Smart Edition, use the following configuration:
$ export RTT_CC_PREFIX=riscv64-unknown-linux-musl-
$ export RTT_EXEC_PATH=/opt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/bin
```
## Compilation
### Dependency Installation
```shell
$ sudo apt install -y scons libncurses5-dev device-tree-compiler
```
## Modify Current Project Configuration
For the Linux platform, execute:
```shell
$ scons --menuconfig
```
1. By default, compile as RT-Thread Standard Edition. If you need to compile as RT-Smart Edition, modify as follows:
```shell
RT-Thread Kernel --->
[*] Enable RT-Thread Smart (microkernel on kernel/userland)
(0x80000000) The virtual address of kernel start
```
2. Select the current target development board type:
```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:
```shell
$ source ~/.env/env.sh
$ pkgs --update
```
After updating the software package, execute `scons -j10` or `scons -j10 --verbose` to compile this board support package. If the compilation is successful, an rtthread.elf file will be generated.
After the compilation is complete, the script automatically calls the `./mksdimg.sh` script to package and generate `boot.sd`, which is the kernel file for SD card startup.
## Running
1. Divide the SD card into 2 partitions, with the first partition used to store bin files, and the second partition used as a data storage partition, with `FAT32` format.
2. Copy the `fip.bin` and `boot.sd` files from the root directory to the first partition of the SD card. Subsequent firmware updates only require copying the `boot.sd` file.
Where:
- fip.bin: fsbl, opensbi, and uboot packaged bin file
- boot.sd: kernel packaged bin file
After updating `boot.sd`, restart to see the serial port output:
```shell
U-Boot 2021.10 (Jun 26 2023 - 14:09:06 +0800)cvitek_cv180x
DRAM: 63.3 MiB
gd->relocaddr=0x82435000. offset=0x2235000
MMC: cv-sd@4310000: 0
Loading Environment from <NULL>... OK
In: serial
Out: serial
Err: serial
Net:
Warning: ethernet@4070000 (eth0) using random MAC address - 62:80:19:6c:d4:64
eth0: ethernet@4070000
Hit any key to stop autoboot: 0
Boot from SD ...
switch to partitions #0, OK
mmc0 is current device
132692 bytes read in 12 ms (10.5 MiB/s)
## Loading kernel from FIT Image at 81400000 ...
Using 'config-cv1800b_milkv_duo_sd' configuration
Trying 'kernel-1' kernel subimage
Verifying Hash Integrity ... crc32+ OK
## Loading fdt from FIT Image at 81400000 ...
Using 'config-cv1800b_milkv_duo_sd' configuration
Trying 'fdt-cv1800b_milkv_duo_sd' fdt subimage
Verifying Hash Integrity ... sha256+ OK
Booting using the fdt blob at 0x8141b590
Uncompressing Kernel Image
Decompressing 296768 bytes used 42ms
Loading Device Tree to 0000000081be5000, end 0000000081becb60 ... OK
Starting kernel ...
heap: [0x802766b0 - 0x812766b0]
\ | /
- RT - Thread Operating System
/ | \ 5.1.0 build Apr 7 2024 23:33:20
2006 - 2024 Copyright by RT-Thread team
Hello RISC-V!
msh />
```