2023-06-30 00:05:55 +08:00
|
|
|
import os
|
|
|
|
|
|
|
|
# toolchains options
|
|
|
|
ARCH ='risc-v'
|
|
|
|
VENDOR ='t-head'
|
|
|
|
CPU ='c906'
|
|
|
|
CROSS_TOOL ='gcc'
|
|
|
|
|
|
|
|
if os.getenv('RTT_ROOT'):
|
|
|
|
RTT_ROOT = os.getenv('RTT_ROOT')
|
|
|
|
else:
|
2024-01-28 16:05:52 +08:00
|
|
|
RTT_ROOT = r'../../..'
|
2023-06-30 00:05:55 +08:00
|
|
|
|
|
|
|
if os.getenv('RTT_CC'):
|
|
|
|
CROSS_TOOL = os.getenv('RTT_CC')
|
|
|
|
|
|
|
|
if CROSS_TOOL == 'gcc':
|
|
|
|
PLATFORM = 'gcc'
|
|
|
|
EXEC_PATH = r'/opt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/bin'
|
|
|
|
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
|
|
|
|
#PREFIX = 'riscv64-unknown-elf-'
|
|
|
|
PREFIX = os.getenv('RTT_CC_PREFIX') or 'riscv64-unknown-linux-musl-'
|
|
|
|
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 = ' -mcmodel=medany -march=rv64imafdc -mabi=lp64'
|
|
|
|
CFLAGS = DEVICE + ' -Wno-cpp -fvar-tracking -ffreestanding -fno-common -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -D_POSIX_SOURCE '
|
|
|
|
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'
|
|
|
|
CPATH = ''
|
|
|
|
LPATH = ''
|
|
|
|
|
|
|
|
if BUILD == 'debug':
|
|
|
|
CFLAGS += ' -O0 -ggdb'
|
|
|
|
AFLAGS += ' -ggdb'
|
|
|
|
else:
|
|
|
|
CFLAGS += ' -O2 -Os'
|
|
|
|
|
|
|
|
CXXFLAGS = CFLAGS
|
|
|
|
|
|
|
|
DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtthread.asm\n'
|
2024-01-28 16:05:52 +08:00
|
|
|
POST_ACTION = OBJCPY + ' -O binary $TARGET Image\n' + SIZE + ' $TARGET \n' + './mksdimg.sh\n' + 'cd ../ && ./combine-fip.sh\n'
|