A complete template project for the CH32V103 RISC-V microcontroller with CMake build system and automated CI/CD.
ch32v103-template/
├── .gitignore
├── CMakeLists.txt
├── LICENSE
├── README.md
├── .github/
├── apps/ # Application examples
│ └── framework/ # Application framework
├── core/ # Core system files
├── cpu/ # CPU-specific code
├── driver/ # Hardware abstraction layer
│ ├── inc/ # Driver header files
│ └── src/ # Driver source files
├── lib/ # Libraries
│ └── debug/ # Debug utilities
└── system/ # System-level code
-
RISC-V GCC Toolchain: Install using xPack
npm install -g xpm xpm install @xpack-dev-tools/riscv-none-elf-gcc@14.2.0-3.1
-
CMake: Version 3.16 or higher
# Ubuntu/Debian sudo apt-get install cmake # macOS brew install cmake # Windows # Download from https://cmake.org/download/
-
Make: Build system
# Ubuntu/Debian sudo apt-get install build-essential # macOS (via Xcode Command Line Tools) xcode-select --install
The toolchain will be installed in:
- Linux/macOS:
~/.local/xPacks/@xpack-dev-tools/riscv-none-elf-gcc/14.2.0-3.1/.content/bin/ - Windows:
%APPDATA%\xPacks\@xpack-dev-tools\riscv-none-elf-gcc\14.2.0-3.1\.content\bin\
Add this directory to your PATH environment variable.
-
Clone the repository:
git clone <repository-url> cd ch32v103-template
-
Create build directory:
mkdir build cd build -
Configure and build:
cmake .. make -j$(nproc)
To flash the compiled firmware to the CH32V103 microcontroller, use the WCH-Link tool (wlink).
Install wlink using Cargo:
cargo install --git https://github.com/ch32-rs/wlinkWCH-Link is a flash tool for WCH's RISC-V MCUs (CH32V, CH56X, CH57X, CH58X, CH59X, CH32L103, CH32X035, CH641, CH643).
Example: Flash the firmware binary to address 0x08000000:
wlink flash --address 0x08000000 ./firmware.binThis project template is provided as-is for educational and commercial use. Please check individual component licenses for specific terms.
- Fork the repository
- Create a feature branch
- Make your changes
- Test with the CI/CD pipeline
- Submit a pull request