2021-05-12 18:49:31 +08:00
|
|
|
import os
|
|
|
|
# toolchains options
|
|
|
|
ARCH = 'arm'
|
|
|
|
CPU = 'arm926'
|
|
|
|
# toolchains options
|
|
|
|
CROSS_TOOL = 'gcc'
|
|
|
|
|
|
|
|
if os.getenv('RTT_CC'):
|
|
|
|
CROSS_TOOL = os.getenv('RTT_CC')
|
2022-03-12 07:00:53 +08:00
|
|
|
if os.getenv('RTT_ROOT'):
|
|
|
|
RTT_ROOT = os.getenv('RTT_ROOT')
|
|
|
|
|
|
|
|
# cross_tool provides the cross compiler
|
|
|
|
# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR
|
2021-05-12 18:49:31 +08:00
|
|
|
|
|
|
|
if CROSS_TOOL == 'gcc':
|
|
|
|
PLATFORM = 'gcc'
|
|
|
|
EXEC_PATH = r'C:\Program Files (x86)\GNU Tools ARM Embedded\6 2017-q1-update\bin'
|
|
|
|
elif CROSS_TOOL == 'keil':
|
|
|
|
PLATFORM = 'armcc'
|
|
|
|
EXEC_PATH = r'C:\Keil_v5'
|
|
|
|
|
|
|
|
if os.getenv('RTT_EXEC_PATH'):
|
|
|
|
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
|
|
|
|
|
2022-12-29 15:15:13 +08:00
|
|
|
#BUILD = 'debug'
|
|
|
|
BUILD = ''
|
2021-05-12 18:49:31 +08:00
|
|
|
|
|
|
|
CORE = 'arm926ej-s'
|
|
|
|
MAP_FILE = 'rtthread_n9h30.map'
|
|
|
|
LINK_FILE = 'linking_scripts/n9h30'
|
|
|
|
TARGET_NAME = 'rtthread.bin'
|
|
|
|
|
|
|
|
#------- GCC settings ----------------------------------------------------------
|
|
|
|
if PLATFORM == 'gcc':
|
|
|
|
# toolchains
|
|
|
|
PREFIX = 'arm-none-eabi-'
|
|
|
|
CC = PREFIX + 'gcc'
|
|
|
|
AS = PREFIX + 'gcc'
|
|
|
|
AR = PREFIX + 'ar'
|
2022-03-12 07:00:53 +08:00
|
|
|
CXX = PREFIX + 'g++'
|
2021-05-12 18:49:31 +08:00
|
|
|
LINK = PREFIX + 'gcc'
|
|
|
|
TARGET_EXT = 'elf'
|
|
|
|
SIZE = PREFIX + 'size'
|
|
|
|
OBJDUMP = PREFIX + 'objdump'
|
|
|
|
OBJCPY = PREFIX + 'objcopy'
|
|
|
|
|
|
|
|
DEVICE = ' -mcpu=arm926ej-s'
|
|
|
|
CFLAGS = DEVICE
|
|
|
|
AFLAGS = '-c'+ DEVICE + ' -x assembler-with-cpp'
|
|
|
|
AFLAGS += ' -Iplatform'
|
|
|
|
LFLAGS = DEVICE
|
|
|
|
LFLAGS += ' -Wl,--gc-sections,-cref,-Map=' + MAP_FILE
|
|
|
|
LFLAGS += ' -T ' + LINK_FILE + '.ld'
|
|
|
|
|
|
|
|
CPATH = ''
|
|
|
|
LPATH = ''
|
|
|
|
|
|
|
|
if BUILD == 'debug':
|
2022-03-12 07:00:53 +08:00
|
|
|
CFLAGS += ' -O0 -gdwarf-2 -g'
|
2021-05-12 18:49:31 +08:00
|
|
|
AFLAGS += ' -gdwarf-2'
|
|
|
|
else:
|
2022-01-05 14:38:20 +08:00
|
|
|
CFLAGS += ' -O2'
|
2021-05-12 18:49:31 +08:00
|
|
|
|
2022-03-12 07:00:53 +08:00
|
|
|
CXXFLAGS = CFLAGS
|
|
|
|
|
2021-05-12 18:49:31 +08:00
|
|
|
POST_ACTION = OBJCPY + ' -O binary $TARGET ' + TARGET_NAME + '\n'
|
|
|
|
POST_ACTION += SIZE + ' $TARGET\n'
|
|
|
|
#------- Keil settings ---------------------------------------------------------
|
|
|
|
elif PLATFORM == 'armcc':
|
|
|
|
# toolchains
|
|
|
|
CC = 'armcc'
|
|
|
|
AS = 'armasm'
|
|
|
|
AR = 'armar'
|
|
|
|
LINK = 'armlink'
|
|
|
|
TARGET_EXT = 'axf'
|
|
|
|
EXEC_PATH += '/arm/armcc/bin/'
|
|
|
|
|
|
|
|
DEVICE = ' --cpu=' + CORE
|
|
|
|
CFLAGS = DEVICE + ' --apcs=interwork --diag_suppress=870'
|
|
|
|
AFLAGS = DEVICE + ' -Iplatform'
|
|
|
|
LFLAGS = DEVICE + ' --strict'
|
|
|
|
LFLAGS += ' --info sizes --info totals --info unused --info veneers'
|
|
|
|
LFLAGS += ' --list ' + MAP_FILE
|
|
|
|
LFLAGS += ' --scatter ' + LINK_FILE + '.sct'
|
|
|
|
|
|
|
|
if BUILD == 'debug':
|
|
|
|
CFLAGS += ' -g -O0'
|
|
|
|
AFLAGS += ' -g'
|
|
|
|
else:
|
|
|
|
CFLAGS += ' -O2'
|
|
|
|
|
|
|
|
POST_ACTION = 'fromelf --bin $TARGET --output ' + TARGET_NAME + ' \n'
|
2022-01-16 18:43:27 +08:00
|
|
|
POST_ACTION += 'fromelf -z $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)
|