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