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