Subversion Repositories FlightCtrl

Rev

Details | Last modification | View Log | RSS feed

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