2023-01-07 15:03:21 +08:00
|
|
|
import os
|
|
|
|
|
|
|
|
# toolchains options
|
|
|
|
ARCH ='risc-v'
|
|
|
|
CPU ='e9xx'
|
|
|
|
CROSS_TOOL ='gcc'
|
|
|
|
|
|
|
|
if os.getenv('RTT_ROOT'):
|
|
|
|
RTT_ROOT = os.getenv('RTT_ROOT')
|
|
|
|
else:
|
2023-03-19 14:41:18 +08:00
|
|
|
RTT_ROOT = r'../../../..'
|
2023-01-07 15:03:21 +08:00
|
|
|
|
|
|
|
if os.getenv('RTT_CC'):
|
|
|
|
CROSS_TOOL = os.getenv('RTT_CC')
|
|
|
|
|
|
|
|
if CROSS_TOOL == 'gcc':
|
|
|
|
PLATFORM = 'gcc'
|
|
|
|
EXEC_PATH = r'/opt/Xuantie-900-gcc-elf-newlib-x86_64-V2.6.1/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-'
|
|
|
|
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'
|
|
|
|
|
2023-03-19 14:41:18 +08:00
|
|
|
DEVICE = ' -march=rv32imafcpzpsfoperand_xtheade -mabi=ilp32f -mtune=e907'
|
|
|
|
CFLAGS = DEVICE + ' -std=gnu99 -fno-jump-tables -fno-common -fms-extensions -ffunction-sections -fdata-sections -fmessage-length=0 -Wall -Wchar-subscripts -Wformat -Wundef -Wuninitialized -Winit-self -Wignored-qualifiers'
|
|
|
|
CFLAGS += ' -fstrict-volatile-bitfields -fshort-enums -Wno-error=unused-variable -Wno-error=format= -Wno-error=unused-function -Wno-error=implicit-function-declaration -Wno-error=deprecated-declarations -Wno-format'
|
2023-01-07 15:03:21 +08:00
|
|
|
|
2023-03-19 14:41:18 +08:00
|
|
|
LINKER_SCRIPTS = r'board/linker_scripts/bl808_flash_m0.ld'
|
2023-01-07 15:03:21 +08:00
|
|
|
|
|
|
|
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
|
2023-03-19 14:41:18 +08:00
|
|
|
LFLAGS = DEVICE + ' -nostartfiles -ufw_header -fms-extensions -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,_start -T ' + LINKER_SCRIPTS
|
2023-01-07 15:03:21 +08:00
|
|
|
CPATH = ''
|
|
|
|
LPATH = ''
|
|
|
|
|
|
|
|
if BUILD == 'debug':
|
2023-03-19 14:41:18 +08:00
|
|
|
CFLAGS += ' -O2 -g3'
|
|
|
|
AFLAGS += ' -g3'
|
2023-01-07 15:03:21 +08:00
|
|
|
else:
|
|
|
|
CFLAGS += ' -O3'
|
|
|
|
|
|
|
|
CXXFLAGS = CFLAGS + ' -std=gnu++17 -Wno-multichar'
|
|
|
|
|
|
|
|
DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtt.asm\n'
|
|
|
|
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread_m0.bin\n' + SIZE + ' $TARGET \n'
|
2023-03-19 14:41:18 +08:00
|
|
|
POST_ACTION += 'sh combine.sh bl808 ./rtthread_m0.bin\n'
|