One core for the CH32V family: V003 and the V002/V004/V005/V006/V007 family, X035, V103, V203, V307, L103 and V407, from 16 KB to 512 KB of flash, with the same sketch code.
Standard Arduino API: digitalWrite, analogRead, analogWrite, attachInterrupt, Serial, Wire, SPI, tone, HardwareTimer, plus the WCH peripheral drivers for everything else.
WCH’s own toolchain: GCC 15.2 with the WCH extensions (xw compressed instructions, hardware stack push/pop) and OpenOCD 2.12 for the WCH-LinkE, both installed by the Boards Manager.
Tuning menus: clock source and speed, optimization (LTO for the 16 KB V003), C library (nano, float printf/scanf), USB stack, upload method.
Checked on hardware: releases are run on the EVT boards of each series (GPIO, interrupts, ADC, PWM, timers, I2C, SPI, Serial) before they go to the Boards Manager.
CH32 MCU EVT Boards then also lists versions like 1.0.8-dev.2: builds of main that are not yet tested on every board. Install one like any other version; only one version is installed at a time, so going back to the stable one is a click away. A dev build shows “(dev)” in the board menu, and its release notes on the Releases page list what changed.
Development version (git)
Clone into your sketchbook to use the latest main:
mkdir -p ~/Documents/Arduino/hardware/WCH
cd ~/Documents/Arduino/hardware/WCH
git clone --recursive https://github.com/openwch/arduino_core_ch32.git ch32v
The clone uses the same toolchain as the release: install the release once from the Boards Manager (it brings the tools), or point wch.gcc.dir and wch.openocd.dir at your own tool folders in a platform.local.txt next to platform.txt.
More packages of the V002/V004/V005/V006/V007 family and the CH32X033 are on the way (#200, #171). A board that isn’t listed can usually run the variant of the same chip; see adding a board.
Features
V00x
VM00X
X035
V10x
V20x
V30x
L10x
V4x7
GPIO, pull-up/down, open drain
✅
✅
✅
✅
✅
✅
✅
✅
attachInterrupt (EXTI)
✅
✅
✅
✅
✅
✅
✅
✅
analogRead (ADC)
✅
✅
✅
✅
✅
✅
✅
✅
analogWrite (PWM), tone
✅
✅
✅ ¹
✅
✅
✅
✅
✅
HardwareTimer
✅
✅
✅
✅
✅
✅
✅
✓
Serial (U(S)ART)
✅
✅
✅
✅
✅
✅
⚠️ ²
✅
Wire (I2C master)
✅
✅
✅
✅
✅
✅
✓
✅
SPI
✅
✅
✅
✅
✅
✅
✓
✅
LTO (Tools → Optimize)
✅
✅
✅
⚠️ ⁴
⚠️ ⁴
⚠️ ⁴
⚠️ ⁴
EEPROM (option bytes)
✓
⚠️ ³
USB device (Adafruit TinyUSB)
✓
✓
USB-PD sink (USBPD_SINK)
✓
✅ checked on an EVT board · ✓ available, not yet checked on a board · ⚠️ known problem
¹ not on complementary (N) timer outputs yet, #183 · ² #149 · ³ #213 · ⁴ LTO drops the core’s interrupt handlers on these series (#204); use the plain optimize options
// Toggle a pin and print over Serial (the WCH-Link's COM port, 115200)
#define LED_PIN PA8 // pins use the chip's names: PA8, PD4, PC1, ...
void setup() {
Serial.begin(115200);
pinMode(LED_PIN, OUTPUT);
}
void loop() {
digitalWrite(LED_PIN, !digitalRead(LED_PIN));
Serial.print("millis: ");
Serial.println(millis());
delay(500);
}
Analog inputs are also A0, A1, … The default Serial is the USART wired to the WCH-Link on the EVT board. Other UARTs: HardwareSerial Serial2(USART2);, with the pins from the variant’s pin map (USART2 on PA2/PA3 for the V20x and X035 boards; the other variants list only the Serial UART so far).
On CH32X035, select Tools → USB support → USB CDC Serial and the 48 MHz
clock to use Serial over the native USB port. The default option keeps
Serial on the hardware UART; in USB mode that UART remains available as
Serial1. Serial.begin(115200) starts USB CDC (the baud value does not set
USB speed). if (Serial) indicates that the host has opened the port. The
receive buffer holds one 64-byte packet; USB flow control pauses the host
until the sketch reads it. Writes can return fewer bytes and set
Serial.getWriteError() when the host disconnects or does not accept data
within 250 ms. Use USB serial from the main program, not an interrupt.
See USBSerial.ino. The USB descriptors
retain WCH’s example VID/PID (1a86:fe0c); check their suitability before
distributing a product. Native USB serial and USB-PD together have not been
tested. A PlatformIO-built USB firmware image compiled and passed flash
readback, but did not enumerate in the latest hardware test.
Library examples are under File → Examples → (Examples for CH32 MCU EVT Boards): EEPROM, SPI (SPI flash), Wire (I2C scanner, AT24C02, I2C slave), USBPD_SINK.
Using the WCH peripheral drivers
The WCH SDK drivers (ch32*_*.h) are available in every sketch, so peripherals the Arduino API doesn’t cover (DMA, CAN, OPA, RTC, DAC, …) can be used next to Arduino code:
WCH-LinkE (RV mode) or the WCH-Link on the EVT board; SWDIO/SWCLK, or SWIO (PD1) on V00x/VM00X
WCH-ISP
the chip’s USB/UART bootloader (BOOT0 high while resetting), on chips that have one
WCH-LinkE in ARM mode? Switch it to RV mode with WCH-LinkUtility.
Chip no longer connects (a sketch turned the debug pins into GPIO)? Upload with BOOT0 held high, or erase the chip with WCH-LinkUtility.
Toolchain
Tool
Version
Installed by
WCH GCC (riscv32-wch-elf)
15.2.0
Boards Manager (riscv-wch-gcc)
WCH OpenOCD
2.12
Boards Manager (openocd-wch)
GCC 15.2 and OpenOCD 2.12 are the builds from MounRiver Studio (3.0.0 for OpenOCD and for macOS). Releases up to 1.0.4 used GCC 8.2 (openwch/risc-none-embed-gcc) and OpenOCD 1.0.0 (openwch/openocd_wch); they stay installable from the Boards Manager.
Project layout
cores/arduino/ Arduino API (HardwareSerial, HardwareTimer, wiring_*, Tone, ...)
cores/arduino/ch32/ glue between the API and the WCH SDK (uart, analog, interrupt, clock, timer)
variants/<series>/ one folder per chip or board: pin names, pin maps, enabled peripherals
system/<series>/ WCH SDK: startup, linker scripts, peripheral drivers
libraries/ Wire, SPI, EEPROM, USBPD_SINK, Adafruit TinyUSB
boards.txt boards and Tools-menu options
platform.txt build recipes, toolchain, upload tools
Contributing
Bug reports, fixes and new boards are welcome. CONTRIBUTING.md covers how to report a bug so it can be reproduced, how to build and test a change, and how to add a chip or board.
Arduino Core for WCH CH32
Program WCH’s RISC-V CH32 microcontrollers with the Arduino IDE, Arduino CLI and the Arduino API you already know.
Install · Boards · Features · Getting started · Upload · Changelog · Contributing
Why this core
digitalWrite,analogRead,analogWrite,attachInterrupt,Serial,Wire,SPI,tone,HardwareTimer, plus the WCH peripheral drivers for everything else.xwcompressed instructions, hardware stack push/pop) and OpenOCD 2.12 for the WCH-LinkE, both installed by the Boards Manager.Installation
Arduino IDE 2 (Boards Manager)
File → Preferences → Additional boards manager URLs, add:
Tools → Board → Boards Manager, search CH32, install CH32 MCU EVT Boards. The IDE also downloads the toolchain (WCH GCC 15.2) and OpenOCD 2.12.
Tools → Board → CH32 MCU EVT Boards: pick your series, then your chip under Tools → Board Select.
Arduino CLI
Dev builds (Boards Manager)
To try fixes before the next release, add the dev index as a second URL, next to the stable one:
CH32 MCU EVT Boards then also lists versions like
1.0.8-dev.2: builds ofmainthat are not yet tested on every board. Install one like any other version; only one version is installed at a time, so going back to the stable one is a click away. A dev build shows “(dev)” in the board menu, and its release notes on the Releases page list what changed.Development version (git)
Clone into your sketchbook to use the latest
main:The clone uses the same toolchain as the release: install the release once from the Boards Manager (it brings the tools), or point
wch.gcc.dirandwch.openocd.dirat your own tool folders in aplatform.local.txtnext toplatform.txt.Operating systems
~/.arduino15/packages/WCH/tools/beforeinstall/2.0.0/start.shIntel Mac with 1.0.4: install the
libusblibrary before the first upload:If uploads still fail with
libusberrors, contact the MounRiver Studio team at support@mounriver.com (they build the toolchain and OpenOCD).Supported chips and boards
More packages of the V002/V004/V005/V006/V007 family and the CH32X033 are on the way (#200, #171). A board that isn’t listed can usually run the variant of the same chip; see adding a board.
Features
attachInterrupt(EXTI)analogRead(ADC)analogWrite(PWM),toneHardwareTimerSerial(U(S)ART)Wire(I2C master)SPIEEPROM(option bytes)USBPD_SINK)✅ checked on an EVT board · ✓ available, not yet checked on a board · ⚠️ known problem ¹ not on complementary (N) timer outputs yet, #183 · ² #149 · ³ #213 · ⁴ LTO drops the core’s interrupt handlers on these series (#204); use the plain optimize options
Open problems are in the issues.
Getting started
Analog inputs are also
A0,A1, … The defaultSerialis the USART wired to the WCH-Link on the EVT board. Other UARTs:HardwareSerial Serial2(USART2);, with the pins from the variant’s pin map (USART2 on PA2/PA3 for the V20x and X035 boards; the other variants list only theSerialUART so far).On CH32X035, select Tools → USB support → USB CDC Serial and the 48 MHz clock to use
Serialover the native USB port. The default option keepsSerialon the hardware UART; in USB mode that UART remains available asSerial1.Serial.begin(115200)starts USB CDC (the baud value does not set USB speed).if (Serial)indicates that the host has opened the port. The receive buffer holds one 64-byte packet; USB flow control pauses the host until the sketch reads it. Writes can return fewer bytes and setSerial.getWriteError()when the host disconnects or does not accept data within 250 ms. Use USB serial from the main program, not an interrupt. See USBSerial.ino. The USB descriptors retain WCH’s example VID/PID (1a86:fe0c); check their suitability before distributing a product. Native USB serial and USB-PD together have not been tested. A PlatformIO-built USB firmware image compiled and passed flash readback, but did not enumerate in the latest hardware test.Library examples are under File → Examples → (Examples for CH32 MCU EVT Boards): EEPROM, SPI (SPI flash), Wire (I2C scanner, AT24C02, I2C slave), USBPD_SINK.
Using the WCH peripheral drivers
The WCH SDK drivers (
ch32*_*.h) are available in every sketch, so peripherals the Arduino API doesn’t cover (DMA, CAN, OPA, RTC, DAC, …) can be used next to Arduino code:Upload
Toolchain
riscv32-wch-elf)riscv-wch-gcc)openocd-wch)GCC 15.2 and OpenOCD 2.12 are the builds from MounRiver Studio (3.0.0 for OpenOCD and for macOS). Releases up to 1.0.4 used GCC 8.2 (openwch/risc-none-embed-gcc) and OpenOCD 1.0.0 (openwch/openocd_wch); they stay installable from the Boards Manager.
Project layout
Contributing
Bug reports, fixes and new boards are welcome. CONTRIBUTING.md covers how to report a bug so it can be reproduced, how to build and test a change, and how to add a chip or board.
Related projects
Contact