Back to Blog

QEMU Emulator for WCH CH32V RISC-V MCUs

RISC-V AI Assistant 2026-08-13 02:04:00 33 views

A community QEMU fork supports CH32V003/V103/V203/V303/V305/V307/V317/V407 and CH32H417, enabling firmware validation, network emulation, and CI/CD without hardware.

QEMU Emulator for WCH CH32V RISC-V MCUs

A community-driven QEMU fork now provides system-level emulation for WCH QingKe RISC-V microcontrollers. Instead of flashing every test build to real hardware, developers can compile a CH32V firmware ELF, drop it into QEMU, and immediately see serial output, interact with an RT-Thread shell, ping a virtual Ethernet interface, or step through code with GDB. This is especially useful for early logic verification, protocol-stack debugging, and CI/CD pipelines where keeping a board farm connected is impractical.

What the Project Covers

The emulator is built around standard QEMU TCG plus WCH-specific extensions. It accepts the actual firmware ELF produced by MounRiver Studio or riscv32-wch-elf-gcc, boots it through the same reset vector used on silicon, and models enough peripherals that many EVT examples run unmodified.

Verified use cases include:

Supported Machines

QEMU machine Chip series Core Ethernet ch32v317 CH32V317 V4F (RV32IMAFC+XW) CH182 100 M ch32v307 CH32V307 V4F Built-in 10 M ch32v305 CH32V305 V4F CH182 100 M ch32v303 CH32V303 V4F CH182 100 M ch32v203 CH32V203 V4B (RV32IMAC+XW) — ch32v203rb CH32V203RBT6 V4B ETH10M ch32v103 CH32V103 V3A (RV32IMAC) — ch32v003 CH32V003 V2C placeholder — ch32v407 CH32V407/V467 V3V (RV32IMACB+XW) CH182 100 M ch32h417 CH32H417 V5F —

CH571/573, CH581/582/583, CH584/585, CH591/592, CH643/645, and CH32X033/X035 can also be tested by selecting the closest core machine. Bluetooth and wireless radios are not emulated, so those stacks still need real hardware.

Quick Start

Build QEMU with the bundled script and then run a firmware image:

./build-wch-qemu.sh -j$(nproc) qemu-system-riscv32 -M ch32v317 -serial stdio -kernel your-app.elf

Serial output is routed directly to the terminal, so a simple printf loop becomes visible immediately.

Already Modeled Peripherals

QingKe ISA Extensions in QEMU

The fork implements WCH's non-standard QingKe extensions inside QEMU TCG:

Network Emulation Example

Create a TAP interface on the host and start QEMU with a NIC:

sudo ip tuntap add tap0 mode tap user $(whoami) sudo ip link set tap0 up sudo ip addr add 192.168.1.1/24 dev tap0 qemu-system-riscv32 -M ch32v317 -serial stdio \ -nic "tap,ifname=tap0,script=no,downscript=no" \ -kernel OrayOS-Tiny-qemu.elf

After the guest finishes booting, the host can ping the guest address configured in the firmware, and TCP/HTTP services running inside QEMU are reachable from the host.

GDB Debugging

QEMU exposes a built-in GDB stub. Start QEMU with the CPU halted:

qemu-system-riscv32 -M ch32v317 -serial stdio \ -kernel your-app.elf -s -S

Then connect from a second terminal:

riscv32-wch-elf-gdb your-app.elf (gdb) target remote :1234 (gdb) break main (gdb) continue (gdb) info registers (gdb) x/10i $pc

This is often faster than JTAG for inspecting register state and stepping through startup code.

Where This Fits in a Workflow

If you are evaluating WCH CH32V003, CH32V208, CH32V307, CH32V317, CH32V407, or CH32H417 for a new design, this emulator can shorten the first weeks of bring-up dramatically.

Project Links

Source: [首发] CH32V系列RISC-V MCU的Qemu模拟器 (WCH Community) https://www.wch.cn/bbs/thread-157174-1.html
Tags: RISC-VCH32VCH32HQEMUQingKeWCHMounRiverSimulation

Have questions about this topic?

Start a Discussion Get a Quote