Template for C TDD that uses the cpputest framework/test harness. This template uses Makefiles instead of CMake
Find a file Use this template
2026-02-22 19:11:54 -08:00
.template_files Refactored template files 2025-12-23 14:22:47 -08:00
build created copy with generic name 2025-03-07 10:51:08 -08:00
docs Added empty dirs and hidden placeholders 2024-03-06 20:57:41 -08:00
extern Added extern dir for holding external dependencies. 2025-12-20 18:41:49 -08:00
inc Fixed GNU extension issue 2025-12-23 14:51:34 -08:00
src added window watchdog module and tests. 2026-02-22 19:11:54 -08:00
tests added window watchdog module and tests. 2026-02-22 19:11:54 -08:00
.clang-format fixed cli flags 2024-08-04 09:27:15 -07:00
.clang-format-ignore Added an clang formattiing ignore file. 2025-03-08 15:38:05 -08:00
.gitignore updated git ignore list to ignore all in build dir. 2026-02-05 13:44:35 -08:00
.gitmodules Removed the git submodule in root directory 2025-12-20 18:41:35 -08:00
CMakeLists.txt cleaned up commented out lines. 2025-12-20 19:40:47 -08:00
compile_commands.json added the compile commands symlink 2024-03-12 22:39:28 -07:00
Doxyfile Updated doxygen file to use the README.md file as the main 2025-03-26 19:24:22 -07:00
otto.sh commented out make main in favor of using PROJECT_NAME variable. 2026-02-15 16:35:35 -08:00
README.md updated readme with correct infomation on toolchain install for linux systems. 2026-02-15 16:28:51 -08:00
riscv32-toolchain.cmake Changed the refernces to "NEWLIB" --> "ALTCLIB" as it's more accurate. 2026-02-15 16:36:03 -08:00
setup.sh Added start of command to setup script. 2026-02-17 01:13:27 -08:00

CH32v003 Cmake + CppUTest Template

Goal

Be a flexable template repo for working with ch32v003 controllers while aslo inegrating TDD scripts using Cmake.

Requirements

  • CMake
  • Sh, Bash or compatible shell
  • Make/GMake/BSDMake/etc
  • clang/gcc
  • clangd
  • CppUTest(for unit tests)
  • NewLIB/newlib-nano(USE musl actually)
  • riscv toolchain xpack RISC-V TC

Installing toolchain

FreeBSD:

sudo pkg install gawk gsed

git clone https://github.com/riscv-collab/riscv-gnu-toolchain.git
cd ./riscv-gnu-toolchain

git submodule update --init --recursive

mkdir ./build && cd ./build

# Create needed dir for the output.
mkdir /usr/local/riscv && chmod -R 0775 /usr/local/riscv

# Setup to build newlib for 32bit embedded and compressed cpus.
# Not needed for ch32fun as it uses musl
./configure --prefix=/usr/local/riscv --with-arch=rv32ec \
    --with-arch=rv32ec \
    --with-abi=ilp32e \
    --with-multilib
make -j4 newlib

# Some Example options below.
make -j4 build-gcc1
make -j4 build-gcc2
make -j4 build-gdb
make -j4 build-libc
make -j4 build-llvm
make -j4 build-uclibc
make -j4 build-binutils

Linux:

Pretty much the same as FreeBSD, just follow the toolchain's README.md files instructions.

First download the tar.gz file from the link in the requirements(Xpack).

Once you've downloaded the latest release extract the archive into it's own file.

You should then move the contents into a new directory like so.

sudo mkdir -p /opt/riscv
tar -xvzf ./xpack<name_here>
sudo mv ./xpack<name_here>/* /opt/riscv/

You will also need to add the location to your path so it's picked up in your terminal.

# Appends the new location on to the existing path variable.
echo "export PATH=/opt/riscv/bin:$PATH" >> ~/.bashrc

# Sources the bashrc(config file) to update current terminal session.
source ~/.bashrc

After following the above steps you should now have a working RISC-V toolchain that can be used for development.

TODO

  • Add ch32v003fun sources.
  • Add example blinky default main.
  • Add useful test examples.
  • Add useful mock examples.
  • Get Blinky to run on hardware.
  • Set conditional compile/linker flags?
  • Get RegEdit setup for 32bit addresses.
  • Add full test suite for Mock of RegEdit module.