Subversion Repositories FlightCtrl

Rev

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

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