Subversion Repositories FlightCtrl

Rev

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

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