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