From d374fff42ecbd46572bb830b1c4bec44bb176fb4 Mon Sep 17 00:00:00 2001 From: jakeg00dwin Date: Wed, 4 Dec 2024 19:51:22 -0800 Subject: [PATCH] Added a toolchain cmake file that targets the "riscv-none-elf" tripple. --- ch32v20x-toolchain.cmake | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 ch32v20x-toolchain.cmake diff --git a/ch32v20x-toolchain.cmake b/ch32v20x-toolchain.cmake new file mode 100644 index 0000000..5fc6f0e --- /dev/null +++ b/ch32v20x-toolchain.cmake @@ -0,0 +1,31 @@ +# ############################### +# CH32V20X toolchain file +# ############################### + +# Specify the cross-compiler +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_VERSION 1) +set(CMAKE_SYSTEM_PROCESSOR riscv) + +set(MCU ch32v203) # +set(F_CPU 144000000UL) +set(PROGRAMMER wlink) + +# Define the toolchain executables +set(TRIPPLE riscv-none-elf) +set(CMAKE_C_COMPILER ${TRIPPLE}-gcc) +set(CMAKE_CXX_COMPILER ${TRIPPLE}-g++) +set(CMAKE_ASM_COMPILER ${TRIPPLE}-gcc) +set(CMAKE_LINKER ${TRIPPLE}-ld) +set(CMAKE_OBJCOPY ${TRIPPLE}-objcopy) +set(CMAKE_SIZE ${TRIPPLE}-size) + +# Define compile options +set(CMAKE_C_FLAGS " -Os -mmcu=${AVR_MCU} -DF_CPU=${F_CPU}") +set(CMAKE_CXX_FLAGS "-mmcu=${AVR_MCU} -DF_CPU=${F_CPU}") +set(CMAKE_EXE_LINKER_FLAGS_INIT "-mmcu=${AVR_MCU}") + + +# Define the archiver and other tools +set(CMAKE_AR avr-ar) +set(CMAKE_RANLIB avr-ranlib)