ch32v003fun
An open source development environment (tooling, headers, examples) for the CH32V003 with gcc-riscv64 that can be used in Windows (Native), Linux and/or WSL. The CH32V003 is 10-cent part with a RISC-V EC core that runs at 48MHz, has 16kB of flash and 2kB of RAM and a bunch of peripherals. It also comes in SOP-8, QFN-20 and SOIC packages. You can get the datasheet here.
The goal of this project is to develop the tooling and environment for efficient use of the CH32V003. Avoid complicated HALs, and unleash the hardware! The existing EVT is massive, and dev environment weighty. This project specifically avoids the HAL and makes it so you can just use the TRM. In contrast, blinky is only 500 bytes with ch32v003fun, boots faster, and significantly simpler overall.
ch32v003fun contains:
- Examples using ch32v003fun, but not as many as using the HAL.
- "minichlink" which uses the WCH CH-Link with libusb, for cross-platform use.
- An STM32F042 Programmer, the NHC-Link042
- An ESP32S2 Programmer, the esp32s2-funprog
- The official WCH Link-E Programmer.
- An extra copy of libgcc so you can use unusual risc-v build chains, located in the
misc/libgcc.a
. - A folder named "ch32v003fun" containing a single self-contained source file and header file for compling apps for the ch32v003.
- On some systems ability to "printf" back through
- A demo bootloader.
In Progress:
- Other programmer support (ESP32-S2 works, currently)
- OpenOCD-compatible build for
minichlink
. - Full-chip-write for faster flash.
- Support for
NHC-Link042
- Write more demos.
Features
A fast "printf" debug over the programming interface.
And by fast I mean very fast. Typically around 36kBytes/sec.
./minichlink -T | pv > /dev/null
Found ESP32S2 Programmer
536KiB 0:00:15 [36.7KiB/s] [ <=> ]
You can just try out the debugprintf
project, or call SetupDebugPrintf();
and printf()
away.
todo;;
System Prep
On WSL or Debian based OSes apt-get install build-essential libnewlib-dev gcc-riscv64-unknown-elf libusb-1.0-0-dev libudev-dev
On Arch/Manjaro, sudo pacman -S base-devel libusb
, then from AUR install riscv64-unknown-elf-gcc, riscv64-unknown-elf-binutils, riscv64-unknown-elf-newlib
(will compile for a long time).
On Windows, download and install (to system) this copy of GCC10. https://gnutoolchains.com/risc-v/
On macOS install the RISC-V toolchain with homebrew following the instructions at https://github.com/riscv-software-src/homebrew-riscv