2021-05-18 09:57:25 +08:00
|
|
|
import os
|
|
|
|
|
|
|
|
# toolchains options
|
|
|
|
ARCH ='risc-v'
|
|
|
|
CPU ='virt64'
|
|
|
|
CROSS_TOOL ='gcc'
|
|
|
|
|
2022-12-03 12:07:44 +08:00
|
|
|
RTT_ROOT = os.getenv('RTT_ROOT') or os.path.join(os.getcwd(), '..', '..')
|
2021-05-18 09:57:25 +08:00
|
|
|
|
|
|
|
if os.getenv('RTT_CC'):
|
|
|
|
CROSS_TOOL = os.getenv('RTT_CC')
|
|
|
|
|
|
|
|
if CROSS_TOOL == 'gcc':
|
|
|
|
PLATFORM = 'gcc'
|
2022-12-03 12:07:44 +08:00
|
|
|
#EXEC_PATH = r'/home/lizhirui/workspace/riscv64-toolchains/bin'
|
|
|
|
EXEC_PATH = r'/opt/rtt_riscv64_musl/bin'
|
2021-05-18 09:57:25 +08:00
|
|
|
else:
|
|
|
|
print('Please make sure your toolchains is GNU GCC!')
|
|
|
|
exit(0)
|
|
|
|
|
|
|
|
if os.getenv('RTT_EXEC_PATH'):
|
|
|
|
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
|
|
|
|
|
|
|
|
BUILD = 'debug'
|
|
|
|
|
|
|
|
if PLATFORM == 'gcc':
|
|
|
|
# toolchains
|
2022-12-03 12:07:44 +08:00
|
|
|
PREFIX = os.getenv('RTT_CC_PREFIX') or 'riscv64-unknown-elf-'
|
|
|
|
# PREFIX = os.getenv('RTT_CC_PREFIX') or 'riscv64-unknown-linux-musl-'
|
2021-05-18 09:57:25 +08:00
|
|
|
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'
|
|
|
|
|
2022-12-03 12:07:44 +08:00
|
|
|
DEVICE = ' -mcmodel=medany -march=rv64imafdc -mabi=lp64 '
|
2022-12-10 22:16:42 +08:00
|
|
|
CFLAGS = DEVICE + '-ffreestanding -flax-vector-conversions -Wno-cpp -fno-common -ffunction-sections -fdata-sections -fstrict-volatile-bitfields'
|
2022-12-03 12:07:44 +08:00
|
|
|
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -D__ASSEMBLY__ '
|
|
|
|
LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,_start -T link.lds' + ' -lsupc++ -lgcc -static'
|
2021-05-18 09:57:25 +08:00
|
|
|
CPATH = ''
|
|
|
|
LPATH = ''
|
|
|
|
|
|
|
|
if BUILD == 'debug':
|
2022-12-03 12:07:44 +08:00
|
|
|
CFLAGS += ' -O0 -ggdb -fvar-tracking '
|
2021-05-18 09:57:25 +08:00
|
|
|
AFLAGS += ' -ggdb'
|
|
|
|
else:
|
|
|
|
CFLAGS += ' -O2 -Os'
|
|
|
|
|
|
|
|
CXXFLAGS = CFLAGS
|
|
|
|
|
|
|
|
DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtthread.asm\n'
|
|
|
|
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
|