osconfig.py 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import os
  2. import platform
  3. import shutil
  4. # toolchains options
  5. ARCH='arm'
  6. CPU='cortex-m4'
  7. CROSS_TOOL='gcc'
  8. MODULE = 'QS-200'
  9. # bsp lib config
  10. BSP_LIBRARY_TYPE = None
  11. project_directory = os.getcwd()
  12. if os.getenv('OS_CC'):
  13. CROSS_TOOL = os.getenv('OS_CC')
  14. if os.getenv('OS_ROOT'):
  15. OS_ROOT = os.getenv('OS_ROOT')
  16. os_ver = platform.system()
  17. # cross_tool provides the cross compiler
  18. # COMPILER_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR
  19. if CROSS_TOOL == 'gcc':
  20. COMPILER = 'gcc'
  21. os_ver = platform.system()
  22. if os_ver == "Windows":
  23. COMPILER_PATH = './../../tools/gcc/bin'
  24. else :
  25. COMPILER_PATH = '/usr/bin'
  26. if CROSS_TOOL == 'gcc' and os.getenv('OS_EXEC_PATH'):
  27. COMPILER_PATH = os.getenv('OS_EXEC_PATH')
  28. BUILD = 'release'
  29. # BUILD = 'debug'
  30. if COMPILER == 'gcc':
  31. # toolchains
  32. PREFIX = 'arm-none-eabi-'
  33. CC = PREFIX + 'gcc'
  34. AS = PREFIX + 'gcc'
  35. AR = PREFIX + 'ar'
  36. CXX = PREFIX + 'gcc'
  37. LINK = PREFIX + 'gcc'
  38. RESULT_SUFFIX = 'elf'
  39. SIZE = PREFIX + 'size'
  40. OBJDUMP = PREFIX + 'objdump'
  41. OBJCPY = PREFIX + 'objcopy'
  42. 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 '
  43. 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 '
  44. AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb '
  45. LFLAGS = DEVICE + ' -Wall -Wextra -Wl,--gc-sections,-Map=zos.map,-cref,-u,Reset_Handler -T ./libraries/link/ln882h.ld '
  46. # LFLAGS = DEVICE + ' -Wall -Wextra -Wl,-Map=zos.map,-cref,-u,Reset_Handler -T ./libraries/link/ln882h.ld '
  47. CPATH = ''
  48. LPATH = ''
  49. if BUILD == 'debug':
  50. CFLAGS += ' -O2 -Os'
  51. AFLAGS += ' -O2 -Os'
  52. else:
  53. CFLAGS += ' -O2 -Os'
  54. AFLAGS += ' -O2 -Os'
  55. CXXFLAGS = CFLAGS
  56. POST_ACTION = OBJCPY + ' -O binary $TARGET zos.bin\n' + SIZE + ' $TARGET \n'
  57. 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'
  58. if os_ver == "Windows":
  59. if os.path.exists("." + '/zos.bin ') == True :
  60. os.remove("." + '/zos.bin ')
  61. if os.path.exists("." + '/zos.map ') == True :
  62. os.remove("." + '/zos.map ')
  63. if os.path.exists("." + '/zos.elf ') == True :
  64. os.remove("." + '/zos.elf ')
  65. else :
  66. POST_ACTION += 'rm -rf *.bin *.map *.' + RESULT_SUFFIX + ' \n'
  67. os.system('python ./tools/python_scripts/before_build_gcc.py -p ./cfg/flash_partition_cfg.json -o ./cfg/flash_partition_table.h')
  68. os.system('python ./tools/python_scripts/rewrite_ln882x_linker_script.py ./cfg/flash_partition_cfg.json ./libraries/link/ln882h.ld')
  69. # POST_ACTION += 'python QS200_mv.py\n'