Subversion Repositories FlightCtrl

Rev

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

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