]> git.donarmstrong.com Git - kiibohd-controller.git/blob - arm.cmake
Fixing loading script for ARM targets and the teensy loader cli
[kiibohd-controller.git] / arm.cmake
1 ###| CMAKE Kiibohd Controller |###
2 #
3 # Jacob Alexander 2011-2013
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 set( CHIP "mk20dx128" )
38
39 message( STATUS "Chip Selected:" )
40 message( "${CHIP}" )
41 set( MCU "${CHIP}" ) # For loading script compatibility
42
43
44 #| CPU Type
45 #| You _MUST_ set this to match the board you are using
46 #| type "make clean" after changing this, so all files will be rebuilt
47 #|
48 #| "cortex-m4"        # Teensy   3.0
49 set( CPU "cortex-m4" )
50
51 message( STATUS "CPU Selected:" )
52 message( "${CPU}" )
53
54
55 #| Extra Compiler Sources
56 #| Mostly for convenience functions like interrupt handlers
57 set( COMPILER_SRCS
58         Lib/${CHIP}.c
59         Lib/delay.c
60 )
61
62 message( STATUS "Compiler Source Files:" )
63 message( "${COMPILER_SRCS}" )
64
65
66 #| USB Defines
67 set( VENDOR_ID  "0x16C0" )
68 set( PRODUCT_ID "0x0487" )
69
70
71 #| Compiler flag to set the C Standard level.
72 #|     c89   = "ANSI" C
73 #|     gnu89 = c89 plus GCC extensions
74 #|     c99   = ISO C99 standard (not yet fully implemented)
75 #|     gnu99 = c99 plus GCC extensions
76 set( CSTANDARD "-std=gnu99" )
77
78
79 #| Warning Options
80 #|  -Wall...:     warning level
81 set( WARN "-Wall -g" )
82
83
84 #| Tuning Options
85 #|  -f...:        tuning, see GCC manual
86 #| NOTE: -fshort-wchar is specified to allow USB strings be passed conveniently
87 set( TUNING "-mthumb -nostdlib -fdata-sections -ffunction-sections -fshort-wchar" )
88
89
90 #| Optimization level, can be [0, 1, 2, 3, s]. 
91 #|     0 = turn off optimization. s = optimize for size.
92 #|     (Note: 3 is not always the best optimization level.)
93 set( OPT "s" )
94
95
96 #| Output Format
97 #| srec, ihex, binary
98 set( FORMAT "ihex" )
99
100
101 #| Processor frequency.
102 #|   Normally the first thing your program should do is set the clock prescaler,
103 #|   so your program will run at the correct speed.  You should also set this
104 #|   variable to same clock speed.  The _delay_ms() macro uses this, and many
105 #|   examples use this variable to calculate timings.  Do not add a "UL" here.
106 set( F_CPU "48000000" )
107
108
109 #| Dependency Files
110 #| Compiler flags to generate dependency files.
111 set( GENDEPFLAGS "-MMD" )
112
113
114 #| Compiler Flags
115 add_definitions( "-mcpu=${CPU} -DF_CPU=${F_CPU} -D_${CHIP}_=1 -O${OPT} ${TUNING} ${WARN} ${CSTANDARD} ${GENDEPFLAGS}" )
116
117
118 #| Linker Flags
119 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" )
120
121
122 #| Hex Flags (XXX, CMake seems to have issues if you quote the arguments for the custom commands...)
123 set( HEX_FLAGS -O ${FORMAT} -R .eeprom )
124
125
126 #| Lss Flags
127 set( LSS_FLAGS -h -S -z )
128