# 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](https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases) ## Installing toolchain **FreeBSD:** ```sh 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. ```sh sudo mkdir -p /opt/riscv tar -xvzf ./xpack sudo mv ./xpack/* /opt/riscv/ ``` You will also need to add the location to your path so it's picked up in your terminal. ```sh # 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 - [X] Add ch32v003fun sources. - [X] Add example blinky default main. - [X] Add useful test examples. - [ ] Add useful mock examples. - [X] Get Blinky to run on hardware. - [ ] Set conditional compile/linker flags? - [X] Get RegEdit setup for 32bit addresses. - [ ] Add full test suite for Mock of RegEdit module.