Subversion Repositories FlightCtrl

Rev

Rev 513 | Rev 597 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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