• Home
  • Annotate
  • current directory
Name Date Size #Lines LOC

..21-Aug-2025-

applications/21-Aug-2025-

board/21-Aug-2025-

libcpu/21-Aug-2025-

.config A D21-Aug-202550.9 KiB1,5711,453

Kconfig A D21-Aug-2025609 2923

README.md A D21-Aug-202512.5 KiB339266

README_cn.md A D21-Aug-202511.9 KiB341266

SConscript A D21-Aug-2025331 1612

SConstruct A D21-Aug-20251.4 KiB5239

link_smart.lds A D21-Aug-20253.5 KiB152147

link_stacksize.lds A D21-Aug-202524 21

rtconfig.h A D21-Aug-202511.7 KiB533179

rtconfig.py A D21-Aug-20251.6 KiB5239

run.sh A D21-Aug-2025862 3123

README.md

1# QEMU/RISCV64/C906 VIRT Board Support Package User Guide
2
3English | [中文](./README_cn.md)
4
5<!-- TOC -->
6
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)
19    - [3.2.2. Running RT-Thread Smart Edition + Root File System](#322-running-rt-thread-smart-edition--root-file-system)
20  - [4. Contact Information](#4-contact-information)
21
22<!-- /TOC -->
23
24## 1. Introduction
25
26RISC-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.
27
28## 2. Building
29
30Working system: take Ubuntu 24.04 as an example:
31
32```shell
33$ lsb_release -a
34No LSB modules are available.
35Distributor ID: Ubuntu
36Description:    Ubuntu 24.04.2 LTS
37Release:        24.04
38Codename:       noble
39```
40
41### 2.1. Installing the toolchain
42
43- Compiler: [Xuantie-900-gcc-linux-6.6.0-musl64-x86_64-V3.0.2-20250410.tar.gz](https://github.com/RT-Thread/toolchains-ci/releases/download/v1.9/Xuantie-900-gcc-linux-6.6.0-musl64-x86_64-V3.0.2.tar.gz)
44- Emulator: [Xuantie-qemu-x86_64-Ubuntu-20.04-V5.0.5-B20250108-0335.tar.gz](https://www.xrvm.cn/community/download?id=4397435198627713024)
45
46Note: If the emulator in the above link does not work, you can compile the emulator using the following repository
47> [XUANTIE-RV/qemu](https://github.com/XUANTIE-RV/qemu )
48
49### 2.2. Setting RT-Thread toolchain environment variables
50
51There are three environment variables related to the RT-Thread toolchain
52
53- `RTT_CC` is the toolchain name, which is `"gcc"` here
54- `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.
55- `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`.
56
57>Note: This may vary for different toolchains `RTT_CC_PREFIX`, which can be viewed in the toolchain bin folder path.
58It is recommended to export these three environment variables in the `.bashrc` file if you use them all the time.
59
60### 2.3. Downloading the kernel
61
62Assume that the working path is `$WORKSPACE`.
63
64```shell
65cd $WORKSPACE
66git clone git@github.com:RT-Thread/rt-thread.git
67```
68
69Enter xuantie/virt64/c906 the location of the BSP directory, the latter operation is not otherwise described, the default is in this directory.
70
71```shell
72cd $WORKSPACE/rt-thread/bsp/xuantie/virt64/c906
73```
74
75### 2.4. Configuring the kernel
76
77Refresh the configuration file before compiling for the first time.
78
79```shell
80scons --menuconfig
81```
82
83If 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.
84
85```kconfiglib
86(Top) → RT-Thread Kernel
87                                        RT-Thread Project Configuration
88(24) The maximal size of kernel object name
89[ ] Use the data types defined in ARCH_CPU
90[*] Enable RT-Thread Smart (microkernel on kernel/userland)
91[ ] Enable RT-Thread Nano
92...
93```
94
95Save and exit after modification.
96
97### 2.5. Compiling the kernel
98
99If you have compiled before, you can clean it up:
100
101```shell
102scons --clean
103```
104
105Or compile directly:
106
107```shell
108scons -j$(nproc)
109```
110
111The kernel binary file `rtthread.bin` will be generated in the `$WORKSPACE/rt-thread/bsp/xuantie/virt64/c906`.
112
113## 3. Running
114
115### 3.1. Installing QEMU
116
117Here the qemu emulator is installed by compiling the `XUANTIE-RV/qemu` repository.
118
119```shell
120
121git clone git@github.com:XUANTIE-RV/qemu.git
122
123mkdir build
124
125cd build
126
127../configure --target-list="riscv64-softmmu riscv64-linux-user"
128
129make -j8
130
131make install
132```
133
134After the installation is complete, you can check the version.
135
136```shell
137$ qemu-system-riscv64 --version
138QEMU emulator version 8.2.94 (v6.1.0-22774-ge0ace167ef)
139Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers
140```
141
142### 3.2. Running QEMU
143
144The repository has provided a ready-made execution script, which can be executed directly:
145
146```shell
147./run.sh
148```
149
150#### 3.2.1. Running RT-Thread Smart version
151
152The following is an example:
153
154```shell
155$ ./run.sh
156
157OpenSBI v1.4
158   ____                    _____ ____ _____
159  / __ \                  / ____|  _ \_   _|
160 | |  | |_ __   ___ _ __ | (___ | |_) || |
161 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
162 | |__| | |_) |  __/ | | |____) | |_) || |_
163  \____/| .__/ \___|_| |_|_____/|____/_____|
164        | |
165        |_|
166
167Platform Name             : riscv-virtio,qemu
168Platform Features         : medeleg
169Platform HART Count       : 1
170Platform IPI Device       : aclint-mswi
171Platform Timer Device     : aclint-mtimer @ 10000000Hz
172Platform Console Device   : uart8250
173Platform HSM Device       : ---
174Platform PMU Device       : ---
175Platform Reboot Device    : syscon-reboot
176Platform Shutdown Device  : syscon-poweroff
177Platform Suspend Device   : ---
178Platform CPPC Device      : ---
179Firmware Base             : 0x80000000
180Firmware Size             : 323 KB
181Firmware RW Offset        : 0x40000
182Firmware RW Size          : 67 KB
183Firmware Heap Offset      : 0x48000
184Firmware Heap Size        : 35 KB (total), 2 KB (reserved), 9 KB (used), 23 KB (free)
185Firmware Scratch Size     : 4096 B (total), 328 B (used), 3768 B (free)
186Runtime SBI Version       : 2.0
187
188Domain0 Name              : root
189Domain0 Boot HART         : 0
190Domain0 HARTs             : 0*
191Domain0 Region00          : 0x0000000000100000-0x0000000000100fff M: (I,R,W) S/U: (R,W)
192Domain0 Region01          : 0x0000000010000000-0x0000000010000fff M: (I,R,W) S/U: (R,W)
193Domain0 Region02          : 0x0000000002000000-0x000000000200ffff M: (I,R,W) S/U: ()
194Domain0 Region03          : 0x0000000080040000-0x000000008005ffff M: (R,W) S/U: ()
195Domain0 Region04          : 0x0000000080000000-0x000000008003ffff M: (R,X) S/U: ()
196Domain0 Region05          : 0x000000000c400000-0x000000000c5fffff M: (I,R,W) S/U: (R,W)
197Domain0 Region06          : 0x000000000c000000-0x000000000c3fffff M: (I,R,W) S/U: (R,W)
198Domain0 Region07          : 0x0000000000000000-0xffffffffffffffff M: () S/U: (R,W,X)
199Domain0 Next Address      : 0x0000000080200000
200Domain0 Next Arg1         : 0x000000008fe00000
201Domain0 Next Mode         : S-mode
202Domain0 SysReset          : yes
203Domain0 SysSuspend        : yes
204
205Boot HART ID              : 0
206Boot HART Domain          : root
207Boot HART Priv Version    : v1.10
208Boot HART Base ISA        : rv64imafdc
209Boot HART ISA Extensions  : zicntr,zihpm
210Boot HART PMP Count       : 16
211Boot HART PMP Granularity : 2 bits
212Boot HART PMP Address Bits: 54
213Boot HART MHPM Info       : 16 (0x0007fff8)
214Boot HART MIDELEG         : 0x0000000000000222
215Boot HART MEDELEG         : 0x000000000000b109
216heap: [0x003280c0 - 0x043280c0]
217
218 \ | /
219- RT -     Thread Smart Operating System
220 / | \     5.2.1 build Jun  9 2025 09:03:23
221 2006 - 2024 Copyright by RT-Thread team
222lwIP-2.0.3 initialized!
223[I/sal.skt] Socket Abstraction Layer initialize success.
224[I/utest] utest is initialize success.
225[I/utest] total utest testcase num: (1)
226[I/drivers.serial] Using /dev/ttyS0 as default console
227file system initialization done!
228Hello RISC-V
229msh />
230```
231
232### 3.2.2. Running RT-Thread Smart Edition + Root File System
233
234For the Smart kernel, you can also mount the root filesystem during the boot process by specifying the path to the root filesystem image when executing the `run.sh` script.
235
236Note that the kernel supports fat by default, and if you want to mount an ext4 filesystem, you need to install the lwext4 package, even if you can `PKG_USING_LWEXT4`
237> the menuconfig path is (Top) -> RT-Thread online packages -> system). packages -> lwext4: an excellent choice of ext2/3/4 filesystem for microcontrollers.
238
239If you can't find the package in the menu, you can exit menuconfig and run `pkgs --upgrade` to update the package index before trying to enable the package.
240After checking this option, you will also need to update the software and install the source code into the packages directory of bsp as follows (you only need to do this once):
241
242```shell
243source ~/.env/env.sh
244pkgs --update
245```
246
247Save and recompile the kernel.
248
249For more information on how to make a root filesystem, please refer to <https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-smart/quick-start/qemu-xuantie/quickstart>, which will not be repeated here.
250
251The example is as follows:
252
253```shell
254$ bash run.sh ext4.img
255
256OpenSBI v1.4
257   ____                    _____ ____ _____
258  / __ \                  / ____|  _ \_   _|
259 | |  | |_ __   ___ _ __ | (___ | |_) || |
260 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
261 | |__| | |_) |  __/ | | |____) | |_) || |_
262  \____/| .__/ \___|_| |_|_____/|____/_____|
263        | |
264        |_|
265
266Platform Name             : riscv-virtio,qemu
267Platform Features         : medeleg
268Platform HART Count       : 1
269Platform IPI Device       : aclint-mswi
270Platform Timer Device     : aclint-mtimer @ 10000000Hz
271Platform Console Device   : uart8250
272Platform HSM Device       : ---
273Platform PMU Device       : ---
274Platform Reboot Device    : syscon-reboot
275Platform Shutdown Device  : syscon-poweroff
276Platform Suspend Device   : ---
277Platform CPPC Device      : ---
278Firmware Base             : 0x80000000
279Firmware Size             : 323 KB
280Firmware RW Offset        : 0x40000
281Firmware RW Size          : 67 KB
282Firmware Heap Offset      : 0x48000
283Firmware Heap Size        : 35 KB (total), 2 KB (reserved), 9 KB (used), 23 KB (free)
284Firmware Scratch Size     : 4096 B (total), 328 B (used), 3768 B (free)
285Runtime SBI Version       : 2.0
286
287Domain0 Name              : root
288Domain0 Boot HART         : 0
289Domain0 HARTs             : 0*
290Domain0 Region00          : 0x0000000000100000-0x0000000000100fff M: (I,R,W) S/U: (R,W)
291Domain0 Region01          : 0x0000000010000000-0x0000000010000fff M: (I,R,W) S/U: (R,W)
292Domain0 Region02          : 0x0000000002000000-0x000000000200ffff M: (I,R,W) S/U: ()
293Domain0 Region03          : 0x0000000080040000-0x000000008005ffff M: (R,W) S/U: ()
294Domain0 Region04          : 0x0000000080000000-0x000000008003ffff M: (R,X) S/U: ()
295Domain0 Region05          : 0x000000000c400000-0x000000000c5fffff M: (I,R,W) S/U: (R,W)
296Domain0 Region06          : 0x000000000c000000-0x000000000c3fffff M: (I,R,W) S/U: (R,W)
297Domain0 Region07          : 0x0000000000000000-0xffffffffffffffff M: () S/U: (R,W,X)
298Domain0 Next Address      : 0x0000000080200000
299Domain0 Next Arg1         : 0x000000008fe00000
300Domain0 Next Mode         : S-mode
301Domain0 SysReset          : yes
302Domain0 SysSuspend        : yes
303
304Boot HART ID              : 0
305Boot HART Domain          : root
306Boot HART Priv Version    : v1.10
307Boot HART Base ISA        : rv64imafdc
308Boot HART ISA Extensions  : zicntr,zihpm
309Boot HART PMP Count       : 16
310Boot HART PMP Granularity : 2 bits
311Boot HART PMP Address Bits: 54
312Boot HART MHPM Info       : 16 (0x0007fff8)
313Boot HART MIDELEG         : 0x0000000000000222
314Boot HART MEDELEG         : 0x000000000000b109
315heap: [0x003404c0 - 0x043404c0]
316
317 \ | /
318- RT -     Thread Smart Operating System
319 / | \     5.2.1 build Jun 13 2025 09:43:35
320 2006 - 2024 Copyright by RT-Thread team
321[I/utest] utest is initialize success.
322[I/utest] total utest testcase num: (1)
323[I/drivers.serial] Using /dev/ttyS0 as default console
324[W/DFS.fs] mount / failed with file system type: elm
325file system initialization done!
326Hello RISC-V
327msh />/ #
328/ #
329/ # ls
330bin         lib         proc        sbin        usr
331dev         lost+found  root        services    var
332etc         mnt         run         tmp
333/ #
334```
335
336## 4. Contact Information
337
338If you are interested in making an inquiry, please contact: <business@rt-thread.com>
339

README_cn.md

1
2# QEMU/RISCV64/C906 VIRT 板级支持包使用说明
3
4中文页 | [English](./README.md)
5
6<!-- TOC -->
7
8- [QEMU/RISCV64/C906 VIRT 板级支持包使用说明](#qemuriscv64c906-virt-板级支持包使用说明)
9  - [1. 简介](#1-简介)
10  - [2. 构建](#2-构建)
11    - [2.1. 安装工具链](#21-安装工具链)
12    - [2.2. 设置 RT-Thread 工具链环境变量](#22-设置-rt-thread-工具链环境变量)
13    - [2.3. 下载内核](#23-下载内核)
14    - [2.4. 配置内核](#24-配置内核)
15    - [2.5. 编译内核](#25-编译内核)
16  - [3. 运行](#3-运行)
17    - [3.1. 安装 QEMU](#31-安装-qemu)
18    - [3.2. 运行 QEMU](#32-运行-qemu)
19      - [3.2.1. 运行 RT-Thread Smart 版](#321-运行-rt-thread-smart-版)
20    - [3.2.2. 运行 RT-Thread Smart 版 + 根文件系统](#322-运行-rt-thread-smart-版--根文件系统)
21  - [4. 联系人信息](#4-联系人信息)
22
23<!-- /TOC -->
24
25## 1. 简介
26
27RISC-V 是一种开放和免费的指令集体系结构 (ISA)。本工程基于 QEMU 的 RISC-V64 VIRT 平台,移植至 C906 处理器平台。
28
29## 2. 构建
30
31工作系统:以 Ubuntu 24.04 为例:
32
33```shell
34$ lsb_release -a
35No LSB modules are available.
36Distributor ID: Ubuntu
37Description:    Ubuntu 24.04.2 LTS
38Release:        24.04
39Codename:       noble
40```
41
42### 2.1. 安装工具链
43
44- 编译器: [Xuantie-900-gcc-linux-6.6.0-musl64-x86_64-V3.0.2-20250410.tar.gz](https://github.com/RT-Thread/toolchains-ci/releases/download/v1.9/Xuantie-900-gcc-linux-6.6.0-musl64-x86_64-V3.0.2.tar.gz)
45- 模拟器: [Xuantie-qemu-x86_64-Ubuntu-20.04-V5.0.5-B20250108-0335.tar.gz](https://www.xrvm.cn/community/download?id=4397435198627713024)
46
47注:若上述链接中的模拟器不能使用,可以使用下述仓库编译模拟器
48> [XUANTIE-RV/qemu](https://github.com/XUANTIE-RV/qemu)
49
50### 2.2. 设置 RT-Thread 工具链环境变量
51
52和 RT-Thread 工具链相关的环境变量有三个
53
54- `RTT_CC` 为工具链名称, 这里统一为 `"gcc"`
55- `RTT_CC_PREFIX`: 为工具链前缀, 这里对于标准版是 `"riscv64-unknown-elf-"`,对于 Smart 版是 `"riscv64-unknown-linux-musl-"`。
56- `RTT_EXEC_PATH`: 工具链的 bin 文件夹所在路径, 如 `"$HOME/tools/Xuantie-900-gcc-linux-6.6.0-musl64-x86_64-V3.0.2/bin"`, 这个根据个人下载解压后的实际路径进行设置,注意 RT-Thread 标准版和 Smart 版本的工具链是两套不同的版本,而且设置 `RTT_EXEC_PATH` 的路径名时要一直到 `bin`。
57
58>注:对于不同的工具链`RTT_CC_PREFIX`可能有所不同,可在工具链 bin 文件夹所在路径下查看
59如果一直使用的话,建议将这三个环境变量在 `.bashrc` 文件中 export。
60
61### 2.3. 下载内核
62
63假设工作路径是 `$WORKSPACE`。
64
65```shell
66cd $WORKSPACE
67git clone git@github.com:RT-Thread/rt-thread.git
68```
69
70进入 xuantie/virt64/c906 所在 BSP 目录,后面的操作不做另外介绍,默认就在这个目录下。
71
72```shell
73cd $WORKSPACE/rt-thread/bsp/xuantie/virt64/c906
74```
75
76### 2.4. 配置内核
77
78第一次编译前先刷新一下配置文件。
79
80```shell
81scons --menuconfig
82```
83
84要使用 RT-Thread Smart 版,进入配置菜单后至少要打开 `RT_USING_SMART` 这个选项(见下图),其他的看自己的需求,如果此处已开启,直接保存退出即可。
85
86```kconfiglib
87(Top) → RT-Thread Kernel
88                                        RT-Thread Project Configuration
89(24) The maximal size of kernel object name
90[ ] Use the data types defined in ARCH_CPU
91[*] Enable RT-Thread Smart (microkernel on kernel/userland)
92[ ] Enable RT-Thread Nano
93...
94```
95
96修改后保存退出。
97
98### 2.5. 编译内核
99
100如果以前编译后,可以清理一下:
101
102```shell
103scons --clean
104```
105
106或者直接编译:
107
108```shell
109scons -j$(nproc)
110```
111
112在 `$WORKSPACE/rt-thread/bsp/xuantie/virt64/c906` 路径下会生成内核的二进制文件 `rtthread.bin`。
113
114## 3. 运行
115
116### 3.1. 安装 QEMU
117
118这里通过编译`XUANTIE-RV/qemu`仓库安装qemu模拟器
119
120```shell
121
122git clone git@github.com:XUANTIE-RV/qemu.git
123
124mkdir build
125
126cd build
127
128../configure --target-list="riscv64-softmmu riscv64-linux-user"
129
130make -j8
131
132make install
133
134```
135
136安装完毕后可以看一下版本。
137
138```shell
139$ qemu-system-riscv64 --version
140QEMU emulator version 8.2.94 (v6.1.0-22774-ge0ace167ef)
141Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers
142```
143
144### 3.2. 运行 QEMU
145
146仓库里已经提供了现成的执行脚本,可以直接执行:
147
148```shell
149 ./run.sh
150```
151
152#### 3.2.1. 运行 RT-Thread Smart 版
153
154示例如下:
155
156```shell
157$ ./run.sh
158
159OpenSBI v1.4
160   ____                    _____ ____ _____
161  / __ \                  / ____|  _ \_   _|
162 | |  | |_ __   ___ _ __ | (___ | |_) || |
163 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
164 | |__| | |_) |  __/ | | |____) | |_) || |_
165  \____/| .__/ \___|_| |_|_____/|____/_____|
166        | |
167        |_|
168
169Platform Name             : riscv-virtio,qemu
170Platform Features         : medeleg
171Platform HART Count       : 1
172Platform IPI Device       : aclint-mswi
173Platform Timer Device     : aclint-mtimer @ 10000000Hz
174Platform Console Device   : uart8250
175Platform HSM Device       : ---
176Platform PMU Device       : ---
177Platform Reboot Device    : syscon-reboot
178Platform Shutdown Device  : syscon-poweroff
179Platform Suspend Device   : ---
180Platform CPPC Device      : ---
181Firmware Base             : 0x80000000
182Firmware Size             : 323 KB
183Firmware RW Offset        : 0x40000
184Firmware RW Size          : 67 KB
185Firmware Heap Offset      : 0x48000
186Firmware Heap Size        : 35 KB (total), 2 KB (reserved), 9 KB (used), 23 KB (free)
187Firmware Scratch Size     : 4096 B (total), 328 B (used), 3768 B (free)
188Runtime SBI Version       : 2.0
189
190Domain0 Name              : root
191Domain0 Boot HART         : 0
192Domain0 HARTs             : 0*
193Domain0 Region00          : 0x0000000000100000-0x0000000000100fff M: (I,R,W) S/U: (R,W)
194Domain0 Region01          : 0x0000000010000000-0x0000000010000fff M: (I,R,W) S/U: (R,W)
195Domain0 Region02          : 0x0000000002000000-0x000000000200ffff M: (I,R,W) S/U: ()
196Domain0 Region03          : 0x0000000080040000-0x000000008005ffff M: (R,W) S/U: ()
197Domain0 Region04          : 0x0000000080000000-0x000000008003ffff M: (R,X) S/U: ()
198Domain0 Region05          : 0x000000000c400000-0x000000000c5fffff M: (I,R,W) S/U: (R,W)
199Domain0 Region06          : 0x000000000c000000-0x000000000c3fffff M: (I,R,W) S/U: (R,W)
200Domain0 Region07          : 0x0000000000000000-0xffffffffffffffff M: () S/U: (R,W,X)
201Domain0 Next Address      : 0x0000000080200000
202Domain0 Next Arg1         : 0x000000008fe00000
203Domain0 Next Mode         : S-mode
204Domain0 SysReset          : yes
205Domain0 SysSuspend        : yes
206
207Boot HART ID              : 0
208Boot HART Domain          : root
209Boot HART Priv Version    : v1.10
210Boot HART Base ISA        : rv64imafdc
211Boot HART ISA Extensions  : zicntr,zihpm
212Boot HART PMP Count       : 16
213Boot HART PMP Granularity : 2 bits
214Boot HART PMP Address Bits: 54
215Boot HART MHPM Info       : 16 (0x0007fff8)
216Boot HART MIDELEG         : 0x0000000000000222
217Boot HART MEDELEG         : 0x000000000000b109
218heap: [0x003280c0 - 0x043280c0]
219
220 \ | /
221- RT -     Thread Smart Operating System
222 / | \     5.2.1 build Jun  9 2025 09:03:23
223 2006 - 2024 Copyright by RT-Thread team
224lwIP-2.0.3 initialized!
225[I/sal.skt] Socket Abstraction Layer initialize success.
226[I/utest] utest is initialize success.
227[I/utest] total utest testcase num: (1)
228[I/drivers.serial] Using /dev/ttyS0 as default console
229file system initialization done!
230Hello RISC-V
231msh />
232```
233
234### 3.2.2. 运行 RT-Thread Smart 版 + 根文件系统
235
236对于 Smart 版本的内核,也可以在执行 `run.sh` 脚本时指定根文件系统镜像文件的路径在启动过程中挂载根文件系统。
237
238需要注意的是,内核默认支持 fat, 如果要挂载 ext4 的文件系统,则还需要额外安装 lwext4 软件包,即使能 `PKG_USING_LWEXT4`
239>具体 menuconfig 路径是 (Top) -> RT-Thread online packages -> system packages ->  lwext4: an excellent choice of ext2/3/4 filesystem for microcontrollers
240
241如果在菜单中找不到该软件包,可以退出 menuconfig 并执行 `pkgs --upgrade` 更新软件包索引后再尝试使能软件包。
242勾选该选项后还需要执行如下操作更新软件并安装源码到 bsp 的 packages 目录下(该操作只要执行一次即可):
243
244```shell
245source ~/.env/env.sh
246pkgs --update
247```
248
249保存后重新编译内核。
250
251有关如何制作根文件系统,以及更多详细内容,请参考 <https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-smart/quick-start/qemu-xuantie/quickstart>,这里不再赘述。
252
253示例如下:
254
255```shell
256$ bash run.sh ext4.img
257
258OpenSBI v1.4
259   ____                    _____ ____ _____
260  / __ \                  / ____|  _ \_   _|
261 | |  | |_ __   ___ _ __ | (___ | |_) || |
262 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
263 | |__| | |_) |  __/ | | |____) | |_) || |_
264  \____/| .__/ \___|_| |_|_____/|____/_____|
265        | |
266        |_|
267
268Platform Name             : riscv-virtio,qemu
269Platform Features         : medeleg
270Platform HART Count       : 1
271Platform IPI Device       : aclint-mswi
272Platform Timer Device     : aclint-mtimer @ 10000000Hz
273Platform Console Device   : uart8250
274Platform HSM Device       : ---
275Platform PMU Device       : ---
276Platform Reboot Device    : syscon-reboot
277Platform Shutdown Device  : syscon-poweroff
278Platform Suspend Device   : ---
279Platform CPPC Device      : ---
280Firmware Base             : 0x80000000
281Firmware Size             : 323 KB
282Firmware RW Offset        : 0x40000
283Firmware RW Size          : 67 KB
284Firmware Heap Offset      : 0x48000
285Firmware Heap Size        : 35 KB (total), 2 KB (reserved), 9 KB (used), 23 KB (free)
286Firmware Scratch Size     : 4096 B (total), 328 B (used), 3768 B (free)
287Runtime SBI Version       : 2.0
288
289Domain0 Name              : root
290Domain0 Boot HART         : 0
291Domain0 HARTs             : 0*
292Domain0 Region00          : 0x0000000000100000-0x0000000000100fff M: (I,R,W) S/U: (R,W)
293Domain0 Region01          : 0x0000000010000000-0x0000000010000fff M: (I,R,W) S/U: (R,W)
294Domain0 Region02          : 0x0000000002000000-0x000000000200ffff M: (I,R,W) S/U: ()
295Domain0 Region03          : 0x0000000080040000-0x000000008005ffff M: (R,W) S/U: ()
296Domain0 Region04          : 0x0000000080000000-0x000000008003ffff M: (R,X) S/U: ()
297Domain0 Region05          : 0x000000000c400000-0x000000000c5fffff M: (I,R,W) S/U: (R,W)
298Domain0 Region06          : 0x000000000c000000-0x000000000c3fffff M: (I,R,W) S/U: (R,W)
299Domain0 Region07          : 0x0000000000000000-0xffffffffffffffff M: () S/U: (R,W,X)
300Domain0 Next Address      : 0x0000000080200000
301Domain0 Next Arg1         : 0x000000008fe00000
302Domain0 Next Mode         : S-mode
303Domain0 SysReset          : yes
304Domain0 SysSuspend        : yes
305
306Boot HART ID              : 0
307Boot HART Domain          : root
308Boot HART Priv Version    : v1.10
309Boot HART Base ISA        : rv64imafdc
310Boot HART ISA Extensions  : zicntr,zihpm
311Boot HART PMP Count       : 16
312Boot HART PMP Granularity : 2 bits
313Boot HART PMP Address Bits: 54
314Boot HART MHPM Info       : 16 (0x0007fff8)
315Boot HART MIDELEG         : 0x0000000000000222
316Boot HART MEDELEG         : 0x000000000000b109
317heap: [0x003404c0 - 0x043404c0]
318
319 \ | /
320- RT -     Thread Smart Operating System
321 / | \     5.2.1 build Jun 13 2025 09:43:35
322 2006 - 2024 Copyright by RT-Thread team
323[I/utest] utest is initialize success.
324[I/utest] total utest testcase num: (1)
325[I/drivers.serial] Using /dev/ttyS0 as default console
326[W/DFS.fs] mount / failed with file system type: elm
327file system initialization done!
328Hello RISC-V
329msh />/ #
330/ #
331/ # ls
332bin         lib         proc        sbin        usr
333dev         lost+found  root        services    var
334etc         mnt         run         tmp
335/ #
336```
337
338## 4. 联系人信息
339
340如有意向咨询请联系:<business@rt-thread.com>
341