README.md
1# CH32V307V-R1 BSP Introduction
2
3**English** | [中文](README_zh.md)
4
5## 1 Introduction
6
7CH32V307V-R1 is a RISC-V core-based development board with a maximum main frequency of 144Mhz. It delivers the best value for developers to try and get started with RISC-V architecture.
8
9This document records the execution instruction of the BSP (board support package) provided by the RT-Thread community for the CH32V307V-R1 development board.
10
11The document is covered in three parts:
12
13- Board Resources Introduction
14- Compiling
15- Quickly Get Started
16
17By reading the Quickly Get Started section developers can quickly get their hands on this BSP and run RT-Thread on the board.
18
19
20
21**Features**
22
23- MCU: CH32V307VCT6, main frequency 144MHz,FLASH and RAM are available for configuration.
24- LED: 2, user LEDs, LED1(blue), LED2(blue).
25- Button: 2, Reset, User.
26- USB: 2, Tpye-C.
27- Network Port: 1, 10M PHY inside.
28- WCH-Link download debugging tools onboard.
29
30For more details about this board, please refer to: [CH32V307](https://www.wch.cn/products/CH32V307.html) and [CH32V307 official document](https://github.com/openwch/ch32v307)
31
32## 2 Compiling
33
34The BSP supports the RISC-V GCC development environment, here's the specific version information:
35
36| IDE/Compiler | Version Tested |
37| ------------ | -------------------- |
38| GCC | WCH RISC-V GCC 8.2.0 |
39
40## 3 Quickly Get Started
41
42### 3.1 Using [Env](https://www.rt-thread.io/download.html?download=Env) to compile BSP
43
44This section is about to introduce how to use Env to compile the BSP.
45
46#### 3.1.1 Compile BSP
47
481. [Download WCH Compile Toolchain](https://github.com/NanjingQinheng/sdk-toolchain-RISC-V-GCC-WCH/releases)
492. [Download the Env tool latest version](https://github.com/RT-Thread/env-windows/releases)
503. [Download the RT-Thread latest code](https://github.com/RT-Thread/rt-thread/archive/refs/heads/master.zip)
514. Open the Env tool in the current BSP root directory and execute the `scons -j12 --exec-path=D:\sdk-toolchain-RISC-V-GCC-WCH-1.0.0\bin` command, compile it directly while specifying the toolchain location.
525. After compilation, the **rtthread.bin** file will be generated
53
54
55
56#### 3.1.2 Hardware Connection
57
58Use a data cable to connect the onboard wch-link to the PC, and turn on the power switch.
59
60#### 3.1.3 Download
61
62Open the WCH RISC-V MCU ProgrammerTool, select the **rtthread.bin** file that we just generated, and download it.
63
64
65
66> Note that Chip Mem here is set to 224K ROM + 96K RAM.
67
68#### 3.1.4 Running Result
69
70In the terminal tool, open the onboard wch-link serial port (WCHDapLink SERIAL, default 115200-8-1-N), and after resetting the device, you can see the output information of RT-Thread on the serial port:
71
72
73
74#### 3.1.5 If no running result
75
76Replace download tool with WCH-LinkUtility.
77[Details](https://club.rt-thread.org/ask/article/44e5b4bc129ff373.html)
78
79### 3.2 Use VSCode to edit and compile the project
80
81In the Env terminal, type command `scons --target=vsc` to generate the VSCode project. Then, type command `code .` in the Env terminal to open the VSCode.
82
83Use **VSCode terminal** to type command `scons -j12 --exec-path=D:\sdk-toolchain-RISC-V-GCC-WCH-1.0.0\bin` to compile the project in VSCode.
84
85
86
87<!-- ### 3.3 Import RT-Thread Studio Project
88
89**CH32V307V-R1 is pending upgrade in Studio. It's not encouraged now to use Studio to compile this BSP.**
90
91#### 3.3.1 Import
92
93Open RT-Thread Studio and click: File-> Import:
94
95
96
97Select "RT-Thread BSP Project into Workspace":
98
99
100
101填写项目信息,Bsp 根目录为 \rt-thread\bsp\wch\risc-v\ch32v307v-r1 目录:
102
103Fill in the project info, the BSP root directory is \rt-thread\bsp\wch\risc-v\ch32v307v-r1:
104
105
106
107
108#### 3.3.2 Compilation Environment
109
110工程导入后进行编译环境的设置,首先点击“打开构建设置”进入设置界面:
111
112After the project is imported, set the compilation environment, click "Open Build Settings" to enter the setting interface:
113
114
115
116将编译链路径复制到 Toolchain path 中:
117Copy the compilation chain path into the Toolchain path:
118
119
120
121Change Prefix:
122
123
124
125Set the tool:
126
127
128
129#### 3.3.3 Compiling
130
131The result is shown as below:
132
133![success](./figures/success.png -->
134