Subversion Repositories FlightCtrl

Rev

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