2013-01-08 22:40:58 +08:00
|
|
|
import os
|
|
|
|
ARCH = 'arm'
|
2013-07-21 17:19:30 +08:00
|
|
|
CPU = 'arm926'
|
2015-04-15 16:08:43 +08:00
|
|
|
# toolchains options
|
2015-04-15 17:21:41 +08:00
|
|
|
CROSS_TOOL = 'gcc'
|
2013-01-08 22:40:58 +08:00
|
|
|
|
2015-04-15 16:08:43 +08:00
|
|
|
#------- toolchains path -------------------------------------------------------
|
2013-01-08 22:40:58 +08:00
|
|
|
if os.getenv('RTT_CC'):
|
|
|
|
CROSS_TOOL = os.getenv('RTT_CC')
|
|
|
|
|
|
|
|
if CROSS_TOOL == 'gcc':
|
|
|
|
PLATFORM = 'gcc'
|
2017-10-19 23:46:17 +08:00
|
|
|
EXEC_PATH = r'D:\arm-2013.11\bin'
|
2013-01-08 22:40:58 +08:00
|
|
|
elif CROSS_TOOL == 'keil':
|
|
|
|
PLATFORM = 'armcc'
|
2015-04-14 21:56:34 +08:00
|
|
|
EXEC_PATH = 'C:/Keil_v5'
|
2013-01-08 22:40:58 +08:00
|
|
|
elif CROSS_TOOL == 'iar':
|
2015-04-15 16:08:43 +08:00
|
|
|
PLATFORM = 'iar'
|
|
|
|
IAR_PATH = 'C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0'
|
2013-01-08 22:40:58 +08:00
|
|
|
|
|
|
|
if os.getenv('RTT_EXEC_PATH'):
|
|
|
|
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
|
|
|
|
|
|
|
|
#BUILD = 'debug'
|
|
|
|
BUILD = 'release'
|
|
|
|
|
2015-04-15 16:08:43 +08:00
|
|
|
CORE = 'arm926ej-s'
|
|
|
|
MAP_FILE = 'rtthread_at91sam9260.map'
|
|
|
|
LINK_FILE = 'link_scripts/at91sam9260_ram'
|
|
|
|
TARGET_NAME = 'rtthread.bin'
|
|
|
|
|
|
|
|
#------- GCC settings ----------------------------------------------------------
|
2013-01-08 22:40:58 +08:00
|
|
|
if PLATFORM == 'gcc':
|
|
|
|
# toolchains
|
|
|
|
PREFIX = 'arm-none-eabi-'
|
|
|
|
CC = PREFIX + 'gcc'
|
|
|
|
AS = PREFIX + 'gcc'
|
|
|
|
AR = PREFIX + 'ar'
|
|
|
|
LINK = PREFIX + 'gcc'
|
|
|
|
TARGET_EXT = 'axf'
|
|
|
|
SIZE = PREFIX + 'size'
|
|
|
|
OBJDUMP = PREFIX + 'objdump'
|
|
|
|
OBJCPY = PREFIX + 'objcopy'
|
|
|
|
|
|
|
|
DEVICE = ' -mcpu=arm926ej-s'
|
|
|
|
CFLAGS = DEVICE
|
2015-04-15 16:08:43 +08:00
|
|
|
AFLAGS = '-c'+ DEVICE + ' -x assembler-with-cpp'
|
|
|
|
AFLAGS += ' -Iplatform'
|
|
|
|
LFLAGS = DEVICE
|
|
|
|
LFLAGS += ' -Wl,--gc-sections,-cref,-Map=' + MAP_FILE
|
|
|
|
LFLAGS += ' -T ' + LINK_FILE + '.ld'
|
2013-01-08 22:40:58 +08:00
|
|
|
|
|
|
|
CPATH = ''
|
|
|
|
LPATH = ''
|
|
|
|
|
|
|
|
if BUILD == 'debug':
|
|
|
|
CFLAGS += ' -O0 -gdwarf-2'
|
|
|
|
AFLAGS += ' -gdwarf-2'
|
|
|
|
else:
|
|
|
|
CFLAGS += ' -O2'
|
|
|
|
|
2015-04-15 16:08:43 +08:00
|
|
|
POST_ACTION = OBJCPY + ' -O binary $TARGET ' + TARGET_NAME + '\n'
|
|
|
|
POST_ACTION += SIZE + ' $TARGET\n'
|
|
|
|
#------- Keil settings ---------------------------------------------------------
|
2013-01-08 22:40:58 +08:00
|
|
|
elif PLATFORM == 'armcc':
|
|
|
|
# toolchains
|
|
|
|
CC = 'armcc'
|
|
|
|
AS = 'armasm'
|
|
|
|
AR = 'armar'
|
|
|
|
LINK = 'armlink'
|
|
|
|
TARGET_EXT = 'axf'
|
2015-04-15 16:08:43 +08:00
|
|
|
EXEC_PATH += '/arm/armcc/bin/'
|
2013-01-08 22:40:58 +08:00
|
|
|
|
2015-04-15 16:08:43 +08:00
|
|
|
DEVICE = ' --cpu=' + CORE
|
2013-01-08 22:40:58 +08:00
|
|
|
CFLAGS = DEVICE + ' --apcs=interwork --diag_suppress=870'
|
2015-04-14 21:56:34 +08:00
|
|
|
AFLAGS = DEVICE + ' -Iplatform'
|
2015-04-15 16:08:43 +08:00
|
|
|
LFLAGS = DEVICE + ' --strict'
|
|
|
|
LFLAGS += ' --info sizes --info totals --info unused --info veneers'
|
|
|
|
LFLAGS += ' --list ' + MAP_FILE
|
|
|
|
LFLAGS += ' --scatter ' + LINK_FILE + '.scat'
|
2013-01-08 22:40:58 +08:00
|
|
|
|
|
|
|
if BUILD == 'debug':
|
|
|
|
CFLAGS += ' -g -O0'
|
|
|
|
AFLAGS += ' -g'
|
|
|
|
else:
|
|
|
|
CFLAGS += ' -O2'
|
|
|
|
|
2015-04-15 16:08:43 +08:00
|
|
|
POST_ACTION = 'fromelf --bin $TARGET --output ' + TARGET_NAME + ' \n'
|
|
|
|
POST_ACTION += 'fromelf -z $TARGET\n'
|
|
|
|
#------- IAR settings ----------------------------------------------------------
|
|
|
|
elif PLATFORM == 'iar':
|
|
|
|
# toolchains
|
|
|
|
CC = 'iccarm'
|
|
|
|
AS = 'iasmarm'
|
|
|
|
AR = 'iarchive'
|
|
|
|
LINK = 'ilinkarm'
|
|
|
|
TARGET_EXT = 'out'
|
|
|
|
|
|
|
|
DEVICE = CORE
|
|
|
|
|
|
|
|
CFLAGS = '--cpu=' + DEVICE
|
|
|
|
CFLAGS += ' --diag_suppress Pa050'
|
|
|
|
CFLAGS += ' --no_cse'
|
|
|
|
CFLAGS += ' --no_unroll'
|
|
|
|
CFLAGS += ' --no_inline'
|
|
|
|
CFLAGS += ' --no_code_motion'
|
|
|
|
CFLAGS += ' --no_tbaa'
|
|
|
|
CFLAGS += ' --no_clustering'
|
|
|
|
CFLAGS += ' --no_scheduling'
|
|
|
|
|
|
|
|
CFLAGS += ' --endian=little'
|
|
|
|
CFLAGS += ' -e'
|
|
|
|
CFLAGS += ' --fpu=none'
|
|
|
|
CFLAGS += ' --dlib_config "' + IAR_PATH + '/arm/INC/c/DLib_Config_Normal.h"'
|
|
|
|
CFLAGS += ' --silent'
|
|
|
|
|
|
|
|
AFLAGS = '--cpu '+ DEVICE
|
|
|
|
AFLAGS += ' -s+'
|
|
|
|
AFLAGS += ' -w+'
|
|
|
|
AFLAGS += ' -r'
|
|
|
|
AFLAGS += ' --fpu none'
|
|
|
|
AFLAGS += ' -S'
|
|
|
|
AFLAGS += ' -Iplatform'
|
|
|
|
|
|
|
|
if BUILD == 'debug':
|
|
|
|
CFLAGS += ' --debug'
|
|
|
|
CFLAGS += ' -On'
|
|
|
|
else:
|
|
|
|
CFLAGS += ' -Oh'
|
|
|
|
|
|
|
|
LFLAGS = '--config ' + LINK_FILE +'.icf'
|
|
|
|
LFLAGS += ' --entry __iar_program_start'
|
|
|
|
LFLAGS += ' --map ' + MAP_FILE
|
|
|
|
LFLAGS += ' --silent'
|
|
|
|
|
|
|
|
EXEC_PATH = IAR_PATH + '/arm/bin/'
|
|
|
|
POST_ACTION = 'ielftool --silent --bin $TARGET ' + TARGET_NAME
|