2022-04-04 11:07:49 +08:00
|
|
|
import os
|
|
|
|
ARCH = 'risc-v'
|
2022-12-28 02:24:02 +08:00
|
|
|
CPU = 'ch32'
|
2022-04-04 11:07:49 +08:00
|
|
|
# toolchains options
|
|
|
|
CROSS_TOOL = 'gcc'
|
|
|
|
|
|
|
|
#------- toolchains path -------------------------------------------------------
|
|
|
|
if os.getenv('RTT_CC'):
|
|
|
|
CROSS_TOOL = os.getenv('RTT_CC')
|
|
|
|
|
|
|
|
if CROSS_TOOL == 'gcc':
|
|
|
|
PLATFORM = 'gcc'
|
2022-12-28 02:24:02 +08:00
|
|
|
EXEC_PATH = r'D:\RT-ThreadStudio\repo\Extract\ToolChain_Support_Packages\WCH\RISC-V-GCC-WCH\8.2.0\bin'
|
2022-04-04 11:07:49 +08:00
|
|
|
else:
|
|
|
|
print('Please make sure your toolchains is GNU GCC!')
|
|
|
|
exit(0)
|
|
|
|
|
2023-03-01 14:32:43 +08:00
|
|
|
if os.getenv('RTT_EXEC_PATH'):
|
|
|
|
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
|
2022-04-04 11:07:49 +08:00
|
|
|
|
|
|
|
BUILD = 'debug'
|
|
|
|
#BUILD = 'release'
|
|
|
|
|
|
|
|
CORE = 'risc-v'
|
|
|
|
MAP_FILE = 'rtthread.map'
|
|
|
|
LINK_FILE = './board/linker_scripts/link.lds'
|
|
|
|
TARGET_NAME = 'rtthread.bin'
|
|
|
|
|
|
|
|
#------- GCC settings ----------------------------------------------------------
|
|
|
|
if PLATFORM == 'gcc':
|
|
|
|
# toolchains
|
|
|
|
PREFIX = 'riscv-none-embed-'
|
|
|
|
CC = PREFIX + 'gcc'
|
|
|
|
CXX= PREFIX + 'g++'
|
|
|
|
AS = PREFIX + 'gcc'
|
|
|
|
AR = PREFIX + 'ar'
|
|
|
|
LINK = PREFIX + 'gcc'
|
|
|
|
TARGET_EXT = 'elf'
|
|
|
|
SIZE = PREFIX + 'size'
|
|
|
|
OBJDUMP = PREFIX + 'objdump'
|
|
|
|
OBJCPY = PREFIX + 'objcopy'
|
|
|
|
|
|
|
|
DEVICE = ' -march=rv32imac -mabi=ilp32 -DUSE_PLIC -DUSE_M_TIME -DNO_INIT -mcmodel=medany -msmall-data-limit=8 -L. -nostartfiles -lc '
|
|
|
|
CFLAGS = DEVICE
|
|
|
|
CFLAGS += ' -save-temps=obj'
|
|
|
|
AFLAGS = '-c'+ DEVICE + ' -x assembler-with-cpp'
|
|
|
|
LFLAGS = DEVICE
|
|
|
|
LFLAGS += ' -Wl,--gc-sections,-cref,-Map=' + MAP_FILE
|
|
|
|
LFLAGS += ' -T ' + LINK_FILE
|
|
|
|
LFLAGS += ' -Wl,-wrap=memset'
|
|
|
|
|
|
|
|
CPATH = ''
|
|
|
|
LPATH = ''
|
|
|
|
|
|
|
|
if BUILD == 'debug':
|
2022-12-28 02:24:02 +08:00
|
|
|
CFLAGS += ' -O1 -g3'
|
2022-04-04 11:07:49 +08:00
|
|
|
AFLAGS += ' -g3'
|
|
|
|
else:
|
|
|
|
CFLAGS += ' -O2'
|
|
|
|
|
|
|
|
POST_ACTION = OBJCPY + ' -O binary $TARGET ' + TARGET_NAME + '\n'
|
|
|
|
POST_ACTION += SIZE + ' $TARGET\n'
|