2017-09-19 12:14:52 +08:00
|
|
|
import os
|
|
|
|
|
2019-05-12 21:53:47 +08:00
|
|
|
import uuid
|
2022-11-23 10:40:50 +08:00
|
|
|
def get_mac_address():
|
|
|
|
mac=uuid.UUID(int = uuid.getnode()).hex[-12:]
|
2019-09-02 11:21:11 +08:00
|
|
|
return "#define AUTOMAC".join([str(int(e/2) + 1) + ' 0x' + mac[e:e+2] + '\n' for e in range(5,11,2)])
|
2019-05-12 21:53:47 +08:00
|
|
|
|
|
|
|
header = '''
|
|
|
|
#ifndef __MAC_AUTO_GENERATE_H__
|
|
|
|
#define __MAC_AUTO_GENERATE_H__
|
|
|
|
|
|
|
|
/* Automatically generated file; DO NOT EDIT. */
|
|
|
|
/* mac configure file for RT-Thread qemu */
|
|
|
|
|
|
|
|
#define AUTOMAC0 0x52
|
|
|
|
#define AUTOMAC1 0x54
|
|
|
|
#define AUTOMAC2 0x00
|
|
|
|
#define AUTOMAC'''
|
|
|
|
|
|
|
|
end = '''
|
|
|
|
#endif
|
|
|
|
'''
|
|
|
|
|
2019-07-30 15:11:03 +08:00
|
|
|
automac_h_fn = os.path.join(os.path.dirname(__file__), 'drivers', 'automac.h')
|
|
|
|
with open(automac_h_fn, 'w') as f:
|
2019-05-12 21:53:47 +08:00
|
|
|
f.write(header + get_mac_address() + end)
|
|
|
|
|
2017-09-19 12:14:52 +08:00
|
|
|
# toolchains options
|
2022-11-23 10:40:50 +08:00
|
|
|
ARCH ='arm'
|
|
|
|
CPU ='cortex-a'
|
|
|
|
CROSS_TOOL = 'gcc'
|
2018-04-26 09:11:37 +08:00
|
|
|
PLATFORM = 'gcc'
|
2022-11-23 10:40:50 +08:00
|
|
|
EXEC_PATH = os.getenv('RTT_EXEC_PATH') or r'/usr/bin'
|
|
|
|
BUILD = 'debug'
|
2017-09-19 12:14:52 +08:00
|
|
|
|
2022-12-03 12:07:44 +08:00
|
|
|
# LINK_SCRIPT = 'link-lwp.lds'
|
|
|
|
LINK_SCRIPT = 'link.lds'
|
|
|
|
|
2017-09-19 12:14:52 +08:00
|
|
|
if PLATFORM == 'gcc':
|
2022-12-07 11:30:28 +08:00
|
|
|
PREFIX = os.getenv('RTT_EXEC_PREFIX') or 'arm-none-eabi-'
|
2022-11-23 10:40:50 +08:00
|
|
|
CC = PREFIX + 'gcc'
|
|
|
|
CXX = PREFIX + 'g++'
|
|
|
|
AS = PREFIX + 'gcc'
|
|
|
|
AR = PREFIX + 'ar'
|
|
|
|
LINK = PREFIX + 'gcc'
|
2017-09-19 12:14:52 +08:00
|
|
|
TARGET_EXT = 'elf'
|
2022-11-23 10:40:50 +08:00
|
|
|
SIZE = PREFIX + 'size'
|
2017-09-19 12:14:52 +08:00
|
|
|
OBJDUMP = PREFIX + 'objdump'
|
2022-11-23 10:40:50 +08:00
|
|
|
OBJCPY = PREFIX + 'objcopy'
|
|
|
|
STRIP = PREFIX + 'strip'
|
|
|
|
CFPFLAGS = ' -msoft-float'
|
|
|
|
AFPFLAGS = ' -mfloat-abi=softfp -mfpu=neon'
|
|
|
|
DEVICE = ' -march=armv7-a -mtune=cortex-a7 -ftree-vectorize -ffast-math -funwind-tables -fno-strict-aliasing'
|
|
|
|
|
|
|
|
CXXFLAGS= DEVICE + CFPFLAGS + ' -Wall'
|
|
|
|
CFLAGS = DEVICE + CFPFLAGS + ' -Wall -std=gnu99'
|
2022-12-03 12:07:44 +08:00
|
|
|
AFLAGS = DEVICE + ' -c' + AFPFLAGS + ' -x assembler-with-cpp'
|
|
|
|
LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,system_vectors -T '+ LINK_SCRIPT + ' -lsupc++ -lgcc -static'
|
2022-11-23 10:40:50 +08:00
|
|
|
CPATH = ''
|
|
|
|
LPATH = ''
|
2017-09-19 12:14:52 +08:00
|
|
|
|
|
|
|
if BUILD == 'debug':
|
2022-11-23 10:40:50 +08:00
|
|
|
CFLAGS += ' -O0 -gdwarf-2'
|
|
|
|
CXXFLAGS += ' -O0 -gdwarf-2'
|
|
|
|
AFLAGS += ' -gdwarf-2'
|
2017-09-19 12:14:52 +08:00
|
|
|
else:
|
2022-11-23 10:40:50 +08:00
|
|
|
CFLAGS += ' -Os'
|
|
|
|
CXXFLAGS += ' -Os'
|
|
|
|
CXXFLAGS += ' -Woverloaded-virtual -fno-exceptions -fno-rtti'
|
2017-09-19 12:14:52 +08:00
|
|
|
|
2018-04-26 11:34:22 +08:00
|
|
|
M_CFLAGS = CFLAGS + ' -mlong-calls -fPIC '
|
|
|
|
M_CXXFLAGS = CXXFLAGS + ' -mlong-calls -fPIC'
|
|
|
|
M_LFLAGS = DEVICE + CXXFLAGS + ' -Wl,--gc-sections,-z,max-page-size=0x4' +\
|
2018-04-26 23:20:58 +08:00
|
|
|
' -shared -fPIC -nostartfiles -nostdlib -static-libgcc'
|
2018-04-26 11:34:22 +08:00
|
|
|
M_POST_ACTION = STRIP + ' -R .hash $TARGET\n' + SIZE + ' $TARGET \n'
|
|
|
|
|
2022-11-23 10:40:50 +08:00
|
|
|
DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtt.asm\n'
|
2022-12-07 11:30:28 +08:00
|
|
|
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
|