Template for C TDD that uses the cpputest framework/test harness. This template uses Makefiles instead of CMake
Find a file Use this template
jake 6a7e10b4fb Added structure tags to avoid usign GNU extension
I just addded the tag 's' for all the anonymous structures as they don't
use typedef and their scope is limited.

Seems to compile for my testing so far.
2025-03-09 09:20:17 -07:00
.template_files
build
cpputest@c3625dc668
docs
inc Added structure tags to avoid usign GNU extension 2025-03-09 09:20:17 -07:00
mocks Added tests and mocks from other template 2025-03-08 17:07:04 -08:00
src Added comments on ch32v003 pins for ADC along with updated date/top info. 2025-03-09 08:28:24 -07:00
tests Commented out tests for ADC that were dependant on AVR stuff. 2025-03-09 08:27:58 -07:00
.clang-format
.clang-format-ignore Added an clang formattiing ignore file. 2025-03-08 15:38:05 -08:00
.gitignore
.gitmodules
CMakeLists.txt Cleaned up commented out stuff. 2025-03-08 18:44:34 -08:00
compile_commands.json
Doxyfile
otto.sh modified to make main instead of all or hex-release 2025-03-08 17:31:29 -08:00
README.md Added other item to work on 2025-03-08 17:07:19 -08:00
riscv32-toolchain.cmake commented out lines in toolchain file. 2025-03-08 17:31:42 -08:00
setup.sh

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

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.
./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.

TODO

  • Add NewLib finding/functionality
  • Add NewLib-nano finding/functionality
  • 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.