2014-10-20 10:10:18 +08:00
|
|
|
import os
|
|
|
|
|
|
|
|
# toolchains options
|
|
|
|
ARCH='arm'
|
|
|
|
CPU='cortex-m4'
|
|
|
|
CROSS_TOOL='keil'
|
2014-11-03 13:23:56 +08:00
|
|
|
BOARD_NAME = 'mb9bf568r'
|
2014-10-20 10:10:18 +08:00
|
|
|
|
|
|
|
if os.getenv('RTT_CC'):
|
2014-11-03 13:23:56 +08:00
|
|
|
CROSS_TOOL = os.getenv('RTT_CC')
|
2014-10-20 10:10:18 +08:00
|
|
|
|
|
|
|
if CROSS_TOOL == 'gcc':
|
2014-11-03 13:23:56 +08:00
|
|
|
PLATFORM = 'gcc'
|
|
|
|
EXEC_PATH = r'D:/Program Files (x86)/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin'
|
2014-10-20 10:10:18 +08:00
|
|
|
elif CROSS_TOOL == 'keil':
|
2014-11-03 13:23:56 +08:00
|
|
|
PLATFORM = 'armcc'
|
|
|
|
EXEC_PATH = 'D:/Keil'
|
2014-10-20 10:10:18 +08:00
|
|
|
elif CROSS_TOOL == 'iar':
|
|
|
|
print '================ERROR============================'
|
|
|
|
print 'Not support iar yet!'
|
|
|
|
print '================================================='
|
|
|
|
exit(0)
|
|
|
|
|
|
|
|
if os.getenv('RTT_EXEC_PATH'):
|
2014-11-03 13:23:56 +08:00
|
|
|
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
|
2014-10-20 10:10:18 +08:00
|
|
|
|
|
|
|
BUILD = 'debug'
|
|
|
|
|
|
|
|
if PLATFORM == 'gcc':
|
|
|
|
# toolchains
|
|
|
|
PREFIX = 'arm-none-eabi-'
|
|
|
|
CC = PREFIX + 'gcc'
|
2014-11-03 13:23:56 +08:00
|
|
|
CXX = PREFIX + 'g++'
|
2014-10-20 10:10:18 +08:00
|
|
|
AS = PREFIX + 'gcc'
|
|
|
|
AR = PREFIX + 'ar'
|
2014-11-03 13:23:56 +08:00
|
|
|
LINK = PREFIX + 'g++'
|
2014-10-20 10:10:18 +08:00
|
|
|
TARGET_EXT = 'elf'
|
|
|
|
SIZE = PREFIX + 'size'
|
|
|
|
OBJDUMP = PREFIX + 'objdump'
|
|
|
|
OBJCPY = PREFIX + 'objcopy'
|
|
|
|
|
|
|
|
DEVICE = ' -mcpu=cortex-m4 -mthumb'
|
|
|
|
CFLAGS = DEVICE
|
|
|
|
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
|
|
|
|
LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-' + BOARD_NAME + '.map,-cref,-u,Reset_Handler -T rtthread-' + BOARD_NAME + '.ld'
|
|
|
|
|
|
|
|
CPATH = ''
|
|
|
|
LPATH = ''
|
|
|
|
|
|
|
|
if BUILD == 'debug':
|
|
|
|
CFLAGS += ' -O0 -gdwarf-2'
|
|
|
|
AFLAGS += ' -gdwarf-2'
|
|
|
|
else:
|
|
|
|
CFLAGS += ' -O2'
|
2014-11-03 13:23:56 +08:00
|
|
|
CXXFLAGS = CFLAGS
|
2014-10-20 10:10:18 +08:00
|
|
|
|
|
|
|
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
|
|
|
|
|
|
|
|
elif PLATFORM == 'armcc':
|
|
|
|
# toolchains
|
|
|
|
CC = 'armcc'
|
|
|
|
AS = 'armasm'
|
|
|
|
AR = 'armar'
|
|
|
|
LINK = 'armlink'
|
|
|
|
TARGET_EXT = 'axf'
|
|
|
|
|
|
|
|
DEVICE = ' --cpu Cortex-M4.fp'
|
|
|
|
CFLAGS = DEVICE + ' --apcs=interwork'
|
|
|
|
AFLAGS = DEVICE
|
|
|
|
LFLAGS = DEVICE + ' --info sizes --info totals --info unused --info veneers --list rtthread_' + \
|
|
|
|
BOARD_NAME + '.map --scatter rtthread-' + BOARD_NAME + '.sct'
|
|
|
|
|
|
|
|
CFLAGS += ' -I' + EXEC_PATH + '/ARM/RV31/INC'
|
|
|
|
LFLAGS += ' --libpath ' + EXEC_PATH + '/ARM/RV31/LIB'
|
|
|
|
|
|
|
|
EXEC_PATH += '/arm/bin40/'
|
|
|
|
|
|
|
|
if BUILD == 'debug':
|
|
|
|
CFLAGS += ' -g -O0'
|
|
|
|
AFLAGS += ' -g'
|
|
|
|
else:
|
|
|
|
CFLAGS += ' -O2'
|
|
|
|
|
|
|
|
POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET'
|