cnlohr/ch32fun logo

cnlohr/ch32fun

Free

Open source minimal stack for the ch32 and ch5xx WCH RISC-V Microcontrollers

FreeFree tier
Type
Open Source

About cnlohr/ch32fun

ch32fun is an open-source, minimal development environment for the CH32V003 and many other RISC-V microcontrollers from WCH (including CH32 and CH5xx series). It provides a lightweight alternative to WCH's official HAL and EVT, enabling direct use of the Technical Reference Manual (TRM) for efficient, compact code. The project includes tooling (GCC-RISC-V toolchain), headers, examples, a cross-platform programmer called minichlink (using libusb), gdbserver debugging support, and fast printf-over-single-wire debug output. It supports Windows, Linux, and WSL, and aims to avoid complex HALs, making it ideal for resource-constrained embedded development. Blinky can be as small as 500 bytes. The repository also offers support for various programmer interfaces and a wiki for setup instructions.

Key Features

Minimal development environment avoiding complex HAL, enabling direct TRM use
Support for CH32V003, CH32x035, CH32Vxxx, CH5xx, and many other WCH RISC-V chips
Cross-platform tooling for Windows (native), Linux, and WSL
Minichlink programmer using WCH CH-Link with libusb
GDB server-style debugging for use with Visual Studio
Fast printf debug over single-wire interface (approx. 36 kBytes/sec)
Support for a variety of programmers: STM32F042 (NHC-Link042), ESP32S2 (esp32s2-funprog), official WCH Link-E, Arduino-based (Ardulink), and rv003usb SWDIO programmer
Built-in USB ISP bootloader support for WCH chips with USB peripheral
Includes examples and a demo bootloader
Extra copy of libgcc for unusual RISC-V build chains

Pros & Cons

Pros
  • Extremely lightweight – blinky example only 500 bytes
  • Avoids heavy HAL, giving direct hardware control
  • Cross-platform support (Windows, Linux, WSL)
  • Fast debug printf (36 kB/s) over single-wire interface
  • Supports a wide range of WCH RISC-V chips
  • Open source and community-driven
  • Includes multiple programmer options and gdbserver debugging
Cons
  • Limited number of examples compared to official HAL
  • GDB debugging fully tested primarily on CH32V003; limited on other processors
  • Support for obscure chips (e.g., CH32M030, CH641) reported but not thoroughly tested
  • Requires familiarity with TRM and register-level programming

Best For

Embedded development with ultra-low-cost RISC-V MCUs (e.g., CH32V003 at ~$0.10)Replacing bulky HALs with minimal, direct-register programmingFast debugging and printf logging over programming interfaceCross-platform firmware development for WCH microcontrollersTeaching and prototyping RISC-V bare-metal applicationsBuilding compact bootloaders and custom programmer firmware

FAQ

Which microcontrollers are supported by ch32fun?
The project supports CH32V003, CH32x035, CH32V002–V007, CH32V103, CH32V203, CH32V208, CH32V303, CH32V305, CH32V307, CH570, CH572, CH573, CH581–CH585, CH591, CH592, and some obscure chips like CH32M030, CH641, CH643, CH645.
How do I get started with ch32fun?
Installation and setup instructions are available on the project's wiki page linked from the repository.
What debug features does ch32fun offer?
It supports gdbserver-style debugging for Visual Studio and a fast printf-over-single-wire debug output at about 36 kBytes/sec.
What programmers can be used with ch32fun?
Minichlink uses WCH CH-Link with libusb. Also supported: STM32F042 programmer (NHC-Link042), ESP32S2 programmer (esp32s2-funprog), official WCH Link-E, Arduino-based Ardulink, and rv003usb SWDIO programmer.