Subversion Repositories FlightCtrl

Rev

Rev 595 | Rev 604 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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