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