rtconfig.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import os
  2. import sys
  3. # toolchains options
  4. ARCH='arm'
  5. CPU='cortex-m33'
  6. CROSS_TOOL='gcc'
  7. # bsp lib config
  8. BSP_LIBRARY_TYPE = None
  9. if os.getenv('RTT_CC'):
  10. CROSS_TOOL = os.getenv('RTT_CC')
  11. if os.getenv('RTT_ROOT'):
  12. RTT_ROOT = os.getenv('RTT_ROOT')
  13. # cross_tool provides the cross compiler
  14. # EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR
  15. if CROSS_TOOL == 'gcc':
  16. PLATFORM = 'gcc'
  17. EXEC_PATH = r'/usr/bin'
  18. # EXEC_PATH = r'C:\RT-ThreadStudio\repo\Extract\ToolChain_Support_Packages\ARM\GNU_Tools_for_ARM_Embedded_Processors\5.4.1\bin'
  19. elif CROSS_TOOL == 'keil':
  20. PLATFORM = 'armcc'
  21. EXEC_PATH = r'C:/Keil_v5'
  22. elif CROSS_TOOL == 'iar':
  23. PLATFORM = 'iccarm'
  24. EXEC_PATH = r'C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.3'
  25. if os.getenv('RTT_EXEC_PATH'):
  26. EXEC_PATH = os.getenv('RTT_EXEC_PATH')
  27. BUILD = 'debug'
  28. if PLATFORM == 'gcc':
  29. # toolchains
  30. PREFIX = 'arm-none-eabi-'
  31. CC = PREFIX + 'gcc'
  32. AS = PREFIX + 'gcc'
  33. AR = PREFIX + 'ar'
  34. CXX = PREFIX + 'g++'
  35. LINK = PREFIX + 'gcc'
  36. TARGET_EXT = 'elf'
  37. SIZE = PREFIX + 'size'
  38. OBJDUMP = PREFIX + 'objdump'
  39. OBJCPY = PREFIX + 'objcopy'
  40. DEVICE = ' -march=armv8-m.main+fp+dsp -mcpu=cortex-m33 -mthumb -ffunction-sections -fdata-sections -mfloat-abi=softfp -mfpu=fpv5-sp-d16 -mcmse'
  41. CFLAGS = DEVICE + ' -Dgcc'
  42. AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=always'
  43. LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rt-thread.map,-cref,-u,Reset_Handler -T link.ld'
  44. CPATH = ''
  45. LPATH = ''
  46. if BUILD == 'debug':
  47. CFLAGS += ' -O3 -gdwarf-2 -g'
  48. AFLAGS += ' -gdwarf-2'
  49. else:
  50. CFLAGS += ' -O2'
  51. CXXFLAGS = CFLAGS + ' -Wl,--build-id=none --specs=nosys.specs '
  52. POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
  53. elf2uf2_path = os.path.join(os.getcwd(), "tools", "picotool")
  54. os.system("chmod +x {0}".format(elf2uf2_path))
  55. POST_ACTION += "{0} uf2 convert --quiet rtthread-pico.elf rtthread-pico.uf2 --family rp2350-arm-s --abs-block".format(elf2uf2_path)