Subversion Repositories FlightCtrl

Rev

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

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