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