2024-12-05 03:51:22 +00:00
|
|
|
# ###############################
|
|
|
|
# CH32V20X toolchain file
|
|
|
|
# ###############################
|
|
|
|
|
|
|
|
# Specify the cross-compiler
|
|
|
|
set(CMAKE_SYSTEM_NAME Generic)
|
|
|
|
set(CMAKE_SYSTEM_VERSION 1)
|
|
|
|
set(CMAKE_SYSTEM_PROCESSOR riscv)
|
|
|
|
|
2024-12-07 03:38:26 +00:00
|
|
|
set(MCU ch32v203)
|
|
|
|
set(MARCH rv32imac)
|
|
|
|
set(MABI ilp32)
|
2024-12-05 03:51:22 +00:00
|
|
|
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)
|
|
|
|
|
2024-12-07 03:38:26 +00:00
|
|
|
# #####################################
|
|
|
|
# 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"
|
|
|
|
|
2024-12-05 03:51:22 +00:00
|
|
|
# Define compile options
|
2024-12-07 06:28:14 +00:00
|
|
|
# Should check to see if parts are all compiled using same options
|
2024-12-07 03:38:26 +00:00
|
|
|
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}")
|
2024-12-07 06:28:14 +00:00
|
|
|
#set(CMAKE_EXE_LINKER_FLAGS_INIT "-mmcu=${AVR_MCU}")
|
2024-12-05 03:51:22 +00:00
|
|
|
|
|
|
|
# Define the archiver and other tools
|
2024-12-07 03:38:26 +00:00
|
|
|
set(CMAKE_AR ${TRIPPLE}-gcc-ar)
|
|
|
|
set(CMAKE_RANLIB ${TRIPPLE}-gcc-ranlib)
|