Subversion Repositories Projects

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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