Subversion Repositories FlightCtrl

Rev

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

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