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 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 and McHCK mk20dx128
  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. #| MCHCK Based
  28. if ( "${CHIP}" MATCHES "mk20dx128vlf5" )
  29. set( SIZE_RAM 16384 )
  30. set( SIZE_FLASH 126976 )
  31. #| Teensy 3.0
  32. elseif ( "${CHIP}" MATCHES "mk20dx128" )
  33. set( SIZE_RAM 16384 )
  34. set( SIZE_FLASH 131072 )
  35. #| Teensy 3.1
  36. elseif ( "${CHIP}" MATCHES "mk20dx256" )
  37. set( SIZE_RAM 65536 )
  38. set( SIZE_FLASH 262144 )
  39. #| Unknown ARM
  40. else ()
  41. message( AUTHOR_WARNING "CHIP: ${CHIP} - Unknown ARM microcontroller" )
  42. endif ()
  43. #| Chip Base Type
  44. #| Automatically chosed based on the chip name.
  45. if ( "${CHIP}" MATCHES "^mk20dx.*$" )
  46. set( CHIP_FAMILY "mk20dx" )
  47. message( STATUS "Chip Family:" )
  48. message( "${CHIP_FAMILY}" )
  49. else ()
  50. message( FATAL_ERROR "Unknown chip family: ${CHIP}" )
  51. endif ()
  52. #| CPU Type
  53. #| You _MUST_ set this to match the board you are using
  54. #| type "make clean" after changing this, so all files will be rebuilt
  55. #|
  56. #| "cortex-m4" # Teensy 3.0, 3.1, McHCK
  57. set( CPU "cortex-m4" )
  58. message( STATUS "CPU Selected:" )
  59. message( "${CPU}" )
  60. #| Extra Compiler Sources
  61. #| Mostly for convenience functions like interrupt handlers
  62. set( COMPILER_SRCS
  63. Lib/${CHIP_FAMILY}.c
  64. Lib/delay.c
  65. )
  66. message( STATUS "Compiler Source Files:" )
  67. message( "${COMPILER_SRCS}" )
  68. #| USB Defines, this is how the loader programs detect which type of chip base is used
  69. if ( "${CHIP}" MATCHES "mk20dx128vlf5" )
  70. set( VENDOR_ID "0x1C11" )
  71. set( PRODUCT_ID "0xB04D" )
  72. set( BOOT_VENDOR_ID "0x1C11" )
  73. set( BOOT_PRODUCT_ID "0xB007" )
  74. set( DFU 1 )
  75. elseif ( "${CHIP}" MATCHES "mk20dx128" OR "${CHIP}" MATCHES "mk20dx256" )
  76. set( VENDOR_ID "0x1C11" )
  77. set( PRODUCT_ID "0xB04D" )
  78. set( BOOT_VENDOR_ID "0x16c0" ) # TODO Double check, this is likely incorrect
  79. set( BOOT_PRODUCT_ID "0x0487" )
  80. set( TEENSY 1 )
  81. endif ()
  82. #| Compiler flag to set the C Standard level.
  83. #| c89 = "ANSI" C
  84. #| gnu89 = c89 plus GCC extensions
  85. #| c99 = ISO C99 standard (not yet fully implemented)
  86. #| gnu99 = c99 plus GCC extensions
  87. #| gnu11 = c11 plus GCC extensions
  88. set( CSTANDARD "-std=gnu11" )
  89. #| Warning Options
  90. #| -Wall...: warning level
  91. set( WARN "-Wall -ggdb3" )
  92. #| Tuning Options
  93. #| -f...: tuning, see GCC manual
  94. #| NOTE: -fshort-wchar is specified to allow USB strings be passed conveniently
  95. if( BOOTLOADER )
  96. set( TUNING "-D_bootloader_ -Wno-main -msoft-float -mthumb -fplan9-extensions -ffunction-sections -fdata-sections -fno-builtin -fstrict-volatile-bitfields -flto -fno-use-linker-plugin" )
  97. #set( TUNING "-mthumb -fdata-sections -ffunction-sections -fno-builtin -msoft-float -fstrict-volatile-bitfields -flto -fno-use-linker-plugin -fwhole-program -Wno-main -nostartfiles -fplan9-extensions -D_bootloader_" )
  98. else()
  99. set( TUNING "-mthumb -nostdlib -fdata-sections -ffunction-sections -fshort-wchar -fno-builtin -nostartfiles" )
  100. endif()
  101. #| Optimization level, can be [0, 1, 2, 3, s].
  102. #| 0 = turn off optimization. s = optimize for size.
  103. #| (Note: 3 is not always the best optimization level.)
  104. set( OPT "s" )
  105. #| Processor frequency.
  106. #| Normally the first thing your program should do is set the clock prescaler,
  107. #| so your program will run at the correct speed. You should also set this
  108. #| variable to same clock speed. The _delay_ms() macro uses this, and many
  109. #| examples use this variable to calculate timings. Do not add a "UL" here.
  110. set( F_CPU "48000000" )
  111. #| Dependency Files
  112. #| Compiler flags to generate dependency files.
  113. set( GENDEPFLAGS "-MMD" )
  114. #| Compiler Flags
  115. add_definitions( "-mcpu=${CPU} -DF_CPU=${F_CPU} -D_${CHIP}_=1 -O${OPT} ${TUNING} ${WARN} ${CSTANDARD} ${GENDEPFLAGS}" )
  116. #| Linker Flags
  117. if( BOOTLOADER )
  118. # Bootloader linker flags
  119. set( LINKER_FLAGS "${TUNING} -Wl,--gc-sections -fwhole-program -T${CMAKE_CURRENT_SOURCE_DIR}/../Lib/${CHIP}.bootloader.ld -nostartfiles -Wl,-Map=link.map" )
  120. #set( LINKER_FLAGS "-Wl,-Map=link.map,--cref -Wl,--gc-sections -Wl,--no-wchar-size-warning -T${CMAKE_CURRENT_SOURCE_DIR}/../Lib/${CHIP}.bootloader.ld" )
  121. else()
  122. # Normal linker flags
  123. set( LINKER_FLAGS "-Wl,-Map=link.map,--cref -Wl,--gc-sections -Wl,--no-wchar-size-warning -T${CMAKE_CURRENT_SOURCE_DIR}/Lib/${CHIP}.ld" )
  124. endif()
  125. #| Hex Flags (XXX, CMake seems to have issues if you quote the arguments for the custom commands...)
  126. set( HEX_FLAGS -O ihex -R .eeprom )
  127. #| Binary Flags
  128. set( BIN_FLAGS -O binary )
  129. #| Lss Flags
  130. set( LSS_FLAGS -h -S -z )