rtconfig.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import os
  2. import uuid
  3. def get_mac_address():
  4. mac=uuid.UUID(int = uuid.getnode()).hex[-12:]
  5. return "#define AUTOMAC".join([str(int(e/2) + 1) + ' 0x' + mac[e:e+2] + '\n' for e in range(5,11,2)])
  6. header = '''
  7. #ifndef __MAC_AUTO_GENERATE_H__
  8. #define __MAC_AUTO_GENERATE_H__
  9. /* Automatically generated file; DO NOT EDIT. */
  10. /* mac configure file for RT-Thread qemu */
  11. #define AUTOMAC0 0x52
  12. #define AUTOMAC1 0x54
  13. #define AUTOMAC2 0x00
  14. #define AUTOMAC'''
  15. end = '''
  16. #endif
  17. '''
  18. automac_h_fn = os.path.join(os.path.dirname(__file__), 'drivers', 'automac.h')
  19. with open(automac_h_fn, 'w') as f:
  20. f.write(header + get_mac_address() + end)
  21. # toolchains options
  22. ARCH ='arm'
  23. CPU ='cortex-a'
  24. CROSS_TOOL = 'gcc'
  25. PLATFORM = 'gcc'
  26. EXEC_PATH = os.getenv('RTT_EXEC_PATH') or r'/usr/bin'
  27. BUILD = 'debug'
  28. LINK_SCRIPT = 'link.lds'
  29. if PLATFORM == 'gcc':
  30. PREFIX = os.getenv('RTT_CC_PREFIX') or 'arm-none-eabi-'
  31. CC = PREFIX + 'gcc'
  32. CXX = PREFIX + 'g++'
  33. AS = PREFIX + 'gcc'
  34. AR = PREFIX + 'ar'
  35. LINK = PREFIX + 'gcc'
  36. TARGET_EXT = 'elf'
  37. SIZE = PREFIX + 'size'
  38. OBJDUMP = PREFIX + 'objdump'
  39. OBJCPY = PREFIX + 'objcopy'
  40. STRIP = PREFIX + 'strip'
  41. CFPFLAGS = ' -msoft-float'
  42. AFPFLAGS = ' -mfloat-abi=softfp -mfpu=neon'
  43. DEVICE = ' -march=armv7-a -mtune=cortex-a7 -ftree-vectorize -ffast-math -funwind-tables -fno-strict-aliasing'
  44. CXXFLAGS= DEVICE + CFPFLAGS + ' -Wall -fdiagnostics-color=always'
  45. CFLAGS = DEVICE + CFPFLAGS + ' -Wall -Wno-cpp -std=gnu99 -D_POSIX_SOURCE -fdiagnostics-color=always'
  46. AFLAGS = DEVICE + ' -c' + AFPFLAGS + ' -x assembler-with-cpp'
  47. LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,system_vectors -T '+ LINK_SCRIPT + ' -lsupc++ -lgcc -static'
  48. CPATH = ''
  49. LPATH = ''
  50. if BUILD == 'debug':
  51. CFLAGS += ' -O0 -gdwarf-2'
  52. CXXFLAGS += ' -O0 -gdwarf-2'
  53. AFLAGS += ' -gdwarf-2'
  54. else:
  55. CFLAGS += ' -Os'
  56. CXXFLAGS += ' -Os'
  57. CXXFLAGS += ' -Woverloaded-virtual -fno-rtti'
  58. M_CFLAGS = CFLAGS + ' -mlong-calls -fPIC '
  59. M_CXXFLAGS = CXXFLAGS + ' -mlong-calls -fPIC'
  60. M_LFLAGS = DEVICE + CXXFLAGS + ' -Wl,--gc-sections,-z,max-page-size=0x4' +\
  61. ' -shared -fPIC -nostartfiles -nostdlib -static-libgcc'
  62. M_POST_ACTION = STRIP + ' -R .hash $TARGET\n' + SIZE + ' $TARGET \n'
  63. DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtt.asm\n'
  64. POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'