Subversion Repositories FlightCtrl

Rev

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