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-03-17 18:25:27 -07:00
.template_files updated the template cmakelists.txt file to use variables from toolchain files. 2026-02-24 19:02:09 -08:00
build created copy with generic name 2025-03-07 10:51:08 -08:00
docs
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 updated window watchdog to use the toolchain file variables. 2026-02-24 19:02:44 -08:00
tests Added tests module for wwdg/mocks. 2026-03-17 18:25:27 -07: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 Added ignore for all core dump files. 2026-03-17 18:21:23 -07:00
.gitmodules Removed the git submodule in root directory 2025-12-20 18:41:35 -08:00
CMakeLists.txt fixed typo in comment of main cmake file. 2026-02-22 19:32:42 -08:00
compile_commands.json added the compile commands symlink 2024-03-12 22:39:28 -07:00
Doxyfile updated doxygen config to include better default name and version info 2026-03-17 18:21:40 -07:00
i2c_design.md Adding new docs(markdown) for holding thoughts/ideas on design of i2c and multiple mcu support. 2026-03-17 18:23:07 -07:00
mcu_support.md Adding new docs(markdown) for holding thoughts/ideas on design of i2c and multiple mcu support. 2026-03-17 18:23:07 -07:00
otto.sh Updated otto script to allow more granular testing and more obvious error finding. 2026-03-17 18:22:33 -07:00
README.md removed whitespace from readme. 2026-03-17 18:21:48 -07:00
riscv32-toolchain.cmake Added comments to the toolchain file for where future configs may be placed. 2026-02-24 19:03:54 -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.