Subversion Repositories FlightCtrl

Rev

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