rtconfig.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import os
  2. # toolchains options
  3. ARCH ='risc-v'
  4. CPU ='e9xx'
  5. CROSS_TOOL ='gcc'
  6. BSP_LIBRARY_TYPE = 'bouffalo_lab'
  7. if os.getenv('RTT_ROOT'):
  8. RTT_ROOT = os.getenv('RTT_ROOT')
  9. else:
  10. RTT_ROOT = r'../../../..'
  11. if os.getenv('RTT_CC'):
  12. CROSS_TOOL = os.getenv('RTT_CC')
  13. if CROSS_TOOL == 'gcc':
  14. PLATFORM = 'gcc'
  15. EXEC_PATH = r'/opt/Xuantie-900-gcc-elf-newlib-x86_64-V2.6.1/bin'
  16. else:
  17. print('Please make sure your toolchains is GNU GCC!')
  18. exit(0)
  19. if os.getenv('RTT_EXEC_PATH'):
  20. EXEC_PATH = os.getenv('RTT_EXEC_PATH')
  21. BUILD = 'debug'
  22. if PLATFORM == 'gcc':
  23. # toolchains
  24. PREFIX = 'riscv64-unknown-elf-'
  25. CC = PREFIX + 'gcc'
  26. CXX = PREFIX + 'g++'
  27. AS = PREFIX + 'gcc'
  28. AR = PREFIX + 'ar'
  29. LINK = PREFIX + 'gcc'
  30. TARGET_EXT = 'elf'
  31. SIZE = PREFIX + 'size'
  32. OBJDUMP = PREFIX + 'objdump'
  33. OBJCPY = PREFIX + 'objcopy'
  34. DEVICE = ' -march=rv32imafcpzpsfoperand_xtheade -mabi=ilp32f -mtune=e907'
  35. CFLAGS = DEVICE + ' -std=gnu99 -fno-jump-tables -fno-common -fms-extensions -ffunction-sections -fdata-sections -fmessage-length=0 -Wall -Wchar-subscripts -Wformat -Wundef -Wuninitialized -Winit-self -Wignored-qualifiers'
  36. CFLAGS += ' -fstrict-volatile-bitfields -fshort-enums -Wno-error=unused-variable -Wno-error=format= -Wno-error=unused-function -Wno-error=implicit-function-declaration -Wno-error=deprecated-declarations -Wno-format'
  37. LINKER_SCRIPTS = r'board/linker_scripts/bl808_flash_m0.ld'
  38. AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
  39. LFLAGS = DEVICE + ' -nostartfiles -ufw_header -fms-extensions -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,_start -T ' + LINKER_SCRIPTS
  40. CPATH = ''
  41. LPATH = ''
  42. if BUILD == 'debug':
  43. CFLAGS += ' -O2 -g3'
  44. AFLAGS += ' -g3'
  45. else:
  46. CFLAGS += ' -O3'
  47. CXXFLAGS = CFLAGS + ' -std=gnu++17 -Wno-multichar'
  48. DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtt.asm\n'
  49. POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread_m0.bin\n' + SIZE + ' $TARGET \n'
  50. POST_ACTION += 'sh combine.sh bl808 ./rtthread_m0.bin\n'
  51. def dist_handle(BSP_ROOT, dist_dir):
  52. import sys
  53. cwd_path = os.getcwd()
  54. sys.path.append(os.path.join(os.path.dirname(BSP_ROOT), 'tools'))
  55. from sdk_dist import dist_do_building
  56. dist_do_building(BSP_ROOT, dist_dir)