Kiibohd Controller
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

arm.cmake 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. ###| CMAKE Kiibohd Controller |###
  2. #
  3. # Jacob Alexander 2011-2014
  4. # Due to this file's usefulness:
  5. #
  6. # Released into the Public Domain
  7. #
  8. # Freescale ARM CMake Build Configuration
  9. #
  10. ###
  11. #| Set the Compilers (must be set first)
  12. include( CMakeForceCompiler )
  13. cmake_force_c_compiler ( arm-none-eabi-gcc ARMCCompiler )
  14. cmake_force_cxx_compiler( arm-none-eabi-g++ ARMCxxCompiler )
  15. set( _CMAKE_TOOLCHAIN_PREFIX arm-none-eabi- )
  16. ###
  17. # ARM Defines and Linker Options
  18. #
  19. #| Chip Name (Linker)
  20. #|
  21. #| "mk20dx128" # Teensy 3.0
  22. #| "mk20dx256" # Teensy 3.1
  23. message( STATUS "Chip Selected:" )
  24. message( "${CHIP}" )
  25. set( MCU "${CHIP}" ) # For loading script compatibility
  26. #| Chip Size Database
  27. #| Teensy 3.0
  28. if ( "${CHIP}" MATCHES "mk20dx128" )
  29. set( SIZE_RAM 16384 )
  30. set( SIZE_FLASH 131072 )
  31. #| Teensy 3.1
  32. elseif ( "${CHIP}" MATCHES "mk20dx256" )
  33. set( SIZE_RAM 65536 )
  34. set( SIZE_FLASH 262144 )
  35. #| Unknown ARM
  36. else ()
  37. message( AUTHOR_WARNING "CHIP: ${CHIP} - Unknown ARM microcontroller" )
  38. endif ()
  39. #| Chip Base Type
  40. #| Automatically chosed based on the chip name.
  41. if ( "${CHIP}" MATCHES "^mk20dx.*$" )
  42. set( CHIP_FAMILY "mk20dx" )
  43. message( STATUS "Chip Family:" )
  44. message( "${CHIP_FAMILY}" )
  45. else ()
  46. message( FATAL_ERROR "Unknown chip family: ${CHIP}" )
  47. endif ()
  48. #| CPU Type
  49. #| You _MUST_ set this to match the board you are using
  50. #| type "make clean" after changing this, so all files will be rebuilt
  51. #|
  52. #| "cortex-m4" # Teensy 3.0, 3.1
  53. set( CPU "cortex-m4" )
  54. message( STATUS "CPU Selected:" )
  55. message( "${CPU}" )
  56. #| Extra Compiler Sources
  57. #| Mostly for convenience functions like interrupt handlers
  58. set( COMPILER_SRCS
  59. Lib/${CHIP_FAMILY}.c
  60. Lib/delay.c
  61. )
  62. message( STATUS "Compiler Source Files:" )
  63. message( "${COMPILER_SRCS}" )
  64. #| USB Defines
  65. set( VENDOR_ID "0x16C0" )
  66. set( PRODUCT_ID "0x0487" )
  67. #| Compiler flag to set the C Standard level.
  68. #| c89 = "ANSI" C
  69. #| gnu89 = c89 plus GCC extensions
  70. #| c99 = ISO C99 standard (not yet fully implemented)
  71. #| gnu99 = c99 plus GCC extensions
  72. set( CSTANDARD "-std=gnu99" )
  73. #| Warning Options
  74. #| -Wall...: warning level
  75. set( WARN "-Wall -g" )
  76. #| Tuning Options
  77. #| -f...: tuning, see GCC manual
  78. #| NOTE: -fshort-wchar is specified to allow USB strings be passed conveniently
  79. set( TUNING "-mthumb -nostdlib -fdata-sections -ffunction-sections -fshort-wchar" )
  80. #| Optimization level, can be [0, 1, 2, 3, s].
  81. #| 0 = turn off optimization. s = optimize for size.
  82. #| (Note: 3 is not always the best optimization level.)
  83. set( OPT "s" )
  84. #| Output Format
  85. #| srec, ihex, binary
  86. set( FORMAT "ihex" )
  87. #| Processor frequency.
  88. #| Normally the first thing your program should do is set the clock prescaler,
  89. #| so your program will run at the correct speed. You should also set this
  90. #| variable to same clock speed. The _delay_ms() macro uses this, and many
  91. #| examples use this variable to calculate timings. Do not add a "UL" here.
  92. set( F_CPU "48000000" )
  93. #| Dependency Files
  94. #| Compiler flags to generate dependency files.
  95. set( GENDEPFLAGS "-MMD" )
  96. #| Compiler Flags
  97. add_definitions( "-mcpu=${CPU} -DF_CPU=${F_CPU} -D_${CHIP}_=1 -O${OPT} ${TUNING} ${WARN} ${CSTANDARD} ${GENDEPFLAGS}" )
  98. #| Linker Flags
  99. set( LINKER_FLAGS "-mcpu=${CPU} -Wl,-Map=${TARGET}.map,--cref -Wl,--gc-sections -mthumb -Wl,--no-wchar-size-warning -T${CMAKE_CURRENT_SOURCE_DIR}/Lib/${CHIP}.ld" )
  100. #| Hex Flags (XXX, CMake seems to have issues if you quote the arguments for the custom commands...)
  101. set( HEX_FLAGS -O ${FORMAT} -R .eeprom )
  102. #| Lss Flags
  103. set( LSS_FLAGS -h -S -z )