Rev 1426 | Rev 1435 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1426 | Rev 1431 | ||
---|---|---|---|
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 = 0 |
8 | VERSION_PATCH = 0 |
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 = 2 |
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 printf_P.c timer0.c analog.c menu.c |
109 | SRC = main.c uart.c printf_P.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 |
111 | SRC += mymath.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) \ |
139 | CFLAGS = -O$(OPT) \ |
140 | -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \ |
140 | -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \ |
141 | -Wall -Wstrict-prototypes \ |
141 | -Wall -Wstrict-prototypes \ |
142 | -Wa,-adhlns=$(<:.c=.lst) \ |
142 | -Wa,-adhlns=$(<:.c=.lst) \ |
143 | $(patsubst %,-I%,$(EXTRAINCDIRS)) |
143 | $(patsubst %,-I%,$(EXTRAINCDIRS)) |
144 | 144 | ||
145 | 145 | ||
146 | # Set a "language standard" compiler flag. |
146 | # Set a "language standard" compiler flag. |
147 | # Unremark just one line below to set the language standard to use. |
147 | # Unremark just one line below to set the language standard to use. |
148 | # gnu99 = C99 + GNU extensions. See GCC manual for more information. |
148 | # gnu99 = C99 + GNU extensions. See GCC manual for more information. |
149 | #CFLAGS += -std=c89 |
149 | #CFLAGS += -std=c89 |
150 | #CFLAGS += -std=gnu89 |
150 | #CFLAGS += -std=gnu89 |
151 | #CFLAGS += -std=c99 |
151 | #CFLAGS += -std=c99 |
152 | CFLAGS += -std=gnu99 |
152 | CFLAGS += -std=gnu99 |
153 | 153 | ||
154 | CFLAGS += -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) |
154 | CFLAGS += -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) |
155 | 155 | ||
156 | 156 | ||
157 | # Optional assembler flags. |
157 | # Optional assembler flags. |
158 | # -Wa,...: tell GCC to pass this to the assembler. |
158 | # -Wa,...: tell GCC to pass this to the assembler. |
159 | # -ahlms: create listing |
159 | # -ahlms: create listing |
160 | # -gstabs: have the assembler create line number information; note that |
160 | # -gstabs: have the assembler create line number information; note that |
161 | # for use in COFF files, additional information about filenames |
161 | # for use in COFF files, additional information about filenames |
162 | # and function names needs to be present in the assembler source |
162 | # and function names needs to be present in the assembler source |
163 | # files -- see avr-libc docs [FIXME: not yet described there] |
163 | # files -- see avr-libc docs [FIXME: not yet described there] |
164 | ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs |
164 | ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs |
165 | 165 | ||
166 | 166 | ||
167 | 167 | ||
168 | # Optional linker flags. |
168 | # Optional linker flags. |
169 | # -Wl,...: tell GCC to pass this to linker. |
169 | # -Wl,...: tell GCC to pass this to linker. |
170 | # -Map: create map file |
170 | # -Map: create map file |
171 | # --cref: add cross reference to map file |
171 | # --cref: add cross reference to map file |
172 | LDFLAGS = -Wl,-Map=$(TARGET).map,--cref |
172 | LDFLAGS = -Wl,-Map=$(TARGET).map,--cref |
173 | 173 | ||
174 | # Additional libraries |
174 | # Additional libraries |
175 | 175 | ||
176 | # Minimalistic printf version |
176 | # Minimalistic printf version |
177 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_min |
177 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_min |
178 | 178 | ||
179 | # Floating point printf version (requires -lm below) |
179 | # Floating point printf version (requires -lm below) |
180 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt |
180 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt |
181 | 181 | ||
182 | # -lm = math library |
182 | # -lm = math library |
183 | LDFLAGS += -lm |
183 | LDFLAGS += -lm |
184 | 184 | ||
185 | LDFLAGS += libfcinit.a |
185 | LDFLAGS += libfcinit.a |
186 | 186 | ||
187 | ##LDFLAGS += -T./linkerfile/avr5.x |
187 | ##LDFLAGS += -T./linkerfile/avr5.x |
188 | 188 | ||
189 | 189 | ||
190 | 190 | ||
191 | # Programming support using avrdude. Settings and variables. |
191 | # Programming support using avrdude. Settings and variables. |
192 | 192 | ||
193 | # Programming hardware: alf avr910 avrisp bascom bsd |
193 | # Programming hardware: alf avr910 avrisp bascom bsd |
194 | # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 |
194 | # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 |
195 | # |
195 | # |
196 | # Type: avrdude -c ? |
196 | # Type: avrdude -c ? |
197 | # to get a full listing. |
197 | # to get a full listing. |
198 | # |
198 | # |
199 | #AVRDUDE_PROGRAMMER = dt006 |
199 | #AVRDUDE_PROGRAMMER = dt006 |
200 | #AVRDUDE_PROGRAMMER = stk200 |
200 | #AVRDUDE_PROGRAMMER = stk200 |
201 | #AVRDUDE_PROGRAMMER = ponyser |
201 | #AVRDUDE_PROGRAMMER = ponyser |
202 | AVRDUDE_PROGRAMMER = avrispv2 |
202 | AVRDUDE_PROGRAMMER = avrispv2 |
203 | #falls Ponyser ausgewählt wird, muss sich unsere avrdude-Configdatei im Bin-Verzeichnis des Compilers befinden |
203 | #falls Ponyser ausgewählt wird, muss sich unsere avrdude-Configdatei im Bin-Verzeichnis des Compilers befinden |
204 | 204 | ||
205 | #AVRDUDE_PORT = com1 # programmer connected to serial device |
205 | #AVRDUDE_PORT = com1 # programmer connected to serial device |
206 | #AVRDUDE_PORT = lpt1 # programmer connected to parallel port |
206 | #AVRDUDE_PORT = lpt1 # programmer connected to parallel port |
207 | AVRDUDE_PORT = usb # programmer connected to USB |
207 | AVRDUDE_PORT = usb # programmer connected to USB |
208 | 208 | ||
209 | #AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex |
209 | #AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex |
210 | AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex $(FUSE_SETTINGS) |
210 | AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex $(FUSE_SETTINGS) |
211 | #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep |
211 | #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep |
212 | 212 | ||
213 | #avrdude -c avrispv2 -P usb -p m32 -U flash:w:blink.hex |
213 | #avrdude -c avrispv2 -P usb -p m32 -U flash:w:blink.hex |
214 | AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) |
214 | AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) |
215 | 215 | ||
216 | # Uncomment the following if you want avrdude's erase cycle counter. |
216 | # Uncomment the following if you want avrdude's erase cycle counter. |
217 | # Note that this counter needs to be initialized first using -Yn, |
217 | # Note that this counter needs to be initialized first using -Yn, |
218 | # see avrdude manual. |
218 | # see avrdude manual. |
219 | #AVRDUDE_ERASE += -y |
219 | #AVRDUDE_ERASE += -y |
220 | 220 | ||
221 | # Uncomment the following if you do /not/ wish a verification to be |
221 | # Uncomment the following if you do /not/ wish a verification to be |
222 | # performed after programming the device. |
222 | # performed after programming the device. |
223 | AVRDUDE_FLAGS += -V |
223 | AVRDUDE_FLAGS += -V |
224 | 224 | ||
225 | # Increase verbosity level. Please use this when submitting bug |
225 | # Increase verbosity level. Please use this when submitting bug |
226 | # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> |
226 | # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> |
227 | # to submit bug reports. |
227 | # to submit bug reports. |
228 | #AVRDUDE_FLAGS += -v -v |
228 | #AVRDUDE_FLAGS += -v -v |
229 | 229 | ||
230 | # --------------------------------------------------------------------------- |
230 | # --------------------------------------------------------------------------- |
231 | # Define directories, if needed. |
231 | # Define directories, if needed. |
232 | DIRAVR = c:/winavr |
232 | DIRAVR = c:/winavr |
233 | DIRAVRBIN = $(DIRAVR)/bin |
233 | DIRAVRBIN = $(DIRAVR)/bin |
234 | DIRAVRUTILS = $(DIRAVR)/utils/bin |
234 | DIRAVRUTILS = $(DIRAVR)/utils/bin |
235 | DIRINC = . |
235 | DIRINC = . |
236 | DIRLIB = $(DIRAVR)/avr/lib |
236 | DIRLIB = $(DIRAVR)/avr/lib |
237 | 237 | ||
238 | 238 | ||
239 | # Define programs and commands. |
239 | # Define programs and commands. |
240 | SHELL = sh |
240 | SHELL = sh |
241 | 241 | ||
242 | CC = avr-gcc |
242 | CC = avr-gcc |
243 | 243 | ||
244 | OBJCOPY = avr-objcopy |
244 | OBJCOPY = avr-objcopy |
245 | OBJDUMP = avr-objdump |
245 | OBJDUMP = avr-objdump |
246 | SIZE = avr-size |
246 | SIZE = avr-size |
247 | 247 | ||
248 | # Programming support using avrdude. |
248 | # Programming support using avrdude. |
249 | AVRDUDE = avrdude |
249 | AVRDUDE = avrdude |
250 | 250 | ||
251 | REMOVE = rm -f |
251 | REMOVE = rm -f |
252 | COPY = cp |
252 | COPY = cp |
253 | 253 | ||
254 | HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex |
254 | HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex |
255 | ELFSIZE = $(SIZE) -A $(TARGET).elf |
255 | ELFSIZE = $(SIZE) -A $(TARGET).elf |
256 | 256 | ||
257 | # Define Messages |
257 | # Define Messages |
258 | # English |
258 | # English |
259 | MSG_ERRORS_NONE = Errors: none |
259 | MSG_ERRORS_NONE = Errors: none |
260 | MSG_BEGIN = -------- begin -------- |
260 | MSG_BEGIN = -------- begin -------- |
261 | MSG_END = -------- end -------- |
261 | MSG_END = -------- end -------- |
262 | MSG_SIZE_BEFORE = Size before: |
262 | MSG_SIZE_BEFORE = Size before: |
263 | MSG_SIZE_AFTER = Size after: |
263 | MSG_SIZE_AFTER = Size after: |
264 | MSG_COFF = Converting to AVR COFF: |
264 | MSG_COFF = Converting to AVR COFF: |
265 | MSG_EXTENDED_COFF = Converting to AVR Extended COFF: |
265 | MSG_EXTENDED_COFF = Converting to AVR Extended COFF: |
266 | MSG_FLASH = Creating load file for Flash: |
266 | MSG_FLASH = Creating load file for Flash: |
267 | MSG_EEPROM = Creating load file for EEPROM: |
267 | MSG_EEPROM = Creating load file for EEPROM: |
268 | MSG_EXTENDED_LISTING = Creating Extended Listing: |
268 | MSG_EXTENDED_LISTING = Creating Extended Listing: |
269 | MSG_SYMBOL_TABLE = Creating Symbol Table: |
269 | MSG_SYMBOL_TABLE = Creating Symbol Table: |
270 | MSG_LINKING = Linking: |
270 | MSG_LINKING = Linking: |
271 | MSG_COMPILING = Compiling: |
271 | MSG_COMPILING = Compiling: |
272 | MSG_ASSEMBLING = Assembling: |
272 | MSG_ASSEMBLING = Assembling: |
273 | MSG_CLEANING = Cleaning project: |
273 | MSG_CLEANING = Cleaning project: |
274 | 274 | ||
275 | 275 | ||
276 | # Define all object files. |
276 | # Define all object files. |
277 | OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) |
277 | OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) |
278 | 278 | ||
279 | # Define all listing files. |
279 | # Define all listing files. |
280 | LST = $(ASRC:.S=.lst) $(SRC:.c=.lst) |
280 | LST = $(ASRC:.S=.lst) $(SRC:.c=.lst) |
281 | 281 | ||
282 | # Combine all necessary flags and optional flags. |
282 | # Combine all necessary flags and optional flags. |
283 | # Add target processor to flags. |
283 | # Add target processor to flags. |
284 | #ALL_CFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -I. $(CFLAGS) |
284 | #ALL_CFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -I. $(CFLAGS) |
285 | ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) |
285 | ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) |
286 | ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) |
286 | ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) |
287 | 287 | ||
288 | 288 | ||
289 | # Default target. |
289 | # Default target. |
290 | all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \ |
290 | all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \ |
291 | $(TARGET).lss $(TARGET).sym sizeafter finished end |
291 | $(TARGET).lss $(TARGET).sym sizeafter finished end |
292 | 292 | ||
293 | 293 | ||
294 | # Eye candy. |
294 | # Eye candy. |
295 | # AVR Studio 3.x does not check make's exit code but relies on |
295 | # AVR Studio 3.x does not check make's exit code but relies on |
296 | # the following magic strings to be generated by the compile job. |
296 | # the following magic strings to be generated by the compile job. |
297 | begin: |
297 | begin: |
298 | @echo |
298 | @echo |
299 | @echo $(MSG_BEGIN) |
299 | @echo $(MSG_BEGIN) |
300 | 300 | ||
301 | finished: |
301 | finished: |
302 | @echo $(MSG_ERRORS_NONE) |
302 | @echo $(MSG_ERRORS_NONE) |
303 | 303 | ||
304 | end: |
304 | end: |
305 | @echo $(MSG_END) |
305 | @echo $(MSG_END) |
306 | @echo |
306 | @echo |
307 | 307 | ||
308 | 308 | ||
309 | # Display size of file. |
309 | # Display size of file. |
310 | # Display size of file. |
310 | # Display size of file. |
311 | sizebefore: |
311 | sizebefore: |
312 | @if [ -f $(TARGET).elf ]; then echo Size before:; $(ELFSIZE); $(HEXSIZE); echo; fi |
312 | @if [ -f $(TARGET).elf ]; then echo Size before:; $(ELFSIZE); $(HEXSIZE); echo; fi |
313 | sizeafter: |
313 | sizeafter: |
314 | @if [ -f $(TARGET).elf ]; then echo Size after:; $(ELFSIZE); $(HEXSIZE); echo; fi |
314 | @if [ -f $(TARGET).elf ]; then echo Size after:; $(ELFSIZE); $(HEXSIZE); echo; fi |
315 | 315 | ||
316 | 316 | ||
317 | # Display compiler version information. |
317 | # Display compiler version information. |
318 | gccversion : |
318 | gccversion : |
319 | @$(CC) --version |
319 | @$(CC) --version |
320 | 320 | ||
321 | 321 | ||
322 | # Convert ELF to COFF for use in debugging / simulating in |
322 | # Convert ELF to COFF for use in debugging / simulating in |
323 | # AVR Studio or VMLAB. |
323 | # AVR Studio or VMLAB. |
324 | COFFCONVERT=$(OBJCOPY) --debugging \ |
324 | COFFCONVERT=$(OBJCOPY) --debugging \ |
325 | --change-section-address .data-0x800000 \ |
325 | --change-section-address .data-0x800000 \ |
326 | --change-section-address .bss-0x800000 \ |
326 | --change-section-address .bss-0x800000 \ |
327 | --change-section-address .noinit-0x800000 \ |
327 | --change-section-address .noinit-0x800000 \ |
328 | --change-section-address .eeprom-0x810000 |
328 | --change-section-address .eeprom-0x810000 |
329 | 329 | ||
330 | 330 | ||
331 | coff: $(TARGET).elf |
331 | coff: $(TARGET).elf |
332 | @echo |
332 | @echo |
333 | @echo $(MSG_COFF) $(TARGET).cof |
333 | @echo $(MSG_COFF) $(TARGET).cof |
334 | $(COFFCONVERT) -O coff-avr $< $(TARGET).cof |
334 | $(COFFCONVERT) -O coff-avr $< $(TARGET).cof |
335 | 335 | ||
336 | 336 | ||
337 | extcoff: $(TARGET).elf |
337 | extcoff: $(TARGET).elf |
338 | @echo |
338 | @echo |
339 | @echo $(MSG_EXTENDED_COFF) $(TARGET).cof |
339 | @echo $(MSG_EXTENDED_COFF) $(TARGET).cof |
340 | $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof |
340 | $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof |
341 | 341 | ||
342 | 342 | ||
343 | 343 | ||
344 | 344 | ||
345 | # Program the device. |
345 | # Program the device. |
346 | program: $(TARGET).hex $(TARGET).eep |
346 | program: $(TARGET).hex $(TARGET).eep |
347 | $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) |
347 | $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) |
348 | 348 | ||
349 | 349 | ||
350 | 350 | ||
351 | 351 | ||
352 | # Create final output files (.hex, .eep) from ELF output file. |
352 | # Create final output files (.hex, .eep) from ELF output file. |
353 | %.hex: %.elf |
353 | %.hex: %.elf |
354 | @echo |
354 | @echo |
355 | @echo $(MSG_FLASH) $@ |
355 | @echo $(MSG_FLASH) $@ |
356 | $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ |
356 | $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ |
357 | 357 | ||
358 | %.eep: %.elf |
358 | %.eep: %.elf |
359 | @echo |
359 | @echo |
360 | @echo $(MSG_EEPROM) $@ |
360 | @echo $(MSG_EEPROM) $@ |
361 | -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ |
361 | -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ |
362 | --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ |
362 | --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ |
363 | 363 | ||
364 | # Create extended listing file from ELF output file. |
364 | # Create extended listing file from ELF output file. |
365 | %.lss: %.elf |
365 | %.lss: %.elf |
366 | @echo |
366 | @echo |
367 | @echo $(MSG_EXTENDED_LISTING) $@ |
367 | @echo $(MSG_EXTENDED_LISTING) $@ |
368 | $(OBJDUMP) -h -S $< > $@ |
368 | $(OBJDUMP) -h -S $< > $@ |
369 | 369 | ||
370 | # Create a symbol table from ELF output file. |
370 | # Create a symbol table from ELF output file. |
371 | %.sym: %.elf |
371 | %.sym: %.elf |
372 | @echo |
372 | @echo |
373 | @echo $(MSG_SYMBOL_TABLE) $@ |
373 | @echo $(MSG_SYMBOL_TABLE) $@ |
374 | avr-nm -n $< > $@ |
374 | avr-nm -n $< > $@ |
375 | 375 | ||
376 | 376 | ||
377 | 377 | ||
378 | # Link: create ELF output file from object files. |
378 | # Link: create ELF output file from object files. |
379 | .SECONDARY : $(TARGET).elf |
379 | .SECONDARY : $(TARGET).elf |
380 | .PRECIOUS : $(OBJ) |
380 | .PRECIOUS : $(OBJ) |
381 | %.elf: $(OBJ) |
381 | %.elf: $(OBJ) |
382 | @echo |
382 | @echo |
383 | @echo $(MSG_LINKING) $@ |
383 | @echo $(MSG_LINKING) $@ |
384 | $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) |
384 | $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) |
385 | 385 | ||
386 | 386 | ||
387 | # Compile: create object files from C source files. |
387 | # Compile: create object files from C source files. |
388 | %.o : %.c |
388 | %.o : %.c |
389 | @echo |
389 | @echo |
390 | @echo $(MSG_COMPILING) $< |
390 | @echo $(MSG_COMPILING) $< |
391 | $(CC) -c $(ALL_CFLAGS) $< -o $@ |
391 | $(CC) -c $(ALL_CFLAGS) $< -o $@ |
392 | 392 | ||
393 | 393 | ||
394 | # Compile: create assembler files from C source files. |
394 | # Compile: create assembler files from C source files. |
395 | %.s : %.c |
395 | %.s : %.c |
396 | $(CC) -S $(ALL_CFLAGS) $< -o $@ |
396 | $(CC) -S $(ALL_CFLAGS) $< -o $@ |
397 | 397 | ||
398 | 398 | ||
399 | # Assemble: create object files from assembler source files. |
399 | # Assemble: create object files from assembler source files. |
400 | %.o : %.S |
400 | %.o : %.S |
401 | @echo |
401 | @echo |
402 | @echo $(MSG_ASSEMBLING) $< |
402 | @echo $(MSG_ASSEMBLING) $< |
403 | $(CC) -c $(ALL_ASFLAGS) $< -o $@ |
403 | $(CC) -c $(ALL_ASFLAGS) $< -o $@ |
404 | 404 | ||
405 | 405 | ||
406 | 406 | ||
407 | 407 | ||
408 | 408 | ||
409 | 409 | ||
410 | # Target: clean project. |
410 | # Target: clean project. |
411 | clean: begin clean_list finished end |
411 | clean: begin clean_list finished end |
412 | 412 | ||
413 | clean_list : |
413 | clean_list : |
414 | @echo |
414 | @echo |
415 | @echo $(MSG_CLEANING) |
415 | @echo $(MSG_CLEANING) |
416 | # $(REMOVE) $(TARGET).hex |
416 | $(REMOVE) Flight-Ctrl_*.hex |
417 | $(REMOVE) $(TARGET).eep |
417 | $(REMOVE) $(TARGET).eep |
418 | $(REMOVE) $(TARGET).obj |
418 | $(REMOVE) $(TARGET).obj |
419 | $(REMOVE) $(TARGET).cof |
419 | $(REMOVE) $(TARGET).cof |
420 | $(REMOVE) $(TARGET).elf |
420 | $(REMOVE) $(TARGET).elf |
421 | $(REMOVE) $(TARGET).map |
421 | $(REMOVE) $(TARGET).map |
422 | $(REMOVE) $(TARGET).obj |
422 | $(REMOVE) $(TARGET).obj |
423 | $(REMOVE) $(TARGET).a90 |
423 | $(REMOVE) $(TARGET).a90 |
424 | $(REMOVE) $(TARGET).sym |
424 | $(REMOVE) $(TARGET).sym |
425 | $(REMOVE) $(TARGET).lnk |
425 | $(REMOVE) $(TARGET).lnk |
426 | $(REMOVE) $(TARGET).lss |
426 | $(REMOVE) $(TARGET).lss |
427 | # $(REMOVE) $(OBJ) |
427 | $(REMOVE) $(OBJ) |
428 | $(REMOVE) $(LST) |
428 | $(REMOVE) $(LST) |
429 | $(REMOVE) $(SRC:.c=.s) |
429 | $(REMOVE) $(SRC:.c=.s) |
430 | $(REMOVE) $(SRC:.c=.d) |
430 | $(REMOVE) $(SRC:.c=.d) |
431 | $(REMOVE) $(SRC:.c=.o) |
431 | $(REMOVE) $(SRC:.c=.o) |
432 | 432 | ||
433 | 433 | ||
434 | # Automatically generate C source code dependencies. |
434 | # Automatically generate C source code dependencies. |
435 | # (Code originally taken from the GNU make user manual and modified |
435 | # (Code originally taken from the GNU make user manual and modified |
436 | # (See README.txt Credits).) |
436 | # (See README.txt Credits).) |
437 | # |
437 | # |
438 | # Note that this will work with sh (bash) and sed that is shipped with WinAVR |
438 | # Note that this will work with sh (bash) and sed that is shipped with WinAVR |
439 | # (see the SHELL variable defined above). |
439 | # (see the SHELL variable defined above). |
440 | # This may not work with other shells or other seds. |
440 | # This may not work with other shells or other seds. |
441 | # |
441 | # |
442 | %.d: %.c |
442 | %.d: %.c |
443 | set -e; $(CC) -MM $(ALL_CFLAGS) $< \ |
443 | set -e; $(CC) -MM $(ALL_CFLAGS) $< \ |
444 | | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \ |
444 | | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \ |
445 | [ -s $@ ] || rm -f $@ |
445 | [ -s $@ ] || rm -f $@ |
446 | 446 | ||
447 | 447 | ||
448 | # Remove the '-' if you want to see the dependency files generated. |
448 | # Remove the '-' if you want to see the dependency files generated. |
449 | -include $(SRC:.c=.d) |
449 | -include $(SRC:.c=.d) |
450 | 450 | ||
451 | 451 | ||
452 | 452 | ||
453 | # Listing of phony targets. |
453 | # Listing of phony targets. |
454 | .PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \ |
454 | .PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \ |
455 | clean clean_list program |
455 | clean clean_list program |
456 | 456 |