ch32fun: minimal open-source toolchain for sub-$0.10 WCH RISC-V microcontrollers
The ch32fun project provides a register-level, HAL-free development environment for WCH's CH32V003 and related RISC-V MCUs, producing 500-byte binaries with standard gcc-riscv64 and open-source flashing tools.
Summary
The CH32 RISC-V User Group has released ch32fun, an open-source development stack targeting WCH's CH32V003 and broader CH32/CH5xx microcontroller families. The project eschews traditional hardware abstraction layers in favor of direct register manipulation using vendor reference manuals, enabling extremely compact firmware. A basic blink example compiles to approximately 500 bytes and achieves fast boot times. The toolchain runs on Windows, Linux, or WSL using standard gcc-riscv64, with flashing and debugging handled by the companion minichlink utility.
The CH32V003 at the center of this ecosystem is a 48 MHz RISC-V MCU with 16 kB flash and 2 kB RAM, available in SOP-8, QFN-20, and SOIC packages at roughly ten cents in volume. ch32fun extends beyond this part to cover the CH32X035, multiple CH32V00x variants, CH32V2xx/3xx series, and recently the CH570 through CH592 in the CH5xx line. Developers can build projects through PlatformIO using the ch32v003fun framework, or with plain makefiles from a provided template. The project intentionally omits malloc, pointing users to tinyalloc or libmemory when dynamic allocation is required.
Architecture and tooling model
- Register-level programming: The stack intentionally omits a hardware abstraction layer, requiring developers to write directly to peripheral registers using the vendor reference manual rather than abstracted APIs.
- Minimal binary footprint: A blink example compiles to approximately 500 bytes, demonstrating the efficiency gains from eliminating HAL overhead and startup code bloat.
- minichlink flashing and debug: The companion tool writes firmware at approximately 36 kBytes/sec and integrates a gdbserver compatible with gdb-multiarch and Visual Studio Code for debugging.
- printf debugging support: The SetupDebugPrintf() function enables formatted debug output without a full semihosting implementation, with a dedicated debugprintf example provided.
- Build system flexibility: Projects compile with standard gcc-riscv64 and can use either PlatformIO with framework = ch32v003fun or standalone makefiles derived from a template project.
Why it matters
For the RISC-V embedded ecosystem, ch32fun lowers barriers to entry on cost-sensitive hardware by replacing proprietary or vendor-locked toolchains with standard open-source components. The CH32V003's sub-$0.10 pricing in DIP-like packages makes RISC-V accessible to hobbyists and educational contexts previously dominated by 8-bit AVR and PIC parts, while the HAL-free approach appeals to engineers optimizing for deterministic behavior and minimal code size in commercial products.
Original reference: blog.adafruit.com →