Rev 909 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 909 | Rev 916 | ||
---|---|---|---|
1 | #-------------------------------------------------------------------- |
1 | #-------------------------------------------------------------------- |
2 | # MCU name |
2 | # MCU name |
3 | #MCU = atmega644 |
3 | #MCU = atmega644 |
4 | MCU = atmega644p |
4 | MCU = atmega644p |
5 | F_CPU = 20000000 |
5 | F_CPU = 20000000 |
6 | # |
6 | # |
7 | #------------------------------------------------------------------- |
7 | #------------------------------------------------------------------- |
8 | # comment out for Quadro, uncomment for Hexakopter |
8 | # comment out for Quadro, uncomment for Hexakopter |
9 | HEXAKOPTER = _HEXA |
9 | HEXAKOPTER = _HEXA |
10 | #------------------------------------------------------------------- |
10 | #------------------------------------------------------------------- |
11 | 11 | ||
12 | VERSION_MAJOR = 0 |
12 | VERSION_MAJOR = 0 |
13 | VERSION_MINOR = 69 |
13 | VERSION_MINOR = 69 |
14 | VERSION_INDEX = 10 |
14 | VERSION_INDEX = 10 |
15 | 15 | ||
16 | VERSION_COMPATIBLE = 7 # PC-Kompatibilität |
16 | VERSION_COMPATIBLE = 7 # PC-Kompatibilität |
17 | #------------------------------------------------------------------- |
17 | #------------------------------------------------------------------- |
18 | #OPTIONS |
18 | #OPTIONS |
19 | # Use one of the extensions for a gps solution |
19 | # Use one of the extensions for a gps solution |
20 | #EXT = KILLAGREG |
20 | #EXT = KILLAGREG |
21 | #EXT = NAVICTRL |
21 | #EXT = NAVICTRL |
22 | EXT = MK3MAG |
22 | EXT = MK3MAG |
- | 23 | ||
23 | #------------------------------------------------------------------- |
24 | #------------------------------------------------------------------- |
24 | 25 | ||
25 | ifeq ($(MCU), atmega644) |
26 | ifeq ($(MCU), atmega644) |
26 | FUSE_SETTINGS = -u -U lfuse:w:0xff:m -U hfuse:w:0xdf:m |
27 | FUSE_SETTINGS = -u -U lfuse:w:0xff:m -U hfuse:w:0xdf:m |
27 | #FUSE_SETTINGS = -U lfuse:w:0xff:m -U hfuse:w:0xdf:m |
28 | #FUSE_SETTINGS = -U lfuse:w:0xff:m -U hfuse:w:0xdf:m |
28 | # -u bei neuen Controllern wieder einspielen |
29 | # -u bei neuen Controllern wieder einspielen |
29 | HEX_NAME = MEGA644$(HEXAKOPTER)_$(EXT) |
30 | HEX_NAME = MEGA644$(HEXAKOPTER)_$(EXT) |
30 | endif |
31 | endif |
31 | 32 | ||
32 | ifeq ($(MCU), atmega644p) |
33 | ifeq ($(MCU), atmega644p) |
33 | FUSE_SETTINGS = -u -U lfuse:w:0xff:m -U hfuse:w:0xdf:m |
34 | FUSE_SETTINGS = -u -U lfuse:w:0xff:m -U hfuse:w:0xdf:m |
34 | HEX_NAME = MEGA644p$(HEXAKOPTER)_$(EXT) |
35 | HEX_NAME = MEGA644p$(HEXAKOPTER)_$(EXT) |
35 | endif |
36 | endif |
36 | 37 | ||
37 | 38 | ||
38 | ifeq ($(F_CPU), 16000000) |
39 | ifeq ($(F_CPU), 16000000) |
39 | QUARZ = 16MHZ |
40 | QUARZ = 16MHZ |
40 | endif |
41 | endif |
41 | 42 | ||
42 | ifeq ($(F_CPU), 20000000) |
43 | ifeq ($(F_CPU), 20000000) |
43 | QUARZ = 20MHZ |
44 | QUARZ = 20MHZ |
44 | endif |
45 | endif |
45 | 46 | ||
46 | 47 | ||
47 | # Output format. (can be srec, ihex, binary) |
48 | # Output format. (can be srec, ihex, binary) |
48 | FORMAT = ihex |
49 | FORMAT = ihex |
49 | 50 | ||
50 | # Target file name (without extension). |
51 | # Target file name (without extension). |
51 | 52 | ||
52 | ifeq ($(VERSION_INDEX), 0) |
53 | ifeq ($(VERSION_INDEX), 0) |
53 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)a |
54 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)a |
54 | endif |
55 | endif |
55 | ifeq ($(VERSION_INDEX), 1) |
56 | ifeq ($(VERSION_INDEX), 1) |
56 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)b |
57 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)b |
57 | endif |
58 | endif |
58 | ifeq ($(VERSION_INDEX), 2) |
59 | ifeq ($(VERSION_INDEX), 2) |
59 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)c |
60 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)c |
60 | endif |
61 | endif |
61 | ifeq ($(VERSION_INDEX), 3) |
62 | ifeq ($(VERSION_INDEX), 3) |
62 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)d |
63 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)d |
63 | endif |
64 | endif |
64 | ifeq ($(VERSION_INDEX), 4) |
65 | ifeq ($(VERSION_INDEX), 4) |
65 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)e |
66 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)e |
66 | endif |
67 | endif |
67 | ifeq ($(VERSION_INDEX), 5) |
68 | ifeq ($(VERSION_INDEX), 5) |
68 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)f |
69 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)f |
69 | endif |
70 | endif |
70 | ifeq ($(VERSION_INDEX), 6) |
71 | ifeq ($(VERSION_INDEX), 6) |
71 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)g |
72 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)g |
72 | endif |
73 | endif |
73 | ifeq ($(VERSION_INDEX), 7) |
74 | ifeq ($(VERSION_INDEX), 7) |
74 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)h |
75 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)h |
75 | endif |
76 | endif |
76 | ifeq ($(VERSION_INDEX), 8) |
77 | ifeq ($(VERSION_INDEX), 8) |
77 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)i |
78 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)i |
78 | endif |
79 | endif |
79 | ifeq ($(VERSION_INDEX), 9) |
80 | ifeq ($(VERSION_INDEX), 9) |
80 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)j |
81 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)j |
81 | endif |
82 | endif |
82 | ifeq ($(VERSION_INDEX), 10) |
83 | ifeq ($(VERSION_INDEX), 10) |
83 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)k |
84 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)k |
84 | endif |
85 | endif |
85 | 86 | ||
86 | 87 | ||
87 | # Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization. |
88 | # Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization. |
88 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
89 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
89 | OPT = s |
90 | OPT = s |
90 | 91 | ||
91 | ########################################################################################################## |
92 | ########################################################################################################## |
92 | # List C source files here. (C dependencies are automatically generated.) |
93 | # List C source files here. (C dependencies are automatically generated.) |
93 | SRC = main.c uart.c printf_P.c timer0.c timer2.c analog.c menu.c led.c |
94 | SRC = main.c uart.c printf_P.c timer0.c timer2.c analog.c menu.c led.c |
94 | SRC += twimaster.c rc.c fc.c eeprom.c fifo.c |
95 | SRC += twimaster.c rc.c fc.c eeprom.c fifo.c |
95 | ifeq ($(MCU), atmega644p) |
96 | ifeq ($(MCU), atmega644p) |
96 | SRC += uart1.c |
97 | SRC += uart1.c |
97 | endif |
98 | endif |
98 | ifeq ($(EXT), KILLAGREG) |
99 | ifeq ($(EXT), KILLAGREG) |
99 | SRC += mm3.c mymath.c gps.c ubx.c |
100 | SRC += mm3.c mymath.c gps.c ubx.c |
100 | endif |
101 | endif |
101 | ifeq ($(EXT), MK3MAG) |
102 | ifeq ($(EXT), MK3MAG) |
102 | SRC += mk3mag.c mymath.c gps.c ubx.c |
103 | SRC += mk3mag.c mymath.c gps.c ubx.c |
103 | endif |
104 | endif |
104 | ifeq ($(EXT), NAVICTRL) |
105 | ifeq ($(EXT), NAVICTRL) |
105 | SRC += spi.c |
106 | SRC += spi.c |
106 | endif |
107 | endif |
107 | ########################################################################################################## |
108 | ########################################################################################################## |
108 | 109 | ||
109 | 110 | ||
110 | # List Assembler source files here. |
111 | # List Assembler source files here. |
111 | # Make them always end in a capital .S. Files ending in a lowercase .s |
112 | # Make them always end in a capital .S. Files ending in a lowercase .s |
112 | # will not be considered source files but generated files (assembler |
113 | # will not be considered source files but generated files (assembler |
113 | # output from the compiler), and will be deleted upon "make clean"! |
114 | # output from the compiler), and will be deleted upon "make clean"! |
114 | # Even though the DOS/Win* filesystem matches both .s and .S the same, |
115 | # Even though the DOS/Win* filesystem matches both .s and .S the same, |
115 | # it will preserve the spelling of the filenames, and gcc itself does |
116 | # it will preserve the spelling of the filenames, and gcc itself does |
116 | # care about how the name is spelled on its command-line. |
117 | # care about how the name is spelled on its command-line. |
117 | ASRC = |
118 | ASRC = |
118 | 119 | ||
119 | 120 | ||
120 | 121 | ||
121 | # List any extra directories to look for include files here. |
122 | # List any extra directories to look for include files here. |
122 | # Each directory must be seperated by a space. |
123 | # Each directory must be seperated by a space. |
123 | EXTRAINCDIRS = |
124 | EXTRAINCDIRS = |
124 | 125 | ||
125 | 126 | ||
126 | # Optional compiler flags. |
127 | # Optional compiler flags. |
127 | # -g: generate debugging information (for GDB, or for COFF conversion) |
128 | # -g: generate debugging information (for GDB, or for COFF conversion) |
128 | # -O*: optimization level |
129 | # -O*: optimization level |
129 | # -f...: tuning, see gcc manual and avr-libc documentation |
130 | # -f...: tuning, see gcc manual and avr-libc documentation |
130 | # -Wall...: warning level |
131 | # -Wall...: warning level |
131 | # -Wa,...: tell GCC to pass this to the assembler. |
132 | # -Wa,...: tell GCC to pass this to the assembler. |
132 | # -ahlms: create assembler listing |
133 | # -ahlms: create assembler listing |
133 | CFLAGS = -O$(OPT) \ |
134 | CFLAGS = -O$(OPT) \ |
134 | -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \ |
135 | -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \ |
135 | -Wall -Wstrict-prototypes \ |
136 | -Wall -Wstrict-prototypes \ |
136 | -Wa,-adhlns=$(<:.c=.lst) \ |
137 | -Wa,-adhlns=$(<:.c=.lst) \ |
137 | $(patsubst %,-I%,$(EXTRAINCDIRS)) |
138 | $(patsubst %,-I%,$(EXTRAINCDIRS)) |
138 | 139 | ||
139 | 140 | ||
140 | # Set a "language standard" compiler flag. |
141 | # Set a "language standard" compiler flag. |
141 | # Unremark just one line below to set the language standard to use. |
142 | # Unremark just one line below to set the language standard to use. |
142 | # gnu99 = C99 + GNU extensions. See GCC manual for more information. |
143 | # gnu99 = C99 + GNU extensions. See GCC manual for more information. |
143 | #CFLAGS += -std=c89 |
144 | #CFLAGS += -std=c89 |
144 | #CFLAGS += -std=gnu89 |
145 | #CFLAGS += -std=gnu89 |
145 | #CFLAGS += -std=c99 |
146 | #CFLAGS += -std=c99 |
146 | CFLAGS += -std=gnu99 |
147 | CFLAGS += -std=gnu99 |
147 | 148 | ||
148 | CFLAGS += -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_COMPATIBLE=$(VERSION_COMPATIBLE) -DVERSION_INDEX=$(VERSION_INDEX) |
149 | CFLAGS += -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_COMPATIBLE=$(VERSION_COMPATIBLE) -DVERSION_INDEX=$(VERSION_INDEX) |
149 | 150 | ||
150 | ifeq ($(EXT), KILLAGREG) |
151 | ifeq ($(EXT), KILLAGREG) |
151 | CFLAGS += -DUSE_KILLAGREG |
152 | CFLAGS += -DUSE_KILLAGREG |
152 | endif |
153 | endif |
153 | ifeq ($(EXT), MK3MAG) |
154 | ifeq ($(EXT), MK3MAG) |
154 | CFLAGS += -DUSE_MK3MAG |
155 | CFLAGS += -DUSE_MK3MAG |
155 | endif |
156 | endif |
156 | ifeq ($(EXT), NAVICTRL) |
157 | ifeq ($(EXT), NAVICTRL) |
157 | CFLAGS += -DUSE_NAVICTRL |
158 | CFLAGS += -DUSE_NAVICTRL |
158 | endif |
159 | endif |
159 | 160 | ||
160 | ifeq ($(HEXAKOPTER), _HEXA) |
161 | ifeq ($(HEXAKOPTER), _HEXA) |
161 | CFLAGS += -DHEXAKOPTER |
162 | CFLAGS += -DHEXAKOPTER |
162 | endif |
163 | endif |
163 | 164 | ||
164 | 165 | ||
165 | # Optional assembler flags. |
166 | # Optional assembler flags. |
166 | # -Wa,...: tell GCC to pass this to the assembler. |
167 | # -Wa,...: tell GCC to pass this to the assembler. |
167 | # -ahlms: create listing |
168 | # -ahlms: create listing |
168 | # -gstabs: have the assembler create line number information; note that |
169 | # -gstabs: have the assembler create line number information; note that |
169 | # for use in COFF files, additional information about filenames |
170 | # for use in COFF files, additional information about filenames |
170 | # and function names needs to be present in the assembler source |
171 | # and function names needs to be present in the assembler source |
171 | # files -- see avr-libc docs [FIXME: not yet described there] |
172 | # files -- see avr-libc docs [FIXME: not yet described there] |
172 | ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs |
173 | ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs |
173 | 174 | ||
174 | 175 | ||
175 | 176 | ||
176 | # Optional linker flags. |
177 | # Optional linker flags. |
177 | # -Wl,...: tell GCC to pass this to linker. |
178 | # -Wl,...: tell GCC to pass this to linker. |
178 | # -Map: create map file |
179 | # -Map: create map file |
179 | # --cref: add cross reference to map file |
180 | # --cref: add cross reference to map file |
180 | LDFLAGS = -Wl,-Map=$(TARGET).map,--cref |
181 | LDFLAGS = -Wl,-Map=$(TARGET).map,--cref |
181 | 182 | ||
182 | # Additional libraries |
183 | # Additional libraries |
183 | 184 | ||
184 | # Minimalistic printf version |
185 | # Minimalistic printf version |
185 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_min |
186 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_min |
186 | 187 | ||
187 | # Floating point printf version (requires -lm below) |
188 | # Floating point printf version (requires -lm below) |
188 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt |
189 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt |
189 | 190 | ||
190 | # -lm = math library |
191 | # -lm = math library |
191 | LDFLAGS += -lm |
192 | LDFLAGS += -lm |
192 | 193 | ||
193 | 194 | ||
194 | ##LDFLAGS += -T./linkerfile/avr5.x |
195 | ##LDFLAGS += -T./linkerfile/avr5.x |
195 | 196 | ||
196 | 197 | ||
197 | 198 | ||
198 | # Programming support using avrdude. Settings and variables. |
199 | # Programming support using avrdude. Settings and variables. |
199 | 200 | ||
200 | # Programming hardware: alf avr910 avrisp bascom bsd |
201 | # Programming hardware: alf avr910 avrisp bascom bsd |
201 | # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 |
202 | # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 |
202 | # |
203 | # |
203 | # Type: avrdude -c ? |
204 | # Type: avrdude -c ? |
204 | # to get a full listing. |
205 | # to get a full listing. |
205 | # |
206 | # |
206 | #AVRDUDE_PROGRAMMER = dt006 |
207 | #AVRDUDE_PROGRAMMER = dt006 |
207 | #AVRDUDE_PROGRAMMER = stk200 |
208 | #AVRDUDE_PROGRAMMER = stk200 |
208 | #AVRDUDE_PROGRAMMER = ponyser |
209 | #AVRDUDE_PROGRAMMER = ponyser |
209 | AVRDUDE_PROGRAMMER = avrispv2 |
210 | AVRDUDE_PROGRAMMER = avrispv2 |
210 | #falls Ponyser ausgewählt wird, muss sich unsere avrdude-Configdatei im Bin-Verzeichnis des Compilers befinden |
211 | #falls Ponyser ausgewählt wird, muss sich unsere avrdude-Configdatei im Bin-Verzeichnis des Compilers befinden |
211 | 212 | ||
212 | #AVRDUDE_PORT = com1 # programmer connected to serial device |
213 | #AVRDUDE_PORT = com1 # programmer connected to serial device |
213 | #AVRDUDE_PORT = lpt1 # programmer connected to parallel port |
214 | #AVRDUDE_PORT = lpt1 # programmer connected to parallel port |
214 | AVRDUDE_PORT = usb # programmer connected to USB |
215 | AVRDUDE_PORT = usb # programmer connected to USB |
215 | 216 | ||
216 | #AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex |
217 | #AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex |
217 | AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex $(FUSE_SETTINGS) |
218 | AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex $(FUSE_SETTINGS) |
218 | #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep |
219 | #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep |
219 | 220 | ||
220 | #avrdude -c avrispv2 -P usb -p m32 -U flash:w:blink.hex |
221 | #avrdude -c avrispv2 -P usb -p m32 -U flash:w:blink.hex |
221 | AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) |
222 | AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) |
222 | 223 | ||
223 | # Uncomment the following if you want avrdude's erase cycle counter. |
224 | # Uncomment the following if you want avrdude's erase cycle counter. |
224 | # Note that this counter needs to be initialized first using -Yn, |
225 | # Note that this counter needs to be initialized first using -Yn, |
225 | # see avrdude manual. |
226 | # see avrdude manual. |
226 | #AVRDUDE_ERASE += -y |
227 | #AVRDUDE_ERASE += -y |
227 | 228 | ||
228 | # Uncomment the following if you do /not/ wish a verification to be |
229 | # Uncomment the following if you do /not/ wish a verification to be |
229 | # performed after programming the device. |
230 | # performed after programming the device. |
230 | AVRDUDE_FLAGS += -V |
231 | AVRDUDE_FLAGS += -V |
231 | 232 | ||
232 | # Increase verbosity level. Please use this when submitting bug |
233 | # Increase verbosity level. Please use this when submitting bug |
233 | # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> |
234 | # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> |
234 | # to submit bug reports. |
235 | # to submit bug reports. |
235 | #AVRDUDE_FLAGS += -v -v |
236 | #AVRDUDE_FLAGS += -v -v |
236 | 237 | ||
237 | # --------------------------------------------------------------------------- |
238 | # --------------------------------------------------------------------------- |
238 | # Define directories, if needed. |
239 | # Define directories, if needed. |
239 | DIRAVR = c:/winavr |
240 | DIRAVR = c:/winavr |
240 | DIRAVRBIN = $(DIRAVR)/bin |
241 | DIRAVRBIN = $(DIRAVR)/bin |
241 | DIRAVRUTILS = $(DIRAVR)/utils/bin |
242 | DIRAVRUTILS = $(DIRAVR)/utils/bin |
242 | DIRINC = . |
243 | DIRINC = . |
243 | DIRLIB = $(DIRAVR)/avr/lib |
244 | DIRLIB = $(DIRAVR)/avr/lib |
244 | 245 | ||
245 | 246 | ||
246 | # Define programs and commands. |
247 | # Define programs and commands. |
247 | SHELL = sh |
248 | SHELL = sh |
248 | 249 | ||
249 | CC = avr-gcc |
250 | CC = avr-gcc |
250 | 251 | ||
251 | OBJCOPY = avr-objcopy |
252 | OBJCOPY = avr-objcopy |
252 | OBJDUMP = avr-objdump |
253 | OBJDUMP = avr-objdump |
253 | SIZE = avr-size |
254 | SIZE = avr-size |
254 | 255 | ||
255 | # Programming support using avrdude. |
256 | # Programming support using avrdude. |
256 | AVRDUDE = avrdude |
257 | AVRDUDE = avrdude |
257 | 258 | ||
258 | REMOVE = rm -f |
259 | REMOVE = rm -f |
259 | COPY = cp |
260 | COPY = cp |
260 | 261 | ||
261 | HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex |
262 | HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex |
262 | ELFSIZE = $(SIZE) -A $(TARGET).elf |
263 | ELFSIZE = $(SIZE) -A $(TARGET).elf |
263 | 264 | ||
264 | # Define Messages |
265 | # Define Messages |
265 | # English |
266 | # English |
266 | MSG_ERRORS_NONE = Errors: none |
267 | MSG_ERRORS_NONE = Errors: none |
267 | MSG_BEGIN = -------- begin -------- |
268 | MSG_BEGIN = -------- begin -------- |
268 | MSG_END = -------- end -------- |
269 | MSG_END = -------- end -------- |
269 | MSG_SIZE_BEFORE = Size before: |
270 | MSG_SIZE_BEFORE = Size before: |
270 | MSG_SIZE_AFTER = Size after: |
271 | MSG_SIZE_AFTER = Size after: |
271 | MSG_COFF = Converting to AVR COFF: |
272 | MSG_COFF = Converting to AVR COFF: |
272 | MSG_EXTENDED_COFF = Converting to AVR Extended COFF: |
273 | MSG_EXTENDED_COFF = Converting to AVR Extended COFF: |
273 | MSG_FLASH = Creating load file for Flash: |
274 | MSG_FLASH = Creating load file for Flash: |
274 | MSG_EEPROM = Creating load file for EEPROM: |
275 | MSG_EEPROM = Creating load file for EEPROM: |
275 | MSG_EXTENDED_LISTING = Creating Extended Listing: |
276 | MSG_EXTENDED_LISTING = Creating Extended Listing: |
276 | MSG_SYMBOL_TABLE = Creating Symbol Table: |
277 | MSG_SYMBOL_TABLE = Creating Symbol Table: |
277 | MSG_LINKING = Linking: |
278 | MSG_LINKING = Linking: |
278 | MSG_COMPILING = Compiling: |
279 | MSG_COMPILING = Compiling: |
279 | MSG_ASSEMBLING = Assembling: |
280 | MSG_ASSEMBLING = Assembling: |
280 | MSG_CLEANING = Cleaning project: |
281 | MSG_CLEANING = Cleaning project: |
281 | 282 | ||
282 | 283 | ||
283 | # Define all object files. |
284 | # Define all object files. |
284 | OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) |
285 | OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) |
285 | 286 | ||
286 | # Define all listing files. |
287 | # Define all listing files. |
287 | LST = $(ASRC:.S=.lst) $(SRC:.c=.lst) |
288 | LST = $(ASRC:.S=.lst) $(SRC:.c=.lst) |
288 | 289 | ||
289 | # Combine all necessary flags and optional flags. |
290 | # Combine all necessary flags and optional flags. |
290 | # Add target processor to flags. |
291 | # Add target processor to flags. |
291 | #ALL_CFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -I. $(CFLAGS) |
292 | #ALL_CFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -I. $(CFLAGS) |
292 | ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) |
293 | ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) |
293 | ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) |
294 | ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) |
294 | 295 | ||
295 | 296 | ||
296 | # Default target. |
297 | # Default target. |
297 | all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \ |
298 | all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \ |
298 | $(TARGET).lss $(TARGET).sym sizeafter finished end |
299 | $(TARGET).lss $(TARGET).sym sizeafter finished end |
299 | 300 | ||
300 | 301 | ||
301 | # Eye candy. |
302 | # Eye candy. |
302 | # AVR Studio 3.x does not check make's exit code but relies on |
303 | # AVR Studio 3.x does not check make's exit code but relies on |
303 | # the following magic strings to be generated by the compile job. |
304 | # the following magic strings to be generated by the compile job. |
304 | begin: |
305 | begin: |
305 | @echo |
306 | @echo |
306 | @echo $(MSG_BEGIN) |
307 | @echo $(MSG_BEGIN) |
307 | 308 | ||
308 | finished: |
309 | finished: |
309 | @echo $(MSG_ERRORS_NONE) |
310 | @echo $(MSG_ERRORS_NONE) |
310 | 311 | ||
311 | end: |
312 | end: |
312 | @echo $(MSG_END) |
313 | @echo $(MSG_END) |
313 | @echo |
314 | @echo |
314 | 315 | ||
315 | 316 | ||
316 | # Display size of file. |
317 | # Display size of file. |
317 | sizebefore: |
318 | sizebefore: |
318 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi |
319 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi |
319 | 320 | ||
320 | sizeafter: |
321 | sizeafter: |
321 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi |
322 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi |
322 | 323 | ||
323 | 324 | ||
324 | 325 | ||
325 | # Display compiler version information. |
326 | # Display compiler version information. |
326 | gccversion : |
327 | gccversion : |
327 | @$(CC) --version |
328 | @$(CC) --version |
328 | 329 | ||
329 | 330 | ||
330 | # Convert ELF to COFF for use in debugging / simulating in |
331 | # Convert ELF to COFF for use in debugging / simulating in |
331 | # AVR Studio or VMLAB. |
332 | # AVR Studio or VMLAB. |
332 | COFFCONVERT=$(OBJCOPY) --debugging \ |
333 | COFFCONVERT=$(OBJCOPY) --debugging \ |
333 | --change-section-address .data-0x800000 \ |
334 | --change-section-address .data-0x800000 \ |
334 | --change-section-address .bss-0x800000 \ |
335 | --change-section-address .bss-0x800000 \ |
335 | --change-section-address .noinit-0x800000 \ |
336 | --change-section-address .noinit-0x800000 \ |
336 | --change-section-address .eeprom-0x810000 |
337 | --change-section-address .eeprom-0x810000 |
337 | 338 | ||
338 | 339 | ||
339 | coff: $(TARGET).elf |
340 | coff: $(TARGET).elf |
340 | @echo |
341 | @echo |
341 | @echo $(MSG_COFF) $(TARGET).cof |
342 | @echo $(MSG_COFF) $(TARGET).cof |
342 | $(COFFCONVERT) -O coff-avr $< $(TARGET).cof |
343 | $(COFFCONVERT) -O coff-avr $< $(TARGET).cof |
343 | 344 | ||
344 | 345 | ||
345 | extcoff: $(TARGET).elf |
346 | extcoff: $(TARGET).elf |
346 | @echo |
347 | @echo |
347 | @echo $(MSG_EXTENDED_COFF) $(TARGET).cof |
348 | @echo $(MSG_EXTENDED_COFF) $(TARGET).cof |
348 | $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof |
349 | $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof |
349 | 350 | ||
350 | 351 | ||
351 | 352 | ||
352 | 353 | ||
353 | # Program the device. |
354 | # Program the device. |
354 | program: $(TARGET).hex $(TARGET).eep |
355 | program: $(TARGET).hex $(TARGET).eep |
355 | $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) |
356 | $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) |
356 | 357 | ||
357 | 358 | ||
358 | 359 | ||
359 | 360 | ||
360 | # Create final output files (.hex, .eep) from ELF output file. |
361 | # Create final output files (.hex, .eep) from ELF output file. |
361 | %.hex: %.elf |
362 | %.hex: %.elf |
362 | @echo |
363 | @echo |
363 | @echo $(MSG_FLASH) $@ |
364 | @echo $(MSG_FLASH) $@ |
364 | $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ |
365 | $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ |
365 | 366 | ||
366 | %.eep: %.elf |
367 | %.eep: %.elf |
367 | @echo |
368 | @echo |
368 | @echo $(MSG_EEPROM) $@ |
369 | @echo $(MSG_EEPROM) $@ |
369 | -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ |
370 | -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ |
370 | --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ |
371 | --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ |
371 | 372 | ||
372 | # Create extended listing file from ELF output file. |
373 | # Create extended listing file from ELF output file. |
373 | %.lss: %.elf |
374 | %.lss: %.elf |
374 | @echo |
375 | @echo |
375 | @echo $(MSG_EXTENDED_LISTING) $@ |
376 | @echo $(MSG_EXTENDED_LISTING) $@ |
376 | $(OBJDUMP) -h -S $< > $@ |
377 | $(OBJDUMP) -h -S $< > $@ |
377 | 378 | ||
378 | # Create a symbol table from ELF output file. |
379 | # Create a symbol table from ELF output file. |
379 | %.sym: %.elf |
380 | %.sym: %.elf |
380 | @echo |
381 | @echo |
381 | @echo $(MSG_SYMBOL_TABLE) $@ |
382 | @echo $(MSG_SYMBOL_TABLE) $@ |
382 | avr-nm -n $< > $@ |
383 | avr-nm -n $< > $@ |
383 | 384 | ||
384 | 385 | ||
385 | 386 | ||
386 | # Link: create ELF output file from object files. |
387 | # Link: create ELF output file from object files. |
387 | .SECONDARY : $(TARGET).elf |
388 | .SECONDARY : $(TARGET).elf |
388 | .PRECIOUS : $(OBJ) |
389 | .PRECIOUS : $(OBJ) |
389 | %.elf: $(OBJ) |
390 | %.elf: $(OBJ) |
390 | @echo |
391 | @echo |
391 | @echo $(MSG_LINKING) $@ |
392 | @echo $(MSG_LINKING) $@ |
392 | $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) |
393 | $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) |
393 | 394 | ||
394 | 395 | ||
395 | # Compile: create object files from C source files. |
396 | # Compile: create object files from C source files. |
396 | %.o : %.c |
397 | %.o : %.c |
397 | @echo |
398 | @echo |
398 | @echo $(MSG_COMPILING) $< |
399 | @echo $(MSG_COMPILING) $< |
399 | $(CC) -c $(ALL_CFLAGS) $< -o $@ |
400 | $(CC) -c $(ALL_CFLAGS) $< -o $@ |
400 | 401 | ||
401 | 402 | ||
402 | # Compile: create assembler files from C source files. |
403 | # Compile: create assembler files from C source files. |
403 | %.s : %.c |
404 | %.s : %.c |
404 | $(CC) -S $(ALL_CFLAGS) $< -o $@ |
405 | $(CC) -S $(ALL_CFLAGS) $< -o $@ |
405 | 406 | ||
406 | 407 | ||
407 | # Assemble: create object files from assembler source files. |
408 | # Assemble: create object files from assembler source files. |
408 | %.o : %.S |
409 | %.o : %.S |
409 | @echo |
410 | @echo |
410 | @echo $(MSG_ASSEMBLING) $< |
411 | @echo $(MSG_ASSEMBLING) $< |
411 | $(CC) -c $(ALL_ASFLAGS) $< -o $@ |
412 | $(CC) -c $(ALL_ASFLAGS) $< -o $@ |
412 | 413 | ||
413 | 414 | ||
414 | 415 | ||
415 | 416 | ||
416 | 417 | ||
417 | 418 | ||
418 | # Target: clean project. |
419 | # Target: clean project. |
419 | clean: begin clean_list finished end |
420 | clean: begin clean_list finished end |
420 | 421 | ||
421 | clean_list : |
422 | clean_list : |
422 | @echo |
423 | @echo |
423 | @echo $(MSG_CLEANING) |
424 | @echo $(MSG_CLEANING) |
424 | # $(REMOVE) $(TARGET).hex |
425 | # $(REMOVE) $(TARGET).hex |
425 | $(REMOVE) $(TARGET).eep |
426 | $(REMOVE) $(TARGET).eep |
426 | $(REMOVE) $(TARGET).obj |
427 | $(REMOVE) $(TARGET).obj |
427 | $(REMOVE) $(TARGET).cof |
428 | $(REMOVE) $(TARGET).cof |
428 | $(REMOVE) $(TARGET).elf |
429 | $(REMOVE) $(TARGET).elf |
429 | $(REMOVE) $(TARGET).map |
430 | $(REMOVE) $(TARGET).map |
430 | $(REMOVE) $(TARGET).obj |
431 | $(REMOVE) $(TARGET).obj |
431 | $(REMOVE) $(TARGET).a90 |
432 | $(REMOVE) $(TARGET).a90 |
432 | $(REMOVE) $(TARGET).sym |
433 | $(REMOVE) $(TARGET).sym |
433 | $(REMOVE) $(TARGET).lnk |
434 | $(REMOVE) $(TARGET).lnk |
434 | $(REMOVE) $(TARGET).lss |
435 | $(REMOVE) $(TARGET).lss |
435 | $(REMOVE) $(OBJ) |
436 | $(REMOVE) $(OBJ) |
436 | $(REMOVE) $(LST) |
437 | $(REMOVE) $(LST) |
437 | $(REMOVE) $(SRC:.c=.s) |
438 | $(REMOVE) $(SRC:.c=.s) |
438 | $(REMOVE) $(SRC:.c=.d) |
439 | $(REMOVE) $(SRC:.c=.d) |
439 | 440 | ||
440 | 441 | ||
441 | # Automatically generate C source code dependencies. |
442 | # Automatically generate C source code dependencies. |
442 | # (Code originally taken from the GNU make user manual and modified |
443 | # (Code originally taken from the GNU make user manual and modified |
443 | # (See README.txt Credits).) |
444 | # (See README.txt Credits).) |
444 | # |
445 | # |
445 | # Note that this will work with sh (bash) and sed that is shipped with WinAVR |
446 | # Note that this will work with sh (bash) and sed that is shipped with WinAVR |
446 | # (see the SHELL variable defined above). |
447 | # (see the SHELL variable defined above). |
447 | # This may not work with other shells or other seds. |
448 | # This may not work with other shells or other seds. |
448 | # |
449 | # |
449 | %.d: %.c |
450 | %.d: %.c |
450 | set -e; $(CC) -MM $(ALL_CFLAGS) $< \ |
451 | set -e; $(CC) -MM $(ALL_CFLAGS) $< \ |
451 | | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \ |
452 | | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \ |
452 | [ -s $@ ] || rm -f $@ |
453 | [ -s $@ ] || rm -f $@ |
453 | 454 | ||
454 | 455 | ||
455 | # Remove the '-' if you want to see the dependency files generated. |
456 | # Remove the '-' if you want to see the dependency files generated. |
456 | -include $(SRC:.c=.d) |
457 | -include $(SRC:.c=.d) |
457 | 458 | ||
458 | 459 | ||
459 | 460 | ||
460 | # Listing of phony targets. |
461 | # Listing of phony targets. |
461 | .PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \ |
462 | .PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \ |
462 | clean clean_list program |
463 | clean clean_list program |
463 | 464 |