rtconfig.py 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import os
  2. ARCH = 'risc-v'
  3. CPU = 'e901'
  4. # toolchains options
  5. CROSS_TOOL = 'gcc'
  6. #------- toolchains path -------------------------------------------------------
  7. if os.getenv('RTT_CC'):
  8. CROSS_TOOL = os.getenv('RTT_CC')
  9. if CROSS_TOOL == 'gcc':
  10. PLATFORM = 'gcc'
  11. EXEC_PATH = r'D:\C-Sky\CDKRepo\Toolchain\XTGccElfNewlib\V3.2.0\R\bin'
  12. else:
  13. print('Please make sure your toolchains is GNU GCC!')
  14. exit(0)
  15. if os.getenv('RTT_EXEC_PATH'):
  16. EXEC_PATH = os.getenv('RTT_EXEC_PATH')
  17. BUILD = 'debug'
  18. #BUILD = 'release'
  19. CORE = 'risc-v'
  20. MAP_FILE = 'rtthread.map'
  21. LINK_FILE = '../../libraries/xuantie_libraries/chip_riscv_dummy/gcc_flash_smartl_lite.ld'
  22. if os.path.exists('./libraries'):
  23. LINK_FILE = './libraries/xuantie_libraries/chip_riscv_dummy/gcc_flash_smartl_lite.ld'
  24. TARGET_NAME = 'rtthread.bin'
  25. #------- GCC settings ----------------------------------------------------------
  26. if PLATFORM == 'gcc':
  27. # toolchains
  28. PREFIX = 'riscv64-unknown-elf-'
  29. CC = PREFIX + 'gcc'
  30. CXX= PREFIX + 'g++'
  31. AS = PREFIX + 'gcc'
  32. AR = PREFIX + 'ar'
  33. LINK = PREFIX + 'gcc'
  34. TARGET_EXT = 'elf'
  35. SIZE = PREFIX + 'size'
  36. OBJDUMP = PREFIX + 'objdump'
  37. OBJCPY = PREFIX + 'objcopy'
  38. MCPU = ' -mcpu=e901plusbm-cp ' # Modify here based on CPU architecture.
  39. MCPU_DEFINE = ' -DCONFIG_CPU_XUANTIE_E901PLUS_BM_CP=1 ' # Modify here based on CPU architecture.
  40. DEVICE = MCPU + MCPU_DEFINE + ' -Wno-main -mcmodel=medany'
  41. GLOBAL_DEFINES = (
  42. '-DCONFIG_KERNEL_RTTHREAD=1 '
  43. '-D__RT_KERNEL_SOURCE__=1 '
  44. '-DCONFIG_CSI_V2=1 '
  45. '-DCONFIG_CSI=csi2 '
  46. '-DCONFIG_INIT_TASK_STACK_SIZE=4096 '
  47. '-DCONFIG_APP_TASK_STACK_SIZE=8192 '
  48. '-DCONFIG_ARCH_MAINSTACK=4096 '
  49. '-DCONFIG_ARCH_INTERRUPTSTACK=4096 '
  50. '-DCONFIG_XIP=1 '
  51. '-DCONFIG_LIBC_MINI_PRINTF_SUPPORT=1 '
  52. '-DCONFIG_SYSTICK_HZ=100 '
  53. '-DCONFIG_BOARD_SMARTL_EVB=1 '
  54. '-DCONFIG_DEBUG=1 '
  55. '-DCLI_CONFIG_STACK_SIZE=4096 '
  56. )
  57. CFLAGS = DEVICE + ' -g -Wall -Wno-unused-function -Wformat -Wformat-security -Warray-bounds -Wuninitialized \
  58. -Wreturn-type -Wcomment -Wswitch -Wparentheses -specs=minilibc.specs -MP -MMD -Os -Wpointer-arith \
  59. -Wno-undef -ffunction-sections -fdata-sections -fno-inline-functions -fno-builtin \
  60. -fno-strict-aliasing -Wno-char-subscripts -Wno-unused-but-set-variable ' + GLOBAL_DEFINES
  61. AFLAGS = DEVICE + ' -g -Wall -Wno-unused-function -Wformat -Wformat-security -Warray-bounds -Wuninitialized \
  62. -Wreturn-type -Wcomment -Wswitch -Wparentheses -specs=minilibc.specs -MP -MMD -Os -Wpointer-arith \
  63. -Wno-undef -ffunction-sections -fdata-sections -fno-inline-functions -fno-builtin \
  64. -fno-strict-aliasing -Wno-char-subscripts -Wno-unused-but-set-variable ' + ' -MP -MMD -D"Default_IRQHandler=SW_handler" ' + GLOBAL_DEFINES
  65. LFLAGS = DEVICE + ' -MP -MMD -Wl,-zmax-page-size=1024 -Wl,-Map=yoc.map -Wl,-zmax-page-size=1024 -Wl,-Map=yoc.map -Wl,--whole-archive -Wl,--no-whole-archive -specs=minilibc.specs -nostartfiles -Wl,--gc-sections '
  66. LFLAGS += ' -T ' + LINK_FILE
  67. CPATH = ''
  68. LPATH = ''
  69. if BUILD == 'debug':
  70. CFLAGS += ' -Os -g3'
  71. AFLAGS += ' -g3'
  72. else:
  73. CFLAGS += ' -O2 -g2'
  74. CXXFLAGS = CFLAGS
  75. POST_ACTION = OBJCPY + ' -O binary $TARGET ' + TARGET_NAME + '\n'
  76. POST_ACTION += SIZE + ' $TARGET\n'
  77. def dist_handle(BSP_ROOT, dist_dir):
  78. import sys
  79. cwd_path = os.getcwd()
  80. sys.path.append(os.path.join(os.path.dirname(BSP_ROOT), '../tools'))
  81. from sdk_dist import dist_do_building
  82. dist_do_building(BSP_ROOT, dist_dir)