Subversion Repositories FlightCtrl

Rev

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

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