]> git.donarmstrong.com Git - kiibohd-controller.git/blob - arm.cmake
Adding teensy-loader-cli so it's not required.
[kiibohd-controller.git] / arm.cmake
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
12
13
14 #| Set the Compilers (must be set first)
15 include( CMakeForceCompiler )
16 cmake_force_c_compiler  ( arm-none-eabi-gcc AVRCCompiler )
17 cmake_force_cxx_compiler( arm-none-eabi-g++ AVRCxxCompiler )
18
19
20 #| Compiler Binaries
21 set( OBJCOPY "arm-none-eabi-objcopy" )
22 set( OBJDUMP "arm-none-eabi-objdump" )
23 set( NM      "arm-none-eabi-nm"      )
24 set( SIZE    "arm-none-eabi-size"    )
25
26
27
28 ###
29 # ARM Defines and Linker Options
30 #
31
32 #| Chip Name (Linker)
33 #| You _MUST_ set this to match the board you are using
34 #| type "make clean" after changing this, so all files will be rebuilt
35 #|
36 #| "mk20dx128"        # Teensy   3.0
37 #| "mk20dx256"        # Teensy   3.1
38 #set( CHIP "mk20dx128" )
39 set( CHIP "mk20dx256" )
40
41 message( STATUS "Chip Selected:" )
42 message( "${CHIP}" )
43 set( MCU "${CHIP}" ) # For loading script compatibility
44
45
46 #| Chip Base Type
47 #| Automatically chosed based on the chip name.
48 if ( "${CHIP}" MATCHES "^mk20dx.*$" )
49         set( CHIP_FAMILY "mk20dx" )
50         message( STATUS "Chip Family:" )
51         message( "${CHIP_FAMILY}" )
52 else ()
53         message( FATAL_ERROR "Unknown chip family: ${CHIP}" )
54 endif ()
55
56
57 #| CPU Type
58 #| You _MUST_ set this to match the board you are using
59 #| type "make clean" after changing this, so all files will be rebuilt
60 #|
61 #| "cortex-m4"        # Teensy   3.0, 3.1
62 set( CPU "cortex-m4" )
63
64 message( STATUS "CPU Selected:" )
65 message( "${CPU}" )
66
67
68 #| Extra Compiler Sources
69 #| Mostly for convenience functions like interrupt handlers
70 set( COMPILER_SRCS
71         Lib/${CHIP_FAMILY}.c
72         Lib/delay.c
73 )
74
75 message( STATUS "Compiler Source Files:" )
76 message( "${COMPILER_SRCS}" )
77
78
79 #| USB Defines
80 set( VENDOR_ID  "0x16C0" )
81 set( PRODUCT_ID "0x0487" )
82
83
84 #| Compiler flag to set the C Standard level.
85 #|     c89   = "ANSI" C
86 #|     gnu89 = c89 plus GCC extensions
87 #|     c99   = ISO C99 standard (not yet fully implemented)
88 #|     gnu99 = c99 plus GCC extensions
89 set( CSTANDARD "-std=gnu99" )
90
91
92 #| Warning Options
93 #|  -Wall...:     warning level
94 set( WARN "-Wall -g" )
95
96
97 #| Tuning Options
98 #|  -f...:        tuning, see GCC manual
99 #| NOTE: -fshort-wchar is specified to allow USB strings be passed conveniently
100 set( TUNING "-mthumb -nostdlib -fdata-sections -ffunction-sections -fshort-wchar" )
101
102
103 #| Optimization level, can be [0, 1, 2, 3, s].
104 #|     0 = turn off optimization. s = optimize for size.
105 #|     (Note: 3 is not always the best optimization level.)
106 set( OPT "s" )
107
108
109 #| Output Format
110 #| srec, ihex, binary
111 set( FORMAT "ihex" )
112
113
114 #| Processor frequency.
115 #|   Normally the first thing your program should do is set the clock prescaler,
116 #|   so your program will run at the correct speed.  You should also set this
117 #|   variable to same clock speed.  The _delay_ms() macro uses this, and many
118 #|   examples use this variable to calculate timings.  Do not add a "UL" here.
119 set( F_CPU "48000000" )
120
121
122 #| Dependency Files
123 #| Compiler flags to generate dependency files.
124 set( GENDEPFLAGS "-MMD" )
125
126
127 #| Compiler Flags
128 add_definitions( "-mcpu=${CPU} -DF_CPU=${F_CPU} -D_${CHIP}_=1 -O${OPT} ${TUNING} ${WARN} ${CSTANDARD} ${GENDEPFLAGS}" )
129
130
131 #| Linker Flags
132 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" )
133
134
135 #| Hex Flags (XXX, CMake seems to have issues if you quote the arguments for the custom commands...)
136 set( HEX_FLAGS -O ${FORMAT} -R .eeprom )
137
138
139 #| Lss Flags
140 set( LSS_FLAGS -h -S -z )
141