Skip to content

Commit 0a2e150

Browse files
committed
update readme
1 parent 1ab8f46 commit 0a2e150

File tree

2 files changed

+228
-141
lines changed

2 files changed

+228
-141
lines changed

bsp/xuantie/virt64/c906/README.md

Lines changed: 190 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,228 @@
1-
# XuanTie - C906 Series
1+
# QEMU/RISCV64/C906 VIRT Board Support Package User Guide
22

3-
## 一 简介
3+
English | [中文](./README_cn.md)
44

5-
### 1. 内核
5+
<!-- TOC -->
66

7-
C906 是基于 RISC-V 指令架构的 64 位超高能效处理器,主要面向安防监控、智能音箱、扫码/刷脸支付等领域。
7+
- [QEMU/RISCV64/C906 VIRT Board Support Package User Guide](#qemuriscv64c906-virt-board-support-package-user-guide)
8+
- [1. Introduction](#1-introduction)
9+
- [2. Building](#2-building)
10+
- [2.1. Installing the toolchain](#21-installing-the-toolchain)
11+
- [2.2. Setting RT-Thread toolchain environment variables](#22-setting-rt-thread-toolchain-environment-variables)
12+
- [2.3. Downloading the kernel](#23-downloading-the-kernel)
13+
- [2.4. Configuring the kernel](#24-configuring-the-kernel)
14+
- [2.5. Compiling the kernel](#25-compiling-the-kernel)
15+
- [3. Running](#3-running)
16+
- [3.1. Installing QEMU](#31-installing-qemu)
17+
- [3.2. Running QEMU](#32-running-qemu)
18+
- [3.2.1. Running RT-Thread Smart version](#321-running-rt-thread-smart-version)
819

9-
### 2.特点
20+
<!-- /TOC -->
1021

11-
• RV64IMA[FD]C[V] 指令架构;
22+
## 1. Introduction
1223

13-
• 5 级单发按序执行流水线;
24+
RISC-V is an open and free instruction set architecture (ISA). This project is based on QEMU's RISC-V64 VIRT platform, ported to the C906 processor platform.
1425

15-
• 一级哈佛结构的指令和数据缓存,大小为 8KB/16KB/32KB/64KB 可配置,缓存行为 64B;
26+
## 2. Building
1627

17-
• Sv39 内存管理单元,实现虚实地址转换与内存管理;
28+
Working system: take Ubuntu 24.04 as an example:
1829

19-
• 支持 AXI4.0 128 比特 Master 接口;
30+
```shell
31+
$ lsb_release -a
32+
No LSB modules are available.
33+
Distributor ID: Ubuntu
34+
Description: Ubuntu 24.04.2 LTS
35+
Release: 24.04
36+
Codename: noble
37+
```
38+
39+
### 2.1. Installing the toolchain
40+
41+
- Compiler: [Xuantie-900-gcc-linux-6.6.0-musl64-x86_64-V3.0.2-20250410.tar.gz](https://www.xrvm.cn/community/download?id=4433353576298909696)
42+
- Emulator: [Xuantie-qemu-x86_64-Ubuntu-20.04-V5.0.5-B20250108-0335.tar.gz](https://www.xrvm.cn/community/download?id=4397435198627713024)
43+
44+
Note: If the emulator in the above link does not work, you can compile the emulator using the following repository
45+
> [XUANTIE-RV/qemu](https://github.com/XUANTIE-RV/qemu )
46+
47+
### 2.2. Setting RT-Thread toolchain environment variables
48+
49+
There are three environment variables related to the RT-Thread toolchain
50+
51+
- `RTT_CC` is the toolchain name, which is `"gcc"` here
52+
- `RTT_CC_PREFIX`: is the toolchain prefix, in this case `"riscv64-unknown-elf-"` for the Standard Edition and `"riscv64-unknown-linux-musl-"` for the Smart Edition.
53+
- `RTT_EXEC_PATH`: the path to the bin folder of the toolchain, e.g. `"$HOME/tools/Xuantie-900-gcc-linux-6.6.0-musl64-x86_64-V3.0.2/bin"`, this is based on the path of the toolchain that was downloaded and unpacked by the user. Thread Standard and Smart versions are two different toolchains, and the path name of `RTT_EXEC_PATH` should be set to `bin`.
54+
55+
>Note: This may vary for different toolchains `RTT_CC_PREFIX`, which can be viewed in the toolchain bin folder path.
56+
It is recommended to export these three environment variables in the `.bashrc` file if you use them all the time.
57+
58+
### 2.3. Downloading the kernel
59+
60+
Assume that the working path is `$WORKSPACE`.
61+
62+
```shell
63+
cd $WORKSPACE
64+
git clone [email protected]:RT-Thread/rt-thread.git
65+
```
66+
67+
Enter xuantie/virt64/c906 the location of the BSP directory, the latter operation is not otherwise described, the default is in this directory.
68+
69+
```shell
70+
cd $WORKSPACE/rt-thread/bsp/xuantie/virt64/c906
71+
```
2072

21-
• 支持核内中断 CLINT 和中断控制器 PLIC;
73+
### 2.4. Configuring the kernel
2274

23-
• 支持 RISC-V Debug 标准。
75+
Refresh the configuration file before compiling for the first time.
2476

25-
• 遵循 RISC-V V 矢量扩展标准(revision 0.7.1);
77+
```shell
78+
scons --menuconfig
79+
```
2680

27-
• 算力可达 4G Flops(@1GHz);
81+
If you want to use the RT-Thread Smart version, at least turn on the `RT_USING_SMART` option after entering the configuration menu (see the figure below), and the rest depends on your needs.
2882

29-
• 支持矢量执行单元运算宽度 64 位和 128 位硬件可配置;
83+
```kconfiglib
84+
(Top) → RT-Thread Kernel
85+
RT-Thread Project Configuration
86+
(24) The maximal size of kernel object name
87+
[ ] Use the data types defined in ARCH_CPU
88+
[*] Enable RT-Thread Smart (microkernel on kernel/userland)
89+
[ ] Enable RT-Thread Nano
90+
...
91+
```
3092

31-
• 支持 INT8/INT16/INT32/INT64/FP16/FP32/BFP16 矢量运算;
93+
Save and exit after modification.
3294

33-
### 3.BSP支持情况
95+
### 2.5. Compiling the kernel
3496

35-
- 当前BSP支持下述内核:
97+
If you have compiled before, you can clean it up:
3698

37-
```asciiarmor
38-
c906 c906fd c906fdv
39-
```
99+
```shell
100+
scons --clean
101+
```
40102

41-
- 当前BSP默认设置的内核是c906,该架构支持[F] [D]扩展,可以通过menuconfig工具使能[F]扩展或者[F] [D] 扩展。
103+
Or compile directly:
42104

43-
- 当使用其他内核架构时需要修改,rtconfig.py文件中的`MCPU`字段。
105+
```shell
106+
scons -j$(nproc)
107+
```
44108

45-
### 4.运行QEMU
109+
The kernel binary file `rtthread.bin` will be generated in the `$WORKSPACE/rt-thread/bsp/xuantie/virt64/c906`.
46110

47-
- BSP根目录下存在`qemu.bat`脚本,生成可执行文件后可点击该脚本直接启动QEMU.
111+
## 3. Running
48112

49-
## 二 工具
113+
### 3.1. Installing QEMU
50114

51-
- 编译器: https://www.xrvm.cn/community/download?id=4433353576298909696
52-
- 模拟器: https://www.xrvm.cn/community/download?id=4397435198627713024
115+
Here the qemu emulator is installed by compiling the `XUANTIE-RV/qemu` repository.
53116

54-
注:若上述链接中的编译器与模拟器不能使用,可以使用下述CDK中的编译器与模拟器
117+
```shell
55118

56-
- SDK:https://www.xrvm.cn/community/download?id=4397799570420076544
119+
git clone [email protected]:XUANTIE-RV/qemu.git
57120

58-
## 三 调试方法
121+
mkdir build
59122

60-
**下述调试方法以E906举例,本BSP操作方式一致**,搭建完成RT-Thread开发环境,在BSP根目录使用env工具在当前目录打开env。
123+
cd build
61124

62-
![](figures/1.env.png)
125+
../configure --target-list="riscv64-softmmu riscv64-linux-user"
63126

64-
使用前执行一次**menuconfig**命令,更新rtconfig.h配置,然后在当前目录执行**scons -j12**命令编译生成可可执行文件。
127+
make -j8
65128

66-
<img src="figures/2.scons.png" alt="env" style="zoom: 95%;" />
129+
make install
130+
```
131+
132+
After the installation is complete, you can check the version.
133+
134+
```shell
135+
$ qemu-system-riscv64 --version
136+
QEMU emulator version 8.2.94 (v6.1.0-22774-ge0ace167ef)
137+
Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers
138+
```
139+
140+
### 3.2. Running QEMU
67141

68-
生成可执行文件,可以直接在命令行启动qemu或者配置vscode脚本借助vscode强大的插件进行图形化调试,qemu的相关命令可以查看玄铁qemu的[用户手册](https://www.xrvm.cn/community/download?id=4397435198627713024),下述是启动qemu的命令,在powershell或命令行可直接执行下述命令,注意qemu需要导出至环境变量或者使用绝对路径。
142+
The repository has provided a ready-made execution script, which can be executed directly:
69143

70144
```shell
71-
qemu-system-riscv64 -machine smartl -nographic -kernel rtthread.elf -cpu e906
145+
./run.sh
72146
```
73147

74-
下述是使用vscode调试的展示。
148+
#### 3.2.1. Running RT-Thread Smart version
75149

76-
<img src="figures/3.vscode.png" alt="env" style="zoom: 63%;" />
150+
The following is an example:
77151

78-
一起为RISC-V加油!
152+
```shell
153+
$ ./run.sh
154+
155+
OpenSBI v1.4
156+
____ _____ ____ _____
157+
/ __ \ / ____| _ \_ _|
158+
| | | |_ __ ___ _ __ | (___ | |_) || |
159+
| | | | '_ \ / _ \ '_ \ \___ \| _ < | |
160+
| |__| | |_) | __/ | | |____) | |_) || |_
161+
\____/| .__/ \___|_| |_|_____/|____/_____|
162+
| |
163+
|_|
164+
165+
Platform Name : riscv-virtio,qemu
166+
Platform Features : medeleg
167+
Platform HART Count : 1
168+
Platform IPI Device : aclint-mswi
169+
Platform Timer Device : aclint-mtimer @ 10000000Hz
170+
Platform Console Device : uart8250
171+
Platform HSM Device : ---
172+
Platform PMU Device : ---
173+
Platform Reboot Device : syscon-reboot
174+
Platform Shutdown Device : syscon-poweroff
175+
Platform Suspend Device : ---
176+
Platform CPPC Device : ---
177+
Firmware Base : 0x80000000
178+
Firmware Size : 323 KB
179+
Firmware RW Offset : 0x40000
180+
Firmware RW Size : 67 KB
181+
Firmware Heap Offset : 0x48000
182+
Firmware Heap Size : 35 KB (total), 2 KB (reserved), 9 KB (used), 23 KB (free)
183+
Firmware Scratch Size : 4096 B (total), 328 B (used), 3768 B (free)
184+
Runtime SBI Version : 2.0
185+
186+
Domain0 Name : root
187+
Domain0 Boot HART : 0
188+
Domain0 HARTs : 0*
189+
Domain0 Region00 : 0x0000000000100000-0x0000000000100fff M: (I,R,W) S/U: (R,W)
190+
Domain0 Region01 : 0x0000000010000000-0x0000000010000fff M: (I,R,W) S/U: (R,W)
191+
Domain0 Region02 : 0x0000000002000000-0x000000000200ffff M: (I,R,W) S/U: ()
192+
Domain0 Region03 : 0x0000000080040000-0x000000008005ffff M: (R,W) S/U: ()
193+
Domain0 Region04 : 0x0000000080000000-0x000000008003ffff M: (R,X) S/U: ()
194+
Domain0 Region05 : 0x000000000c400000-0x000000000c5fffff M: (I,R,W) S/U: (R,W)
195+
Domain0 Region06 : 0x000000000c000000-0x000000000c3fffff M: (I,R,W) S/U: (R,W)
196+
Domain0 Region07 : 0x0000000000000000-0xffffffffffffffff M: () S/U: (R,W,X)
197+
Domain0 Next Address : 0x0000000080200000
198+
Domain0 Next Arg1 : 0x000000008fe00000
199+
Domain0 Next Mode : S-mode
200+
Domain0 SysReset : yes
201+
Domain0 SysSuspend : yes
202+
203+
Boot HART ID : 0
204+
Boot HART Domain : root
205+
Boot HART Priv Version : v1.10
206+
Boot HART Base ISA : rv64imafdc
207+
Boot HART ISA Extensions : zicntr,zihpm
208+
Boot HART PMP Count : 16
209+
Boot HART PMP Granularity : 2 bits
210+
Boot HART PMP Address Bits: 54
211+
Boot HART MHPM Info : 16 (0x0007fff8)
212+
Boot HART MIDELEG : 0x0000000000000222
213+
Boot HART MEDELEG : 0x000000000000b109
214+
heap: [0x003280c0 - 0x043280c0]
215+
216+
\ | /
217+
- RT - Thread Smart Operating System
218+
/ | \ 5.2.1 build Jun 9 2025 09:03:23
219+
2006 - 2024 Copyright by RT-Thread team
220+
lwIP-2.0.3 initialized!
221+
[I/sal.skt] Socket Abstraction Layer initialize success.
222+
[I/utest] utest is initialize success.
223+
[I/utest] total utest testcase num: (1)
224+
[I/drivers.serial] Using /dev/ttyS0 as default console
225+
file system initialization done!
226+
Hello RISC-V
227+
msh />
228+
```

0 commit comments

Comments
 (0)