roxma /
easymake
A handy makefile for simple C/C++ applications
46/100 healthLoading repository data…
nj-designs / repository
A simple Makefile based project for WCH's CHV32V range of RISCV uControllers
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
= LIBCH32V
== OVERVIEW
A simple Makefile based library for WCH's range of CH32Vxxx link:http://www.wch-ic.com/products/categories/47.html?pid=5[RISC-V uControllers].
There's not too much original work here, most of it has been collated from various file dumps etc. from WCH's own site and other pages.
== TOOLS SETUP
NOTE: The following assumes you are using some version of linux. It should work on mac with suitable adjustments. Not tried on windows. PRs for different platforms are welcomed.
=== GCC COMPILER
link: https://gcc.gnu.org/onlinedocs/gcc/RISC-V-Options.html
I've yet to find a known good binary build of the riscv32-unknow-* toolchain, the following shows how to build from source.
Add the following to your .bashrc or equivalent (don't forget to reload your shell).
==== Obtain and build gcc
git clone --branch master https://github.com/riscv/riscv-gnu-toolchain ~/github.com/riscv/riscv-gnu-toolchain cd ~/github.com/riscv/riscv-gnu-toolchain
./configure --prefix=${CH32_RISCV} --with-arch=rv32g --with-abi=ilp32
make -j$(nproc)
riscv32-unknown-elf-gcc --version
=== WLINK
I use the excellent link:https://github.com/ch32-rs/wlink[wlink] to flash the uController.
==== WLINK prerequisites
sudo cp run/60-libch32v.rules /etc/udev/rules.d/60-libch32v.rules
==== WLINK install
At the time of writing, wlink v0.1.1 was the latest released version. I suggest checking the link:https://github.com/ch32-rs/wlink/releases[release page] to see if that's changed.
cd /tmp wget https://github.com/ch32-rs/wlink/releases/download/v0.1.1/wlink-v0.1.1-linux-x64.tar.gz tar -xf wlink-v0.1.1-linux-x64.tar.gz
mkdir -p ${HOME}/.local/bin cp wlink-linux-x64/wlink ${HOME}/.local/bin
wlink list
=== OPENOCD
I've forked link:https://github.com/Seneral/riscv-openocd-wch to provide a somewhat stable openocd build.
As an alternative, I've included a a build of openocd in the run dir.
== BASIC WORKFLOW
Once all of the tools above are install/configured, you can build and test a version of blinky as follows.
=== BUILD
To build, simply run make in the root of this repo.
Linking... riscv32-unknown-elf-gcc -std=gnu2x -march=rv32imac_zicsr -mabi=ilp32e -ffreestanding -fno-pic -Os -Werror -g -Wall -Wextra -Ilib/include -Ibuild -DAPP_STDOUT_BUFFER_SIZE=1024 -DAPP_PROVIDE_PRINTF=1 -DAPP_PRINTF_DISABLE_SUPPORT_FLOAT -DAPP_PRINTF_DISABLE_SUPPORT_EXPONENTIAL -DAPP_PRINTF_DISABLE_SUPPORT_LONG_LONG -DAPP_HSE_FREQ=16000000 -DAPP_SYSCLK_FREQ=48000000 -DWCH_CH32V203G6U6=0x96ef63e9 -DLIBCH32_DEVICE_ID=WCH_CH32V203G6U6 -DLIBCH32_DEVICE_NAME="CH32V203G6U6" -DLIBCH32_FAMILY="v203" -DLIBCH32_FLASH_PROG_ADDR=0x08000000 -DLIBCH32_FLASH_SIZE=32768 -DLIBCH32_FLASH_START=0x00000000 -DLIBCH32_HAS_ADC1=1 -DLIBCH32_HAS_ADC2=1 -DLIBCH32_HAS_ADTM1=1 -DLIBCH32_HAS_GPIOA=1 -DLIBCH32_HAS_GPIOB=1 -DLIBCH32_HAS_GPIOD=1 -DLIBCH32_HAS_GPTM2=1 -DLIBCH32_HAS_GPTM3=1 -DLIBCH32_HAS_GPTM4=1 -DLIBCH32_HAS_I2C1=1 -DLIBCH32_HAS_SPI1=1 -DLIBCH32_HAS_USART1=1 -DLIBCH32_HAS_USART2=1 -DLIBCH32_LD_SCRIPT="ch32v.ld" -DLIBCH32_MABI="ilp32e" -DLIBCH32_MARCH="rv32imac_zicsr" -DLIBCH32_SRAM_SIZE=10240 -DLIBCH32_SRAM_START=0x20000000 -DLIBCH32_SYS_TICK_WIDTH=64 -ffunction-sections -fdata-sections build/lib/src/reset.o build/lib/src/v203/vector-v203.o build/app/led-flash/led-flash.o build/lib/src/adc.o build/lib/src/adtm.o build/lib/src/afio.o build/lib/src/core.o build/lib/src/dma.o build/lib/src/gpio.o build/lib/src/gptm.o build/lib/src/i2c.o build/lib/src/init.o build/lib/src/list_mgr.o build/lib/src/printf.o build/lib/src/rcc.o build/lib/src/spi.o build/lib/src/stdout-buffered.o build/lib/src/usart.o -Wl,-Map,build/led-flash.map -nostdlib -nodefaultlibs -nolibc -nostartfiles -Wl,--no-relax -Wl,--gc-sections -Wl,--defsym=RAM_ORIGIN=0x20000000 -Wl,--defsym=RAM_LENGTH=10240 -Wl,--defsym=FLASH_ORIGIN=0x00000000 -Wl,--defsym=FLASH_LENGTH=32768 -Wl,-Tlib/ld/link.ld --output build/led-flash.elf riscv32-unknown-elf-size -A -x build/led-flash.elf build/led-flash.elf : section size addr .init 0x4 0x0 .vector 0xfc 0x4 .text 0x69c 0x100 .fini 0x0 0x79c .dalign 0x0 0x20000000 .dlalign 0x0 0x79c .data 0x8 0x20000000 .bss 0x30 0x20000008 .stack 0x800 0x20002000 .gptm2 0x50 0x40000000 .gptm3 0x50 0x40000400 .gptm4 0x50 0x40000800 .usart2 0x1c 0x40004400 .i2c1 0x22 0x40005400 .afio 0xc 0x40010000 .gpio_a 0x1c 0x40010800 .gpio_b 0x1c 0x40010c00 .gpio_d 0x1c 0x40011400 .adc1 0x50 0x40012400 .adc2 0x50 0x40012800 .spi1 0x22 0x40013000 .adtm1 0x50 0x40012c00 .usart1 0x1c 0x40013800 .dma1 0xa8 0x40020000 .rcc 0x30 0x40021000 .pfic 0xd14 0xe000e000 .systick 0x18 0xe000f000 .riscv.attributes 0x54 0x0 .comment 0xf 0x0 .debug_line 0x2835 0x0 .debug_info 0x66b5 0x0 .debug_abbrev 0x1885 0x0 .debug_aranges 0x2f8 0x0 .debug_str 0x3660 0x0 .debug_ranges 0x20 0x0 .debug_loclists 0xa69 0x0 .debug_rnglists 0x239 0x0 .debug_line_str 0x1f9 0x0 .debug_frame 0x4b0 0x0 Total 0x11529
riscv32-unknown-elf-objdump -h -S -C build/led-flash.elf > build/led-flash.lst
riscv32-unknown-elf-nm -n build/led-flash.elf > build/led-flash.sym
=== PROGRAM
To program what's just been built.
=== DEBUG
If you want to debug your program, first flash your code to the device using make flash.
wlink-openocd -f run/wch-riscv.cfg -c init -c halt -c wlink_reset_resume
== TODO
== Links
link:https://clang.llvm.org/docs/ClangFormatStyleOptions.html
Selected from shared topics, language and repository description—not editorial ratings.
roxma /
A handy makefile for simple C/C++ applications
46/100 healthourway /
A simple HTTP server for mostly static content written in C
72/100 healthTransmissionZero /
A very simple "Hello World!" GLUT application demonstrating how to write OpenGL applications in C with MinGW and MSVC.
59/100 healthCondorLang /
A fast, simple, and intelligent new programming language
64/100 healthrikusalminen /
A simple Makefile for C executables and static libraries
56/100 healthshawn-dsilva /
A simple template to write, compile and flash code for the TM4C123G Launchpad board on a Linux system.
40/100 health