Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

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