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