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