root / arduino-1.0 / hardware / arduino / bootloaders / stk500v2 / Makefile @ 58d82c77
History | View | Annotate | Download (17.1 KB)
1 | 58d82c77 | Tom Mullins | # ---------------------------------------------------------------------------- |
---|---|---|---|
2 | # Makefile to compile and link stk500boot bootloader |
||
3 | # Author: Peter Fleury |
||
4 | # File: $Id: Makefile,v 1.3 2006/03/04 19:26:17 peter Exp $ |
||
5 | # based on WinAVR Makefile Template written by Eric B. Weddington, J?rg Wunsch, et al. |
||
6 | # |
||
7 | # Adjust F_CPU below to the clock frequency in Mhz of your AVR target |
||
8 | # Adjust BOOTLOADER_ADDRESS to your AVR target |
||
9 | # |
||
10 | #---------------------------------------------------------------------------- |
||
11 | # On command line: |
||
12 | # |
||
13 | # make all = Make software. |
||
14 | # |
||
15 | # make clean = Clean out built project files. |
||
16 | # |
||
17 | # make coff = Convert ELF to AVR COFF. |
||
18 | # |
||
19 | # make extcoff = Convert ELF to AVR Extended COFF. |
||
20 | # |
||
21 | # make program = Download the hex file to the device, using avrdude. |
||
22 | # Please customize the avrdude settings below first! |
||
23 | # |
||
24 | # make debug = Start either simulavr or avarice as specified for debugging, |
||
25 | # with avr-gdb or avr-insight as the front end for debugging. |
||
26 | # |
||
27 | # make filename.s = Just compile filename.c into the assembler code only. |
||
28 | # |
||
29 | # make filename.i = Create a preprocessed source file for use in submitting |
||
30 | # bug reports to the GCC project. |
||
31 | # |
||
32 | # To rebuild project do "make clean" then "make all". |
||
33 | #---------------------------------------------------------------------------- |
||
34 | # <MLS> = Mark Sproul msproul-at-skychariot.com |
||
35 | |||
36 | |||
37 | # MCU name |
||
38 | #MCU = atmega128 |
||
39 | |||
40 | |||
41 | # Processor frequency. |
||
42 | # This will define a symbol, F_CPU, in all source code files equal to the |
||
43 | # processor frequency. You can then use this symbol in your source code to |
||
44 | # calculate timings. Do NOT tack on a 'UL' at the end, this will be done |
||
45 | # automatically to create a 32-bit value in your source code. |
||
46 | #F_CPU = 16000000 |
||
47 | |||
48 | |||
49 | # Bootloader |
||
50 | # Please adjust if using a different AVR |
||
51 | # 0x0e00*2=0x1C00 for ATmega8 512 words Boot Size |
||
52 | # 0xFC00*2=0x1F800 for ATmega128 1024 words Boot Size |
||
53 | # 0xF800*2=0x1F000 for ATmega1280 |
||
54 | # 0xF000*2=0x1E000 for ATmega1280 |
||
55 | #BOOTLOADER_ADDRESS = 1E000 |
||
56 | |||
57 | |||
58 | # Output format. (can be srec, ihex, binary) |
||
59 | FORMAT = ihex |
||
60 | |||
61 | |||
62 | # Target file name (without extension). |
||
63 | TARGET = stk500boot |
||
64 | |||
65 | |||
66 | # List C source files here. (C dependencies are automatically generated.) |
||
67 | SRC = stk500boot.c |
||
68 | |||
69 | |||
70 | # List Assembler source files here. |
||
71 | # Make them always end in a capital .S. Files ending in a lowercase .s |
||
72 | # will not be considered source files but generated files (assembler |
||
73 | # output from the compiler), and will be deleted upon "make clean"! |
||
74 | # Even though the DOS/Win* filesystem matches both .s and .S the same, |
||
75 | # it will preserve the spelling of the filenames, and gcc itself does |
||
76 | # care about how the name is spelled on its command-line. |
||
77 | ASRC = |
||
78 | |||
79 | |||
80 | # Optimization level, can be [0, 1, 2, 3, s]. |
||
81 | # 0 = turn off optimization. s = optimize for size. |
||
82 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
||
83 | OPT = s |
||
84 | |||
85 | |||
86 | # Debugging format. |
||
87 | # Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. |
||
88 | # AVR Studio 4.10 requires dwarf-2. |
||
89 | # AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. |
||
90 | DEBUG = dwarf-2 |
||
91 | |||
92 | |||
93 | # List any extra directories to look for include files here. |
||
94 | # Each directory must be seperated by a space. |
||
95 | # Use forward slashes for directory separators. |
||
96 | # For a directory that has spaces, enclose it in quotes. |
||
97 | EXTRAINCDIRS = |
||
98 | |||
99 | |||
100 | # Compiler flag to set the C Standard level. |
||
101 | # c89 = "ANSI" C |
||
102 | # gnu89 = c89 plus GCC extensions |
||
103 | # c99 = ISO C99 standard (not yet fully implemented) |
||
104 | # gnu99 = c99 plus GCC extensions |
||
105 | CSTANDARD = -std=gnu99 |
||
106 | |||
107 | |||
108 | # Place -D or -U options here |
||
109 | CDEFS = -DF_CPU=$(F_CPU)UL |
||
110 | |||
111 | |||
112 | # Place -I options here |
||
113 | CINCS = |
||
114 | |||
115 | |||
116 | |||
117 | #---------------- Compiler Options ---------------- |
||
118 | # -g*: generate debugging information |
||
119 | # -O*: optimization level |
||
120 | # -f...: tuning, see GCC manual and avr-libc documentation |
||
121 | # -Wall...: warning level |
||
122 | # -Wa,...: tell GCC to pass this to the assembler. |
||
123 | # -adhlns...: create assembler listing |
||
124 | CFLAGS = -g$(DEBUG) |
||
125 | CFLAGS += $(CDEFS) $(CINCS) |
||
126 | CFLAGS += -O$(OPT) |
||
127 | CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -mno-tablejump |
||
128 | CFLAGS += -Wall -Wstrict-prototypes |
||
129 | CFLAGS += -Wa,-adhlns=$(<:.c=.lst) |
||
130 | CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) |
||
131 | CFLAGS += $(CSTANDARD) |
||
132 | |||
133 | |||
134 | #---------------- Assembler Options ---------------- |
||
135 | # -Wa,...: tell GCC to pass this to the assembler. |
||
136 | # -ahlms: create listing |
||
137 | # -gstabs: have the assembler create line number information; note that |
||
138 | # for use in COFF files, additional information about filenames |
||
139 | # and function names needs to be present in the assembler source |
||
140 | # files -- see avr-libc docs [FIXME: not yet described there] |
||
141 | ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs |
||
142 | |||
143 | |||
144 | #---------------- Library Options ---------------- |
||
145 | # Minimalistic printf version |
||
146 | PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min |
||
147 | |||
148 | # Floating point printf version (requires MATH_LIB = -lm below) |
||
149 | PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt |
||
150 | |||
151 | # If this is left blank, then it will use the Standard printf version. |
||
152 | PRINTF_LIB = |
||
153 | #PRINTF_LIB = $(PRINTF_LIB_MIN) |
||
154 | #PRINTF_LIB = $(PRINTF_LIB_FLOAT) |
||
155 | |||
156 | |||
157 | # Minimalistic scanf version |
||
158 | SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min |
||
159 | |||
160 | # Floating point + %[ scanf version (requires MATH_LIB = -lm below) |
||
161 | SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt |
||
162 | |||
163 | # If this is left blank, then it will use the Standard scanf version. |
||
164 | SCANF_LIB = |
||
165 | #SCANF_LIB = $(SCANF_LIB_MIN) |
||
166 | #SCANF_LIB = $(SCANF_LIB_FLOAT) |
||
167 | |||
168 | |||
169 | MATH_LIB = -lm |
||
170 | |||
171 | |||
172 | |||
173 | #---------------- External Memory Options ---------------- |
||
174 | |||
175 | # 64 KB of external RAM, starting after internal RAM (ATmega128!), |
||
176 | # used for variables (.data/.bss) and heap (malloc()). |
||
177 | #EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff |
||
178 | |||
179 | # 64 KB of external RAM, starting after internal RAM (ATmega128!), |
||
180 | # only used for heap (malloc()). |
||
181 | #EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff |
||
182 | |||
183 | EXTMEMOPTS = |
||
184 | |||
185 | |||
186 | |||
187 | |||
188 | #---------------- Linker Options ---------------- |
||
189 | # -Wl,...: tell GCC to pass this to linker. |
||
190 | # -Map: create map file |
||
191 | # --cref: add cross reference to map file |
||
192 | LDFLAGS = -Wl,-Map=$(TARGET).map,--cref |
||
193 | LDFLAGS += $(EXTMEMOPTS) |
||
194 | LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) |
||
195 | |||
196 | |||
197 | #--------------- bootloader linker Options ------- |
||
198 | # BOOTLOADER_ADDRESS (=Start of Boot Loader section |
||
199 | # in bytes - not words) is defined above. |
||
200 | #LDFLAGS += -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS) -nostartfiles -nodefaultlibs |
||
201 | #LDFLAGS += -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS) -nostartfiles |
||
202 | LDFLAGS += -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS) |
||
203 | |||
204 | #---------------- Programming Options (avrdude) ---------------- |
||
205 | |||
206 | # Programming hardware: alf avr910 avrisp bascom bsd |
||
207 | # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 |
||
208 | # |
||
209 | # Type: avrdude -c ? |
||
210 | # to get a full listing. |
||
211 | # |
||
212 | AVRDUDE_PROGRAMMER = stk500v2 |
||
213 | |||
214 | # com1 = serial port. Use lpt1 to connect to parallel port. |
||
215 | AVRDUDE_PORT = com1 # programmer connected to serial device |
||
216 | |||
217 | AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex |
||
218 | #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep |
||
219 | |||
220 | |||
221 | # Uncomment the following if you want avrdude's erase cycle counter. |
||
222 | # Note that this counter needs to be initialized first using -Yn, |
||
223 | # see avrdude manual. |
||
224 | #AVRDUDE_ERASE_COUNTER = -y |
||
225 | |||
226 | # Uncomment the following if you do /not/ wish a verification to be |
||
227 | # performed after programming the device. |
||
228 | #AVRDUDE_NO_VERIFY = -V |
||
229 | |||
230 | # Increase verbosity level. Please use this when submitting bug |
||
231 | # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> |
||
232 | # to submit bug reports. |
||
233 | #AVRDUDE_VERBOSE = -v -v |
||
234 | |||
235 | AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) |
||
236 | AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) |
||
237 | AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) |
||
238 | AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) |
||
239 | |||
240 | |||
241 | |||
242 | #---------------- Debugging Options ---------------- |
||
243 | |||
244 | # For simulavr only - target MCU frequency. |
||
245 | DEBUG_MFREQ = $(F_CPU) |
||
246 | |||
247 | # Set the DEBUG_UI to either gdb or insight. |
||
248 | # DEBUG_UI = gdb |
||
249 | DEBUG_UI = insight |
||
250 | |||
251 | # Set the debugging back-end to either avarice, simulavr. |
||
252 | DEBUG_BACKEND = avarice |
||
253 | #DEBUG_BACKEND = simulavr |
||
254 | |||
255 | # GDB Init Filename. |
||
256 | GDBINIT_FILE = __avr_gdbinit |
||
257 | |||
258 | # When using avarice settings for the JTAG |
||
259 | JTAG_DEV = /dev/com1 |
||
260 | |||
261 | # Debugging port used to communicate between GDB / avarice / simulavr. |
||
262 | DEBUG_PORT = 4242 |
||
263 | |||
264 | # Debugging host used to communicate between GDB / avarice / simulavr, normally |
||
265 | # just set to localhost unless doing some sort of crazy debugging when |
||
266 | # avarice is running on a different computer. |
||
267 | DEBUG_HOST = localhost |
||
268 | |||
269 | |||
270 | |||
271 | #============================================================================ |
||
272 | |||
273 | |||
274 | # Define programs and commands. |
||
275 | SHELL = sh |
||
276 | CC = avr-gcc |
||
277 | OBJCOPY = avr-objcopy |
||
278 | OBJDUMP = avr-objdump |
||
279 | SIZE = avr-size |
||
280 | NM = avr-nm |
||
281 | AVRDUDE = avrdude |
||
282 | REMOVE = rm -f |
||
283 | COPY = cp |
||
284 | WINSHELL = cmd |
||
285 | |||
286 | |||
287 | # Define Messages |
||
288 | # English |
||
289 | MSG_ERRORS_NONE = Errors: none |
||
290 | MSG_BEGIN = -------- begin -------- |
||
291 | MSG_END = -------- end -------- |
||
292 | MSG_SIZE_BEFORE = Size before: |
||
293 | MSG_SIZE_AFTER = Size after: |
||
294 | MSG_COFF = Converting to AVR COFF: |
||
295 | MSG_EXTENDED_COFF = Converting to AVR Extended COFF: |
||
296 | MSG_FLASH = Creating load file for Flash: |
||
297 | MSG_EEPROM = Creating load file for EEPROM: |
||
298 | MSG_EXTENDED_LISTING = Creating Extended Listing: |
||
299 | MSG_SYMBOL_TABLE = Creating Symbol Table: |
||
300 | MSG_LINKING = Linking: |
||
301 | MSG_COMPILING = Compiling: |
||
302 | MSG_ASSEMBLING = Assembling: |
||
303 | MSG_CLEANING = Cleaning project: |
||
304 | |||
305 | |||
306 | |||
307 | |||
308 | # Define all object files. |
||
309 | OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) |
||
310 | |||
311 | # Define all listing files. |
||
312 | LST = $(SRC:.c=.lst) $(ASRC:.S=.lst) |
||
313 | |||
314 | |||
315 | # Compiler flags to generate dependency files. |
||
316 | GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d |
||
317 | |||
318 | |||
319 | # Combine all necessary flags and optional flags. |
||
320 | # Add target processor to flags. |
||
321 | ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) |
||
322 | ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) |
||
323 | |||
324 | |||
325 | |||
326 | ############################################################ |
||
327 | # May 25, 2010 <MLS> Adding 1280 support |
||
328 | mega1280: MCU = atmega1280 |
||
329 | mega1280: F_CPU = 16000000 |
||
330 | mega1280: BOOTLOADER_ADDRESS = 1E000 |
||
331 | mega1280: CFLAGS += -D_MEGA_BOARD_ |
||
332 | mega1280: begin gccversion sizebefore build sizeafter end |
||
333 | mv $(TARGET).hex stk500boot_v2_mega1280.hex |
||
334 | |||
335 | |||
336 | ############################################################ |
||
337 | # Jul 6, 2010 <MLS> Adding 2560 support |
||
338 | mega2560: MCU = atmega2560 |
||
339 | mega2560: F_CPU = 16000000 |
||
340 | mega2560: BOOTLOADER_ADDRESS = 3E000 |
||
341 | mega2560: CFLAGS += -D_MEGA_BOARD_ |
||
342 | mega2560: begin gccversion sizebefore build sizeafter end |
||
343 | mv $(TARGET).hex stk500boot_v2_mega2560.hex |
||
344 | |||
345 | |||
346 | ############################################################ |
||
347 | #Initial config on Amber128 board |
||
348 | # avrdude: Device signature = 0x1e9702 |
||
349 | # avrdude: safemode: lfuse reads as 8F |
||
350 | # avrdude: safemode: hfuse reads as CB |
||
351 | # avrdude: safemode: efuse reads as FF |
||
352 | # Jul 17, 2010 <MLS> Adding 128 support |
||
353 | ############################################################ |
||
354 | amber128: MCU = atmega128 |
||
355 | #amber128: F_CPU = 16000000 |
||
356 | amber128: F_CPU = 14745600 |
||
357 | amber128: BOOTLOADER_ADDRESS = 1E000 |
||
358 | amber128: CFLAGS += -D_BOARD_AMBER128_ |
||
359 | amber128: begin gccversion sizebefore build sizeafter end |
||
360 | mv $(TARGET).hex stk500boot_v2_amber128.hex |
||
361 | |||
362 | ############################################################ |
||
363 | # Aug 23, 2010 <MLS> Adding atmega2561 support |
||
364 | m2561: MCU = atmega2561 |
||
365 | m2561: F_CPU = 8000000 |
||
366 | m2561: BOOTLOADER_ADDRESS = 3E000 |
||
367 | m2561: CFLAGS += -D_ANDROID_2561_ -DBAUDRATE=57600 |
||
368 | m2561: begin gccversion sizebefore build sizeafter end |
||
369 | mv $(TARGET).hex stk500boot_v2_android2561.hex |
||
370 | |||
371 | |||
372 | ############################################################ |
||
373 | # avrdude: Device signature = 0x1e9801 |
||
374 | # avrdude: safemode: lfuse reads as EC |
||
375 | # avrdude: safemode: hfuse reads as 18 |
||
376 | # avrdude: safemode: efuse reads as FD |
||
377 | # Aug 23, 2010 <MLS> Adding cerebot 2560 @ 8mhz |
||
378 | #avrdude -P usb -c usbtiny -p m2560 -v -U flash:w:/Arduino/WiringBootV2_upd1/stk500boot_v2_cerebotplus.hex |
||
379 | ############################################################ |
||
380 | cerebot: MCU = atmega2560 |
||
381 | cerebot: F_CPU = 8000000 |
||
382 | cerebot: BOOTLOADER_ADDRESS = 3E000 |
||
383 | cerebot: CFLAGS += -D_CEREBOTPLUS_BOARD_ -DBAUDRATE=38400 -DUART_BAUDRATE_DOUBLE_SPEED=1 |
||
384 | cerebot: begin gccversion sizebefore build sizeafter end |
||
385 | mv $(TARGET).hex stk500boot_v2_cerebotplus.hex |
||
386 | |||
387 | |||
388 | ############################################################ |
||
389 | # Aug 23, 2010 <MLS> Adding atmega2561 support |
||
390 | penguino: MCU = atmega32 |
||
391 | penguino: F_CPU = 16000000 |
||
392 | penguino: BOOTLOADER_ADDRESS = 7800 |
||
393 | penguino: CFLAGS += -D_PENGUINO_ -DBAUDRATE=57600 |
||
394 | penguino: begin gccversion sizebefore build sizeafter end |
||
395 | mv $(TARGET).hex stk500boot_v2_penguino.hex |
||
396 | |||
397 | |||
398 | # Default target. |
||
399 | all: begin gccversion sizebefore build sizeafter end |
||
400 | |||
401 | build: elf hex eep lss sym |
||
402 | #build: hex eep lss sym |
||
403 | |||
404 | elf: $(TARGET).elf |
||
405 | hex: $(TARGET).hex |
||
406 | eep: $(TARGET).eep |
||
407 | lss: $(TARGET).lss |
||
408 | sym: $(TARGET).sym |
||
409 | |||
410 | |||
411 | |||
412 | # Eye candy. |
||
413 | # AVR Studio 3.x does not check make's exit code but relies on |
||
414 | # the following magic strings to be generated by the compile job. |
||
415 | begin: |
||
416 | @echo |
||
417 | @echo $(MSG_BEGIN) |
||
418 | |||
419 | end: |
||
420 | @echo $(MSG_END) |
||
421 | @echo |
||
422 | |||
423 | |||
424 | # Display size of file. |
||
425 | HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex |
||
426 | ELFSIZE = $(SIZE) --format=avr --mcu=$(MCU) $(TARGET).elf |
||
427 | |||
428 | sizebefore: |
||
429 | @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ |
||
430 | 2>/dev/null; echo; fi |
||
431 | |||
432 | sizeafter: |
||
433 | @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ |
||
434 | 2>/dev/null; echo; fi |
||
435 | |||
436 | |||
437 | |||
438 | # Display compiler version information. |
||
439 | gccversion : |
||
440 | @$(CC) --version |
||
441 | |||
442 | |||
443 | |||
444 | # Program the device. |
||
445 | program: $(TARGET).hex $(TARGET).eep |
||
446 | $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) |
||
447 | |||
448 | |||
449 | # Generate avr-gdb config/init file which does the following: |
||
450 | # define the reset signal, load the target file, connect to target, and set |
||
451 | # a breakpoint at main(). |
||
452 | gdb-config: |
||
453 | @$(REMOVE) $(GDBINIT_FILE) |
||
454 | @echo define reset >> $(GDBINIT_FILE) |
||
455 | @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) |
||
456 | @echo end >> $(GDBINIT_FILE) |
||
457 | @echo file $(TARGET).elf >> $(GDBINIT_FILE) |
||
458 | @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) |
||
459 | ifeq ($(DEBUG_BACKEND),simulavr) |
||
460 | @echo load >> $(GDBINIT_FILE) |
||
461 | endif |
||
462 | @echo break main >> $(GDBINIT_FILE) |
||
463 | |||
464 | debug: gdb-config $(TARGET).elf |
||
465 | ifeq ($(DEBUG_BACKEND), avarice) |
||
466 | @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. |
||
467 | @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ |
||
468 | $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) |
||
469 | @$(WINSHELL) /c pause |
||
470 | |||
471 | else |
||
472 | @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ |
||
473 | $(DEBUG_MFREQ) --port $(DEBUG_PORT) |
||
474 | endif |
||
475 | @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) |
||
476 | |||
477 | |||
478 | |||
479 | |||
480 | # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. |
||
481 | COFFCONVERT=$(OBJCOPY) --debugging \ |
||
482 | --change-section-address .data-0x800000 \ |
||
483 | --change-section-address .bss-0x800000 \ |
||
484 | --change-section-address .noinit-0x800000 \ |
||
485 | --change-section-address .eeprom-0x810000 |
||
486 | |||
487 | |||
488 | |||
489 | coff: $(TARGET).elf |
||
490 | @echo |
||
491 | @echo $(MSG_COFF) $(TARGET).cof |
||
492 | $(COFFCONVERT) -O coff-avr $< $(TARGET).cof |
||
493 | |||
494 | |||
495 | extcoff: $(TARGET).elf |
||
496 | @echo |
||
497 | @echo $(MSG_EXTENDED_COFF) $(TARGET).cof |
||
498 | $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof |
||
499 | |||
500 | |||
501 | # Create final output files (.hex, .eep) from ELF output file. |
||
502 | %.hex: %.elf |
||
503 | @echo |
||
504 | @echo $(MSG_FLASH) $@ |
||
505 | $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ |
||
506 | |||
507 | %.eep: %.elf |
||
508 | @echo |
||
509 | @echo $(MSG_EEPROM) $@ |
||
510 | -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ |
||
511 | --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ |
||
512 | |||
513 | # Create extended listing file from ELF output file. |
||
514 | %.lss: %.elf |
||
515 | @echo |
||
516 | @echo $(MSG_EXTENDED_LISTING) $@ |
||
517 | $(OBJDUMP) -h -S $< > $@ |
||
518 | |||
519 | # Create a symbol table from ELF output file. |
||
520 | %.sym: %.elf |
||
521 | @echo |
||
522 | @echo $(MSG_SYMBOL_TABLE) $@ |
||
523 | $(NM) -n $< > $@ |
||
524 | |||
525 | |||
526 | |||
527 | # Link: create ELF output file from object files. |
||
528 | .SECONDARY : $(TARGET).elf |
||
529 | .PRECIOUS : $(OBJ) |
||
530 | %.elf: $(OBJ) |
||
531 | @echo |
||
532 | @echo $(MSG_LINKING) $@ |
||
533 | $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) |
||
534 | |||
535 | |||
536 | # Compile: create object files from C source files. |
||
537 | %.o : %.c |
||
538 | @echo |
||
539 | @echo $(MSG_COMPILING) $< |
||
540 | $(CC) -c $(ALL_CFLAGS) $< -o $@ |
||
541 | |||
542 | |||
543 | # Compile: create assembler files from C source files. |
||
544 | %.s : %.c |
||
545 | $(CC) -S $(ALL_CFLAGS) $< -o $@ |
||
546 | |||
547 | |||
548 | # Assemble: create object files from assembler source files. |
||
549 | %.o : %.S |
||
550 | @echo |
||
551 | @echo $(MSG_ASSEMBLING) $< |
||
552 | $(CC) -c $(ALL_ASFLAGS) $< -o $@ |
||
553 | |||
554 | # Create preprocessed source for use in sending a bug report. |
||
555 | %.i : %.c |
||
556 | $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ |
||
557 | |||
558 | |||
559 | # Target: clean project. |
||
560 | clean: begin clean_list end |
||
561 | |||
562 | clean_list : |
||
563 | @echo |
||
564 | @echo $(MSG_CLEANING) |
||
565 | $(REMOVE) *.hex |
||
566 | $(REMOVE) *.eep |
||
567 | $(REMOVE) *.cof |
||
568 | $(REMOVE) *.elf |
||
569 | $(REMOVE) *.map |
||
570 | $(REMOVE) *.sym |
||
571 | $(REMOVE) *.lss |
||
572 | $(REMOVE) $(OBJ) |
||
573 | $(REMOVE) $(LST) |
||
574 | $(REMOVE) $(SRC:.c=.s) |
||
575 | $(REMOVE) $(SRC:.c=.d) |
||
576 | $(REMOVE) .dep/* |
||
577 | |||
578 | |||
579 | |||
580 | # Include the dependency files. |
||
581 | -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) |
||
582 | |||
583 | |||
584 | # Listing of phony targets. |
||
585 | .PHONY : all begin finish end sizebefore sizeafter gccversion \ |
||
586 | build elf hex eep lss sym coff extcoff \ |
||
587 | clean clean_list program debug gdb-config |
||
588 |