# ############################### # 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(MARCH rv32imac) set(MABI ilp32) 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) # ##################################### # Flags and Options for ELF building # ##################################### #riscv-none-embed-gcc -march=rv32imac -mabi=ilp32 -msmall-data-limit=8 #-msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections #-fdata-sections -fno-common -Wunused -Wuninitialized #-g -T "/home/ronin/mrs_community-workspace/CH32V203K8T6/Ld/Link.ld" #-nostartfiles -Xlinker --gc-sections -Wl,-Map,"CH32V203K8T6.map" #--specs=nano.specs --specs=nosys.specs -o "CH32V203K8T6.elf" #$(OBJS) $(USER_OBJS) $(LIBS) # ##################################### # Building HEX file # ##################################### #riscv-none-embed-objcopy -O ihex "CH32V203K8T6.elf" "CH32V203K8T6.hex" # ##################################### # LST building # ##################################### #riscv-none-embed-objdump --all-headers --demangle --disassemble "CH32V203K8T6.elf" > "CH32V203K8T6.lst" # ##################################### # Size building or CMD # ##################################### #riscv-none-embed-size --format=berkeley "CH32V203K8T6.elf" # Define compile options # Should check to see if parts are all compiled using same options set(CMAKE_C_FLAGS "-march=${MARCH} -mabi=${MABI} -msmall-data-limit=8\ -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections\ -fdata-section -fno-common -Wunused -Wuninitialized -g\ -T ./src/linker/Link.ld -nostartfiles -Xlinker --gc-sections -Wl\ --specs=nano.sepcs --specs=nosys.specs ") set(CMAKE_CXX_FLAGS "-march=${MARCH}") #set(CMAKE_EXE_LINKER_FLAGS_INIT "-mmcu=${AVR_MCU}") # Define the archiver and other tools set(CMAKE_AR ${TRIPPLE}-gcc-ar) set(CMAKE_RANLIB ${TRIPPLE}-gcc-ranlib)