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