Subversion Repositories FlightCtrl

Rev

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