Added a toolchain cmake file that targets the "riscv-none-elf" tripple.

This commit is contained in:
jakeg00dwin 2024-12-04 19:51:22 -08:00
parent 6d227bc37a
commit d374fff42e
1 changed files with 31 additions and 0 deletions

31
ch32v20x-toolchain.cmake Normal file
View File

@ -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)