import os import platform import shutil # toolchains options ARCH='arm' CPU='cortex-m4' CROSS_TOOL='gcc' MODULE = 'QS-200' # bsp lib config BSP_LIBRARY_TYPE = None project_directory = os.getcwd() if os.getenv('OS_CC'): CROSS_TOOL = os.getenv('OS_CC') if os.getenv('OS_ROOT'): OS_ROOT = os.getenv('OS_ROOT') os_ver = platform.system() # cross_tool provides the cross compiler # COMPILER_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR if CROSS_TOOL == 'gcc': COMPILER = 'gcc' os_ver = platform.system() if os_ver == "Windows": COMPILER_PATH = './../../tools/gcc/bin' else : COMPILER_PATH = '/usr/bin' if CROSS_TOOL == 'gcc' and os.getenv('OS_EXEC_PATH'): COMPILER_PATH = os.getenv('OS_EXEC_PATH') BUILD = 'release' # BUILD = 'debug' if COMPILER == 'gcc': # toolchains PREFIX = 'arm-none-eabi-' CC = PREFIX + 'gcc' AS = PREFIX + 'gcc' AR = PREFIX + 'ar' CXX = PREFIX + 'gcc' LINK = PREFIX + 'gcc' RESULT_SUFFIX = 'elf' SIZE = PREFIX + 'size' OBJDUMP = PREFIX + 'objdump' OBJCPY = PREFIX + 'objcopy' DEVICE = ' -mcpu=cortex-m4 -std=gnu11 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -mabi=aapcs -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-strict-aliasing -mabi=aapcs --specs=nano.specs --specs=nosys.specs -Xlinker -zmuldefs -u _printf_float ' CFLAGS = DEVICE + ' -Wall -Wextra -g -Wundef -Wshadow -Wredundant-decls -Wstrict-prototypes -Wimplicit-function-declaration -Wmissing-prototypes -Wdouble-promotion -Wfloat-conversion -MD -MP -DLN882H -DARM_MATH_CM4 ' AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb ' LFLAGS = DEVICE + ' -Wall -Wextra -Wl,--gc-sections,-Map=zos.map,-cref,-u,Reset_Handler -T ./libraries/link/ln882h.ld ' # LFLAGS = DEVICE + ' -Wall -Wextra -Wl,-Map=zos.map,-cref,-u,Reset_Handler -T ./libraries/link/ln882h.ld ' CPATH = '' LPATH = '' if BUILD == 'debug': CFLAGS += ' -O2 -Os' AFLAGS += ' -O2 -Os' else: CFLAGS += ' -O2 -Os' AFLAGS += ' -O2 -Os' CXXFLAGS = CFLAGS POST_ACTION = OBJCPY + ' -O binary $TARGET zos.bin\n' + SIZE + ' $TARGET \n' POST_ACTION += 'python ./tools/python_scripts/after_build_gcc.py --sdkroot_dir ./libraries --userproj_dir ./ --buildout_dir ./ --buildout_name zos -o ./../../out/QS-200/zos.bin\n' if os_ver == "Windows": if os.path.exists("." + '/zos.bin ') == True : os.remove("." + '/zos.bin ') if os.path.exists("." + '/zos.map ') == True : os.remove("." + '/zos.map ') if os.path.exists("." + '/zos.elf ') == True : os.remove("." + '/zos.elf ') else : POST_ACTION += 'rm -rf *.bin *.map *.' + RESULT_SUFFIX + ' \n' os.system('python ./tools/python_scripts/before_build_gcc.py -p ./cfg/flash_partition_cfg.json -o ./cfg/flash_partition_table.h') os.system('python ./tools/python_scripts/rewrite_ln882x_linker_script.py ./cfg/flash_partition_cfg.json ./libraries/link/ln882h.ld') # POST_ACTION += 'python QS200_mv.py\n'