Subversion Repositories FlightCtrl

Rev

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