Subversion Repositories FlightCtrl

Rev

Rev 1596 | Details | Compare with Previous | Last modification | View Log | RSS feed

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