README.md
1# YD-CH32V307VCT6 BSP Introduction
2
3## 1 Introduction
4
5YD-CH32V307VCT6 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.
6
7This document records the execution instruction of the BSP (board support package) provided by the RT-Thread community for the CH32V307V-R1 development board.
8
9The document is covered in three parts:
10
11- Board Resources Introduction
12- Compiling
13- Quickly Get Started
14
15By reading the Quickly Get Started section developers can quickly get their hands on this BSP and run RT-Thread on the board.
16
17
18
19**Features**
20
21- MCU: CH32V307VCT6, main frequency 144MHz,FLASH and RAM are available for configuration.
22- LED: 2, user LEDs (blue and red).
23- Button: 3, Reset, Boot, User.
24- SPI Flash: 32M-bit serial flash memory (W25Q32).
25- I2C EEPROM: 64k-bit serial EEPROM (24C64).
26- USB: 2, Type-C.
27- Network Port: 1, 10M PHY inside.
28- SDIO: microSD connector.
29- Debug interface: SWD.
30- 8 MHz external quartz oscillator (HSE).
31- 32,768 Hz external RTC quartz oscillator (LSE).
32
33For more details about this board, please refer to:
34- [Board YD-CH32V307VCT6 VCC-GND Studio](http://152.32.187.208:8080/yd-data/YD-CH32V307VCT6/YD-CH32V307VCT6/)
35- [CH32V307](https://www.wch.cn/products/CH32V307.html)
36- [CH32V307 official document](https://github.com/openwch/ch32v307)
37
38## 2 Compiling
39
40The BSP supports the RISC-V GCC development environment, here's the specific version information:
41
42| IDE/Compiler | Version Tested |
43| ------------ | -------------------- |
44| GCC | WCH RISC-V GCC 8.2.0 |
45
46## 3 Quickly Get Started
47
48### 3.1 Using Linux to compile BSP
49
50This section is about to introduce how to compile the BSP in Linux.
51
52#### 3.1.1 Compile BSP
53
541. [Download WCH Compile Toolchain](https://github.com/NanjingQinheng/sdk-toolchain-RISC-V-GCC-WCH/releases)
552. [Download the RT-Thread latest code](https://github.com/RT-Thread/rt-thread/archive/refs/heads/master.zip)
563. Install SCons construction tool (similar GNU Make): sudo apt install scons
574. Edit the variable **EXEC_PATH** in file **rtconfig.py** to point to the directory with executable WCH Compile Toolchain (file riscv-none-embed-gcc).
585. Configure RT-Thread and hardware board: scons --menuconfig
596. Start compilation: scons
607. After compilation, the **rtthread.bin** file will be generated
61
62#### 3.1.2 Download
63
641. Clone source file: git clone https://github.com/jmaselbas/wch-isp.git
652. Compile and install :
66- cd wch-isp
67- make && sudo make install && sudo make load
683. Use a USB cable Type-C to connect board to the PC. Hold button **BOOT0**, press briefly button **RST** and release button **BOOT0**.
694. Check board connection:
70```sh
71wch-isp list
720: BTVER v2.9 UID 10-46-89-26-3b-38-d4-a4 [0x1770] CH32V307VCT6
73MCU current flash size: 256 Kbyte
74```
75
76> Note that Chip Mem here is set to 256K ROM + 64K RAM (see Table 2-1 of datasheet CH32V307, and chapter 32.6 "User Option Bytes" of Reference Manual CH32V2x_V3x).
77
785. Download firmware to board:
79```
80wch-isp -p flash ./rtthread.bin && wch-isp reset
81```
82
83#### 3.1.3 Running Result
84
851. Connect USB-UART converter to board:
86- board pin A9 (UART1_TX) -> converter RX
87- board pin A10 (UART1_RX) -> converter TX (optional, for enter commands)
882. In the terminal tool, open the converter serial port (default 115200-8-1-N), and after resetting the device, you can see the output information of RT-Thread on the serial port:
89```
90 \ | /
91- RT - Thread Operating System
92 / | \ 5.1.0 build Jan 6 2024 17:12:03
93 2006 - 2022 Copyright by RT-Thread team
94SystemClk: 144000000 Hz
95msh >
96```
97On board LEDs (red and blue) blinking.
98