2020-09-01 08:47:21 +08:00
|
|
|
import os
|
2021-10-15 17:38:50 +08:00
|
|
|
import platform
|
2020-09-01 08:47:21 +08:00
|
|
|
|
|
|
|
# toolchains options
|
|
|
|
ARCH='risc-v'
|
|
|
|
CPU='nuclei'
|
|
|
|
CROSS_TOOL='gcc'
|
|
|
|
|
|
|
|
if os.getenv('RTT_CC'):
|
|
|
|
CROSS_TOOL = os.getenv('RTT_CC')
|
|
|
|
|
|
|
|
if CROSS_TOOL == 'gcc':
|
|
|
|
PLATFORM = 'gcc'
|
2021-10-15 17:38:50 +08:00
|
|
|
if platform.system().lower() == "windows":
|
2023-03-01 14:32:43 +08:00
|
|
|
EXEC_PATH = r'/NucleiStudio/toolchain/gcc/bin'
|
2021-10-15 17:38:50 +08:00
|
|
|
else:
|
2023-03-01 14:32:43 +08:00
|
|
|
EXEC_PATH = r'~/NucleiStudio/toolchain/gcc/bin'
|
2021-10-15 17:38:50 +08:00
|
|
|
if os.path.exists(EXEC_PATH) == False:
|
|
|
|
print("Warning: Toolchain path %s doesn't exist, assume it is already in PATH" % EXEC_PATH)
|
|
|
|
EXEC_PATH = '' # Don't set path if not exist
|
2020-09-01 08:47:21 +08:00
|
|
|
else:
|
2021-10-15 17:38:50 +08:00
|
|
|
print("CROSS_TOOL = %s not yet supported" % CROSS_TOOL)
|
2020-09-01 08:47:21 +08:00
|
|
|
|
2021-10-15 17:38:50 +08:00
|
|
|
if os.getenv('RTT_EXEC_PATH'):
|
|
|
|
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
|
2020-09-01 08:47:21 +08:00
|
|
|
|
|
|
|
BUILD = 'debug'
|
|
|
|
# Fixed configurations below
|
2021-10-15 17:38:50 +08:00
|
|
|
NUCLEI_SDK_SOC = "demosoc"
|
|
|
|
NUCLEI_SDK_BOARD = "nuclei_fpga_eval"
|
2020-09-01 08:47:21 +08:00
|
|
|
# Configurable options below
|
2020-09-01 09:17:33 +08:00
|
|
|
# DOWNLOAD: https://doc.nucleisys.com/nuclei_sdk/develop/buildsystem.html#download
|
2020-09-01 08:47:21 +08:00
|
|
|
NUCLEI_SDK_DOWNLOAD = "ilm"
|
2020-09-01 09:17:33 +08:00
|
|
|
# CORE: See https://doc.nucleisys.com/nuclei_sdk/develop/buildsystem.html#core
|
2020-09-01 08:47:21 +08:00
|
|
|
NUCLEI_SDK_CORE = "nx600"
|
|
|
|
|
|
|
|
if PLATFORM == 'gcc':
|
|
|
|
# toolchains
|
|
|
|
PREFIX = 'riscv-nuclei-elf-'
|
|
|
|
CC = PREFIX + 'gcc'
|
|
|
|
CXX = PREFIX + 'g++'
|
|
|
|
AS = PREFIX + 'gcc'
|
|
|
|
AR = PREFIX + 'ar'
|
|
|
|
LINK = PREFIX + 'gcc'
|
|
|
|
GDB = PREFIX + 'gdb'
|
|
|
|
TARGET_EXT = 'elf'
|
|
|
|
SIZE = PREFIX + 'size'
|
|
|
|
OBJDUMP = PREFIX + 'objdump'
|
|
|
|
OBJCPY = PREFIX + 'objcopy'
|
|
|
|
|
|
|
|
CFLAGS = ' -ffunction-sections -fdata-sections -fno-common '
|
|
|
|
AFLAGS = CFLAGS
|
|
|
|
LFLAGS = ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
|
|
|
|
LFLAGS += ' -Wl,-cref,-Map=rtthread.map'
|
|
|
|
LFLAGS += ' -u _isatty -u _write -u _sbrk -u _read -u _close -u _fstat -u _lseek '
|
|
|
|
CPATH = ''
|
|
|
|
LPATH = ''
|
|
|
|
LIBS = ['stdc++']
|
2023-03-01 14:32:43 +08:00
|
|
|
AFLAGS += ' -D"irq_entry=SW_handler" '
|
2020-09-01 08:47:21 +08:00
|
|
|
|
|
|
|
if BUILD == 'debug':
|
|
|
|
CFLAGS += ' -O2 -ggdb'
|
|
|
|
AFLAGS += ' -ggdb'
|
|
|
|
else:
|
|
|
|
CFLAGS += ' -O2 -Os'
|
|
|
|
|
|
|
|
CXXFLAGS = CFLAGS
|
|
|
|
|
|
|
|
DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtt.asm\n'
|
|
|
|
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
|
|
|
|
|
|
|
|
def dist_handle(BSP_ROOT, dist_dir):
|
|
|
|
import sys
|
|
|
|
cwd_path = os.getcwd()
|
|
|
|
sys.path.append(os.path.join(os.path.dirname(BSP_ROOT), 'tools'))
|
|
|
|
from sdk_dist import dist_do_building
|
|
|
|
dist_do_building(BSP_ROOT, dist_dir)
|