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

..21-Aug-2025-

applications/21-Aug-2025-

board/21-Aug-2025-

figures/21-Aug-2025-

figures_en/21-Aug-2025-

.config A D21-Aug-202546.2 KiB1,4181,308

Kconfig A D21-Aug-2025219 138

README_EN.md A D21-Aug-20256.5 KiB14378

SConscript A D21-Aug-2025331 1612

SConstruct A D21-Aug-20251.7 KiB6246

readme.md A D21-Aug-20259.7 KiB275154

rtconfig.h A D21-Aug-20258.2 KiB41881

rtconfig.py A D21-Aug-20252 KiB7054

README_EN.md

1# CH32V208W-R0 User Guide
2
3**英文** | [中文](./README.md)
4
5The CH32V208W-R0 supports RT-Studio projects, and this tutorial gives an example of development instructions for the RT-Studio environment.
6
7## 1 Preparation Stage
8
9- Pull the github repository for rt-thread locally, [link address](https://github.com/RT-Thread/rt-thread).
10- Download and install RT-Thread Studio, [link to address](https://www.rt-thread.org/studio.html).
11- Prepare the ESP8266 module.
12
13## 2 BSP Start Stage
14
15### 2.1 Click on the file and select the import option.
16
17<img src="./figures_en/1import_en.png" style="zoom:80%;" />
18
19### 2.2 Select to import RT-Thread BSP into the workspace
20
21<img src="./figures_en/2workspace_en.png" style="zoom:80%;" />
22
23<div STYLE="page-break-after: always;"></div>
24
25### 2.3 Fill in the project information according to the example
26
27<img src="./figures_en/3info_en.png" style="zoom:80%;" />
28
29### 2.4 Configuration Engineering
30
31After importing the project, there is a reference document readme in the root directory of the project, first of all, follow the readme.md for basic configuration
32
33In order to reduce the memory increase caused by the standard library added during linking, we can choose to use the relatively small memory consumption of newlib, as follows:
34
35<img src="./figures/13newlib.png" style="zoom:67%;" />
36
37### 2.5 Compiling the project
38
39Click on the compile option:
40
41![](./figures_en/4build_en.png)
42
43Compile result:
44
45![](./figures/5result.png)
46
47The project compiles and passes, and thus the preparation phase is completed.
48
49## 3 Configuring the BSP driver with RT-Studio
50
51Each BSP of RT-Thread has been configured with several on-chip peripheral drivers and onboard peripheral drivers by default, use RT-Studio to turn on the corresponding switches directly and configure the corresponding parameters according to the usage environment to use. Due to the multiplexing function of each pin, not all on-chip peripheral drivers and onboard peripheral drivers can be used at the same time, so you need to combine them with the schematic to enable the corresponding peripheral drivers.
52
53RT-Thread has a number of software packages, which can be added to the project by turning on the corresponding package switch using RT-Studio.
54
55<img src="./figures_en/6pkgs_en.png" style="zoom:80%;" />
56
57## 4 Networking with ESP8266 modules
58
59The ESP8266 is a cost-effective, highly integrated Wi-Fi MCU for IoT applications, and can also be used as a standalone WIFI module with the following physical diagram. ESP8266 modules usually support [AT](https://www.rt-thread.org/document/site/#/rt- thread-version/rt-thread-standard/programming-manual/at/at), RT-Thread provides an abstraction layer for these modules that support AT instructions, and this summary will use the AT group to communicate with ESP8266 and connect WIFI.
60
61<img src="./figures/7esp8266.png" style="zoom:60%;" />
62
63### 4.1 Configuring Onboard UART Peripherals
64
65Using the AT component to communicate with the ESP8266 module using serial communication, so we need to enable one more serial port, here we use UART2, the serial driver is already supported by default, we just need to open it in RT-Studio when we use it, as follows:
66
67![](./figures_en/8setting_en.png)
68
69After turning on the option, `ctrl + s` saves the settings and serial port 2 is initialized.
70
71### 4.2 Configuring AT components with RT-Studio
72
73Click on the RT-Thread Settings option on the left, the configuration menu on the right pops up, type AT in the search field, select `AT device` and enable the AT device:
74
75<img src="./figures_en/9AT_en.png" style="zoom: 50%;" />
76
77Select the ESP8266 and configure the appropriate parameters, as shown in the example below.
78
79<img src="./figures_en/10wifinfo_en.png" style="zoom:80%;" />
80
81### 4.3 ESP8266 module connection
82
83Connect the `PA2` pin on the board to the `RX` pin of the module, connect the `PA3` pin to the `TX` pin of the module, and power the module using the power supply pinout from the development board.
84
85<img src="./figures/11board.png" style="zoom: 25%;" />
86
87### 4.4 Enabling kernel debugging.
88
89For a more intuitive understanding of the component initialization process, we can enable the kernel debugging feature to observe it (you can turn it off when not needed) by doing the following:
90
91![](./figures_en/12kdebug_en.png)
92
93Recompile and burn the firmware, the shell output is as follows:
94
95![](./figures/14shellinfo.png)
96
97### 4.5 wifi networking test
98
99My door has configured the WIFI ID and password when using AT, enter the `ping www.baidu.com` command in the shell to test the WIFI connection.
100
101![](./figures/15ping.png)
102
103Output similar content, the ESP8266 module is connected successfully!
104
105### 5 RTduino components
106
107[RTduino](https://github.com/Yaochenger/RTduino) is the Arduino eco-compatible layer of the RT-Thread real-time operating system, and is a sub-community of the [RT-Thread community](https://github.com/RT-Thread/rt- thread), the downstream project of the Arduino open source project, aims to be compatible with the Arduino community ecology to enrich the RT-Thread community package ecology (such as thousands of different Arduino libraries, as well as the excellent open source projects of the Arduino community), and to reduce the learning threshold of the RT-Thread operating system and the chips compatible with RT-Thread. and RT-Thread-adapted chips.
108
109#### 5.1 Configuring RTduino
110
111Turn on the RTduino option in the onboard device driver.
112
113![](./figures_en/16rtduino_en.png)
114
115After turning on the option, `ctrl + s` saves the settings and the RTduino package can be added to the project.
116
117#### 5.2 Using RTduino
118
119In `arduino_main.cpp` you will see the familiar `void setup(void)` and `void loop(void)`, so we can use the BSP here like the official arduino board, the sample code is as follows:
120
121```c++
122#include <Arduino.h>
123
124void setup(void)
125 {
126     /* put your setup code here, to run once: */
127    pinMode(LED_BUILTIN, OUTPUT).
128 }
129
130void loop(void)
131{
132    /* put your main code here, to run repeatedly: */
133    digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)).
134    delay(100).
135}
136
137```
138
139 By default, the project performs a blinking LED function. ch32v208w-r0, the default on-board LED is not directly connected to the pin, the user needs to manually connect the LED to the control pin using a duplex cable, the phenomenon is shown below:
140
141<img src="./figures/17led.png" style="zoom: 25%;" />
142
143So the basic environment of ch32v208w-r0 is built and tested!

readme.md

1# CH32V208W-R0 BSP 说明
2
3**中文** | [英文](README_EN.md)
4
5## 1 开发板简介
6
7CH32V208W-R0 是 WCH 推出的一款基于 RISC-V 内核的开发板,最高主频为 144Mhz。比较适合入门学习 RISC-V 架构。
8
9![board](./figures/ch32v208.png)
10
11**基本特性:**
12
13- MCU:CH32V208WBU6,主频 144MHz,FLASH和RAM可配置
14- LED:2个。
15- 按键:3个 Download  ,Reset, User 。
16- USB:2个。
17- 网口:1个,内置 10M PHY。
18- 板上无 WCH-Link 下载调试工具,需外接。
19
20### 1.2 编译说明
21
22板级包支持 RISC-V GCC 开发环境,以下是具体版本信息:
23
24| IDE/编译器 | 已测试版本           |
25| ---------- | -------------------- |
26| GCC        | WCH RISC-V GCC 8.2.0 |
27
28### 1.4 使用Env编译BSP
29
30本节讲解如何使用Env工具来编译BSP工程。
31
32#### 1.4.1 编译BSP
33
341. 从山河工作室处下载ide/工具链并安装/解压[MounRiver Studio](http://www.mounriver.com/download)352. 对于安装ide的用户,推荐拷贝并重命名工具链至其他位置,避免路径中存在空格。
36   * 对于mrs,工具链在`MounRiver_Studio\toolchain`
37   * 对于mrs2,工具链在`MounRiver_Studio2\resources\app\resources\win32\components\WCH\Toolchain`
383. 根据[Env 用户手册](https://www.rt-thread.org/document/site/#/development-tools/env/env)指引安装ENV。*nix用户和喜欢用PowerShell的用户可参考[RT-Thread/env: Python Scripts for RT-Thread/ENV](https://github.com/RT-Thread/env)394. 下载或使用`git clone`获得rt-thread源码。可使用`--depth`来避免bsp瘦身计划前造成的过多历史记录。
405. 打开env工具,使用cd命令进入bsp目录
416. 设置环境变量以提供工具链(以下需要替换为你自己的工具链地址)
42   * 对于cmd与env提供的ConEmu,使用`set RTT_EXEC_PATH=C:\Users\yekai\Documents\DevTools\wch-riscv-none-elf-gcc-8\bin`
43   * 对于PowerShell,使用`$env:RTT_EXEC_PATH = C:\Users\yekai\Documents\DevTools\wch-riscv-none-elf-gcc-8\bin`
44   * 对于bash与zsh,使用`export RTT_EXEC_PATH=~/DevTools/wch-riscv-none-elf-gcc-8/bin  `
457. 执行`scons --pyconfig-silent`
468. 执行`pkgs --update`拉取所需的库
479. 执行`scons -j4`编译项目
4810. 编译完成之后会生成 **rtthread.bin** 文件。
49
50#### 1.4.2 硬件连接
51
52* 不使用调试器:连接开发板到电脑
53* 使用调试器:使用杜邦线连接按钮下放排针与WCH-Link,SWDIO-DIO/SWCLK-CLK/TX-RXD/RX-TXD/GND-GND。将WCH-Link与开发板分别连接到电脑。
54
55#### 1.4.3 下载
56
57* 不使用调试器:打开 WCH RISC-V MCU ProgrammerTool 下载软件,选择刚刚生成的 **rtthread.bin**  文件,进行下载。
58
59![tool](./figures/tool.png)
60
61* 使用调试器:使用`WCH-LinkUtility.exe`或`wlink`等软件下载
62
63#### 1.4.4 运行结果
64
65在终端工具里打开对应串口(115200-8-1-N),复位设备后,在串口上可以看到 RT-Thread 的输出信息:
66
67![end](./figures/end.png)
68
69### 1.5 使用CMake和CLion开发
70
71```shell
72scons --target=cmake
73clion .
74```
75
76### 1.6 使用VSCode编译工程
77
78在Env终端中敲入命令 `scons --target=vsc` 来生成VSCode工程. 接着敲入命令 `code .` 来打开VSCode.
79
80使用 **VSCode 终端** 敲入命令 `scons -j12 --exec-path=D:\sdk-toolchain-RISC-V-GCC-WCH-1.0.0bin` 来编译工程。
81
82![vscode-terminal](./figures/vscode-terminal.png)
83
84### 1.7 导入 RT-Thread Studio 工程
85
86#### 1.6.0 拉取sdk
87
88参照前文使用env编译一次即可。
89
90#### 1.6.1 导入
91
92打开 RT-Thread Studio 后点击:文件->导入:
93
94![import](./figures/import.png)
95
96选择“RT-Thread Bsp 到工作空间中”:
97
98![windows](./figures/windows.png)
99
100填写项目信息,Bsp 根目录为 `\rt-thread\bsp\wch\risc-v\ch32v307v-r1` 目录:
101
102![config](./figures/config.png)
103
104#### 1.6.2 配置环境
105
106工程导入后进行编译环境的设置,首先点击“打开构建设置”进入设置界面:
107
108![set](./figures/set.png)
109
110将编译链路径复制到 Toolchain path 中:
111
112![toolchain](./figures/toolchain.png)
113
114如图更改 Prefix :
115
116![prefix](./figures/prefix.png)
117
118进行工具设置:
119
120![toolset](./figures/toolset.png)
121
122#### 1.6.3 编译
123
124编译结果如下:
125
126#### ![success](./figures/success.png)
127
128## 2 CH32V208W-R0上手指南
129
130**中文** | [English](./CH32V208W-R0 Getting Started Guide.md)
131
132CH32V208W-R0支持RT-Studio工程,本上手指南以RT-Studio环境的开发说明举例。
133
134### 2.1 准备阶段
135
136- 拉取rt-thread的github仓库到本地,[链接地址](https://github.com/RT-Thread/rt-thread)137
138- 下载安装RT-Thread Studio,[链接地址](https://www.rt-thread.org/studio.html)139- 准备ESP8266模块。
140
141### 2.2 BSP上手阶段
142
143#### 2.2.1 点击文件,选择导入选项。
144
145<img src="figures/1import.png" style="zoom:80%;" />
146
147#### 2.2.2 选择导入RT-Thread Bsp 到工作空间中
148
149<img src="figures/2workspace.png" style="zoom:80%;" />
150
151<div STYLE="page-break-after: always;"></div>
152
153#### 2.2.3 按照示例填写工程信息
154
155<img src="figures/3info.png" style="zoom:80%;" />
156
157### 2.4 配置工程
158
159导入工程后,在工程的根目录下存在参考文档readme,首先按照readme.md进行基础的配置
160
161为了减小链接时添加的标准库带来的内存增大,我们可以选择使用相对占用内存较小的newlib,具体操作如下:
162
163<img src="figures/13newlib.png" style="zoom:67%;" />
164
165### 2.5 编译工程
166
167点击编译选项:
168
169![](figures/4build.png)
170
171编译结果:
172
173![](figures/5result.png)
174
175工程编译通过,至此,准备阶段完成。
176
177## 3 使用RT-Studio配置BSP驱动
178
179RT-Thread每个BSP已经默认适配了若干片上外设驱动与板载外设驱动,使用RT-Studio将相应的开关直接打开并依据使用环境配置相应参数即可使用。由于各个管脚存在复用功能,所以并不是所有的片上外设驱动与板载外设驱动都可以同时使用,使用时需要结合原理图来合理开启相应的外设驱动。
180
181RT-Thread有许多软件软件包,使用RT-Studio将相应软件包的开关打开便可将软件包添加至工程使用。
182
183<img src="figures/6pkgs.png" style="zoom:80%;" />
184
185## 4 联网实操:使用ESP8266模块联网
186
187ESP8266是面向物联网应用的高性价比、高度集成的 Wi-Fi MCU,也可以将其作为一个单独的WIFI模块使用,其实物图如下。ESP8266模组通常支持[AT指令](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/at/at)的操作方式,RT-Thread针对这些支持AT指令的模组提供了一个抽象层,本小结将使用AT组将与ESP8266通讯并连接WIFI。
188
189<img src="figures/7esp8266.png" style="zoom:60%;" />
190
191### 4.1 配置板载UART外设
192
193使用AT组件与ESP8266模组通讯采用串口通讯的方式,所以需要再使能一路串口,这里我们使用UART2,串口驱动默认已经支持,我们仅需要在使用时在RT-Studio中打开即可,具体操作方式如下:
194
195![](figures/8setting.png)
196
197开启选项后,`ctrl + s`保存设置,串口2即被初始化。
198
199### 4.2 使用RT-Studio配置AT组件
200
201点击左侧的RT-Thread Settings选项,弹出右侧的配置菜单,在搜索栏中输入AT,选择`AT设备 `,使能AT设备:
202
203<img src="figures/9AT.png" style="zoom: 50%;" />
204
205选择ESP8266,并配置相应参数,示例如下:
206
207<img src="figures/10wifinfo.png" style="zoom:80%;" />
208
209### 4.3 ESP8266模组连接
210
211将板子上的`PA2`管脚与模组的`RX`管脚连接,将`PA3`管脚与模组的`TX`管脚连接,并使用开发板引出的电源为模组供电。
212
213<img src="figures/11board.png" style="zoom: 25%;" />
214
215### 4.4 使能内核调试功能。
216
217为了更加直观的了解组件的初始化过程,我们可以使能内核调试功能来观察(不需要时可以关掉),操作方法如下:
218
219![](figures/12kdebug.png)
220
221重新编译并烧录固件,shell输出如下:
222
223![](figures/14shellinfo.png)
224
225
226
227### 4.5 wifi联网测试
228
229我门在使用AT时已经配置了WIFI的ID与密码,在shell中输入`ping www.baidu.com`命令测试WIFI连接情况。
230
231![](figures/15ping.png)
232
233输出类似内容,ESP8266模组便联网成功!
234
235## 5 RTduino组件
236
237[RTduino](https://github.com/Yaochenger/RTduino)是RT-Thread实时操作系统的Arduino生态兼容层,为[RT-Thread社区](https://github.com/RT-Thread/rt-thread)的子社区、Arduino开源项目的下游项目,旨在兼容Arduino社区生态来丰富RT-Thread社区软件包生态(如上千种分门别类的Arduino库,以及Arduino社区优秀的开源项目),并降低RT-Thread操作系统以及与RT-Thread适配的芯片的学习门槛。
238
239### 5.1 配置RTduino
240
241将板载设备驱动中的RTduino选项打开。
242
243![](figures/16rtduino.png)
244
245开启选项后,`ctrl + s`保存设置,RTduino软件包即可添加至工程。
246
247### 5.2 使用RTduino
248
249在`arduino_main.cpp`中会看到熟悉的`void setup(void)`与`void loop(void)`,至此我们便可以在此像使用arduino官方板一样使用该BSP,示例代码如下:
250
251```c++
252#include <Arduino.h>
253
254void setup(void)
255 {
256     /* put your setup code here, to run once: */
257    pinMode(LED_BUILTIN, OUTPUT);
258 }
259
260void loop(void)
261{
262    /* put your main code here, to run repeatedly: */
263    digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
264    delay(100);
265}
266
267```
268
269 工程默认执行一个LED闪烁的功能,ch32v208w-r0这款板子默认板载LED不与管脚直接连接,用户在使用LED时需要使用杜邦线手动将LED与控制管脚连接起来,现象如下图所示:
270
271<img src="figures/17led.png" style="zoom: 25%;" />
272
273至此ch32v208w-r0的基础环境便搭建测试完毕!
274
275