2 # Hey Emacs, this is a -*- makefile -*-
\r
3 #----------------------------------------------------------------------------
\r
4 # WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
\r
5 # >> Modified for use with the LUFA project. <<
\r
7 # Released to the Public Domain
\r
9 # Additional material for this makefile was written by:
\r
22 #----------------------------------------------------------------------------
\r
25 # make all = Make software.
\r
27 # make clean = Clean out built project files.
\r
29 # make coff = Convert ELF to AVR COFF.
\r
31 # make extcoff = Convert ELF to AVR Extended COFF.
\r
33 # make program = Download the hex file to the device, using avrdude.
\r
34 # Please customize the avrdude settings below first!
\r
36 # make dfu = Download the hex file to the device, using dfu-programmer (must
\r
37 # have dfu-programmer installed).
\r
39 # make flip = Download the hex file to the device, using Atmel FLIP (must
\r
40 # have Atmel FLIP installed).
\r
42 # make dfu-ee = Download the eeprom file to the device, using dfu-programmer
\r
43 # (must have dfu-programmer installed).
\r
45 # make flip-ee = Download the eeprom file to the device, using Atmel FLIP
\r
46 # (must have Atmel FLIP installed).
\r
48 # make doxygen = Generate DoxyGen documentation for the project (must have
\r
49 # DoxyGen installed)
\r
51 # make debug = Start either simulavr or avarice as specified for debugging,
\r
52 # with avr-gdb or avr-insight as the front end for debugging.
\r
54 # make filename.s = Just compile filename.c into the assembler code only.
\r
56 # make filename.i = Create a preprocessed source file for use in submitting
\r
57 # bug reports to the GCC project.
\r
59 # To rebuild project do "make clean" then "make all".
\r
60 #----------------------------------------------------------------------------
\r
70 # Target architecture (see library "Board Types" documentation).
\r
74 # Target board (see library "Board Types" documentation, NONE for projects not requiring
\r
75 # LUFA board drivers). If USER is selected, put custom board drivers in a directory called
\r
76 # "Board" inside the application directory.
\r
80 # Processor frequency.
\r
81 # This will define a symbol, F_CPU, in all source code files equal to the
\r
82 # processor frequency in Hz. You can then use this symbol in your source code to
\r
83 # calculate timings. Do NOT tack on a 'UL' at the end, this will be done
\r
84 # automatically to create a 32-bit value in your source code.
\r
86 # This will be an integer division of F_USB below, as it is sourced by
\r
87 # F_USB after it has run through any CPU prescalers. Note that this value
\r
88 # does not *change* the processor frequency - it should merely be updated to
\r
89 # reflect the processor speed set externally so that the code can use accurate
\r
94 # Input clock frequency.
\r
95 # This will define a symbol, F_USB, in all source code files equal to the
\r
96 # input clock frequency (before any prescaling is performed) in Hz. This value may
\r
97 # differ from F_CPU if prescaling is used on the latter, and is required as the
\r
98 # raw input clock is fed directly to the PLL sections of the AVR for high speed
\r
99 # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
\r
100 # at the end, this will be done automatically to create a 32-bit value in your
\r
103 # If no clock division is performed on the input clock inside the AVR (via the
\r
104 # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
\r
108 # Output format. (can be srec, ihex, binary)
\r
112 # Target file name (without extension).
\r
113 TARGET = DualVirtualSerial
\r
116 # Object files directory
\r
117 # To put object files in current directory, use a dot (.), do NOT make
\r
118 # this an empty or blank macro!
\r
122 # Path to the LUFA library
\r
123 LUFA_PATH = ../../../..
\r
126 # LUFA library compile-time options and predefined tokens
\r
127 LUFA_OPTS = -D USB_DEVICE_ONLY
\r
128 LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
\r
129 LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
\r
130 LUFA_OPTS += -D USE_FLASH_DESCRIPTORS
\r
131 LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
\r
134 # Create the LUFA source path variables by including the LUFA root makefile
\r
135 include $(LUFA_PATH)/LUFA/makefile
\r
137 ifneq ($(USE_USB),)
\r
142 $(LUFA_SRC_USBCLASS) \
\r
143 DualVirtualSerial.c
\r
146 # List C source files here. (C dependencies are automatically generated.)
\r
149 cirbuf_add_buf_head.c \
\r
150 cirbuf_add_buf_tail.c \
\r
151 cirbuf_add_head.c \
\r
152 cirbuf_add_tail.c \
\r
155 cirbuf_del_buf_head.c \
\r
156 cirbuf_del_buf_tail.c \
\r
157 cirbuf_del_head.c \
\r
158 cirbuf_del_tail.c \
\r
159 cirbuf_get_buf_head.c \
\r
160 cirbuf_get_buf_tail.c \
\r
161 cirbuf_get_head.c \
\r
162 cirbuf_get_tail.c \
\r
175 scheduler_interrupt.c \
\r
176 scheduler_stats.c \
\r
182 uart_recv_nowait.c \
\r
184 uart_send_nowait.c \
\r
197 timer0_prescaler.c \
\r
198 timer0_register_OC_at_tics.c \
\r
199 timer0_register_OC_in_us.c \
\r
200 timer0_register_OV.c \
\r
201 timer0_startstop.c \
\r
203 timer1_prescaler.c \
\r
204 timer1_register_OC_at_tics.c \
\r
205 timer1_register_OC_in_us.c \
\r
206 timer1_register_OV.c \
\r
207 timer1_startstop.c \
\r
209 timer2_prescaler.c \
\r
210 timer2_register_OC_at_tics.c \
\r
211 timer2_register_OC_in_us.c \
\r
212 timer2_register_OV.c \
\r
213 timer2_startstop.c \
\r
215 timer3_prescaler.c \
\r
216 timer3_register_OC_at_tics.c \
\r
217 timer3_register_OC_in_us.c \
\r
218 timer3_register_OV.c \
\r
219 timer3_startstop.c \
\r
221 timer4_prescaler.c \
\r
222 timer4_register_OC_at_tics.c \
\r
223 timer4_register_OC_in_us.c \
\r
224 timer4_register_OV.c \
\r
225 timer4_startstop.c \
\r
227 timer5_prescaler.c \
\r
228 timer5_register_OC_at_tics.c \
\r
229 timer5_register_OC_in_us.c \
\r
230 timer5_register_OV.c \
\r
231 timer5_startstop.c \
\r
232 timer_conf_check.c \
\r
242 # List C++ source files here. (C dependencies are automatically generated.)
\r
246 # List Assembler source files here.
\r
247 # Make them always end in a capital .S. Files ending in a lowercase .s
\r
248 # will not be considered source files but generated files (assembler
\r
249 # output from the compiler), and will be deleted upon "make clean"!
\r
250 # Even though the DOS/Win* filesystem matches both .s and .S the same,
\r
251 # it will preserve the spelling of the filenames, and gcc itself does
\r
252 # care about how the name is spelled on its command-line.
\r
256 # Optimization level, can be [0, 1, 2, 3, s].
\r
257 # 0 = turn off optimization. s = optimize for size.
\r
258 # (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
\r
262 # Debugging format.
\r
263 # Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
\r
264 # AVR Studio 4.10 requires dwarf-2.
\r
265 # AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
\r
269 # List any extra directories to look for include files here.
\r
270 # Each directory must be seperated by a space.
\r
271 # Use forward slashes for directory separators.
\r
272 # For a directory that has spaces, enclose it in quotes.
\r
273 EXTRAINCDIRS = $(LUFA_PATH)/
\r
276 # Compiler flag to set the C Standard level.
\r
278 # gnu89 = c89 plus GCC extensions
\r
279 # c99 = ISO C99 standard (not yet fully implemented)
\r
280 # gnu99 = c99 plus GCC extensions
\r
281 CSTANDARD = -std=c99
\r
284 # Place -D or -U options here for C sources
\r
285 CDEFS = -DF_CPU=$(F_CPU)UL
\r
286 CDEFS += -DF_USB=$(F_USB)UL
\r
287 CDEFS += -DBOARD=BOARD_$(BOARD) -DARCH=ARCH_$(ARCH)
\r
288 CDEFS += $(LUFA_OPTS)
\r
291 # Place -D or -U options here for ASM sources
\r
292 ADEFS = -DF_CPU=$(F_CPU)
\r
293 ADEFS += -DF_USB=$(F_USB)UL
\r
294 ADEFS += -DBOARD=BOARD_$(BOARD) -DARCH=ARCH_$(ARCH)
\r
295 ADEFS += $(LUFA_OPTS)
\r
297 # Place -D or -U options here for C++ sources
\r
298 CPPDEFS = -DF_CPU=$(F_CPU)UL
\r
299 CPPDEFS += -DF_USB=$(F_USB)UL
\r
300 CPPDEFS += -DBOARD=BOARD_$(BOARD) -DARCH=ARCH_$(ARCH)
\r
301 CPPDEFS += $(LUFA_OPTS)
\r
302 #CPPDEFS += -D__STDC_LIMIT_MACROS
\r
303 #CPPDEFS += -D__STDC_CONSTANT_MACROS
\r
307 #---------------- Compiler Options C ----------------
\r
308 # -g*: generate debugging information
\r
309 # -O*: optimization level
\r
310 # -f...: tuning, see GCC manual and avr-libc documentation
\r
311 # -Wall...: warning level
\r
312 # -Wa,...: tell GCC to pass this to the assembler.
\r
313 # -adhlns...: create assembler listing
\r
314 CFLAGS = -g$(DEBUG)
\r
317 CFLAGS += -funsigned-char
\r
318 CFLAGS += -funsigned-bitfields
\r
319 CFLAGS += -ffunction-sections
\r
320 CFLAGS += -fno-inline-small-functions
\r
321 CFLAGS += -fpack-struct
\r
322 CFLAGS += -fshort-enums
\r
323 CFLAGS += -fno-strict-aliasing
\r
324 CFLAGS += -Wall -Werror
\r
325 CFLAGS += -Wstrict-prototypes
\r
326 CFLAGS += -ffreestanding
\r
327 #CFLAGS += -mshort-calls
\r
328 #CFLAGS += -fno-unit-at-a-time
\r
330 #CFLAGS += -Wunreachable-code
\r
331 #CFLAGS += -Wsign-compare
\r
332 CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst)
\r
333 CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
\r
334 CFLAGS += $(CSTANDARD)
\r
335 CFLAGS += -std=gnu99
\r
336 ifneq ($(USE_USB),)
\r
337 CFLAGS += -DUSE_USB
\r
341 #---------------- Compiler Options C++ ----------------
\r
342 # -g*: generate debugging information
\r
343 # -O*: optimization level
\r
344 # -f...: tuning, see GCC manual and avr-libc documentation
\r
345 # -Wall...: warning level
\r
346 # -Wa,...: tell GCC to pass this to the assembler.
\r
347 # -adhlns...: create assembler listing
\r
348 CPPFLAGS = -g$(DEBUG)
\r
349 CPPFLAGS += $(CPPDEFS)
\r
350 CPPFLAGS += -O$(OPT)
\r
351 CPPFLAGS += -funsigned-char
\r
352 CPPFLAGS += -funsigned-bitfields
\r
353 CPPFLAGS += -fpack-struct
\r
354 CPPFLAGS += -fshort-enums
\r
355 CPPFLAGS += -fno-exceptions
\r
357 CPPFLAGS += -Wundef
\r
358 #CPPFLAGS += -mshort-calls
\r
359 #CPPFLAGS += -fno-unit-at-a-time
\r
360 #CPPFLAGS += -Wstrict-prototypes
\r
361 #CPPFLAGS += -Wunreachable-code
\r
362 #CPPFLAGS += -Wsign-compare
\r
363 CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst)
\r
364 CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
\r
365 #CPPFLAGS += $(CSTANDARD)
\r
368 #---------------- Assembler Options ----------------
\r
369 # -Wa,...: tell GCC to pass this to the assembler.
\r
370 # -adhlns: create listing
\r
371 # -gstabs: have the assembler create line number information; note that
\r
372 # for use in COFF files, additional information about filenames
\r
373 # and function names needs to be present in the assembler source
\r
374 # files -- see avr-libc docs [FIXME: not yet described there]
\r
375 # -listing-cont-lines: Sets the maximum number of continuation lines of hex
\r
376 # dump that will be displayed for a given single line of source input.
\r
377 ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
\r
380 #---------------- Library Options ----------------
\r
381 # Minimalistic printf version
\r
382 PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
\r
384 # Floating point printf version (requires MATH_LIB = -lm below)
\r
385 PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
\r
387 # If this is left blank, then it will use the Standard printf version.
\r
389 #PRINTF_LIB = $(PRINTF_LIB_MIN)
\r
390 #PRINTF_LIB = $(PRINTF_LIB_FLOAT)
\r
393 # Minimalistic scanf version
\r
394 SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
\r
396 # Floating point + %[ scanf version (requires MATH_LIB = -lm below)
\r
397 SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
\r
399 # If this is left blank, then it will use the Standard scanf version.
\r
401 #SCANF_LIB = $(SCANF_LIB_MIN)
\r
402 #SCANF_LIB = $(SCANF_LIB_FLOAT)
\r
408 # List any extra directories to look for libraries here.
\r
409 # Each directory must be seperated by a space.
\r
410 # Use forward slashes for directory separators.
\r
411 # For a directory that has spaces, enclose it in quotes.
\r
416 #---------------- External Memory Options ----------------
\r
418 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
\r
419 # used for variables (.data/.bss) and heap (malloc()).
\r
420 #EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
\r
422 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
\r
423 # only used for heap (malloc()).
\r
424 #EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
\r
430 #---------------- Linker Options ----------------
\r
431 # -Wl,...: tell GCC to pass this to linker.
\r
432 # -Map: create map file
\r
433 # --cref: add cross reference to map file
\r
434 LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
\r
435 LDFLAGS += -Wl,--relax
\r
436 LDFLAGS += -Wl,--gc-sections
\r
437 LDFLAGS += $(EXTMEMOPTS)
\r
438 LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
\r
439 LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
\r
441 LDFLAGS = -T avr6.x
\r
445 #---------------- Programming Options (avrdude) ----------------
\r
447 # Programming hardware
\r
448 # Type: avrdude -c ?
\r
449 # to get a full listing.
\r
451 AVRDUDE_PROGRAMMER = jtagmkII
\r
453 # com1 = serial port. Use lpt1 to connect to parallel port.
\r
456 AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
\r
457 #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
\r
460 # Uncomment the following if you want avrdude's erase cycle counter.
\r
461 # Note that this counter needs to be initialized first using -Yn,
\r
462 # see avrdude manual.
\r
463 #AVRDUDE_ERASE_COUNTER = -y
\r
465 # Uncomment the following if you do /not/ wish a verification to be
\r
466 # performed after programming the device.
\r
467 #AVRDUDE_NO_VERIFY = -V
\r
469 # Increase verbosity level. Please use this when submitting bug
\r
470 # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
\r
471 # to submit bug reports.
\r
472 #AVRDUDE_VERBOSE = -v -v
\r
474 AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
\r
475 AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
\r
476 AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
\r
477 AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
\r
481 #---------------- Debugging Options ----------------
\r
483 # For simulavr only - target MCU frequency.
\r
484 DEBUG_MFREQ = $(F_CPU)
\r
486 # Set the DEBUG_UI to either gdb or insight.
\r
490 # Set the debugging back-end to either avarice, simulavr.
\r
491 DEBUG_BACKEND = avarice
\r
492 #DEBUG_BACKEND = simulavr
\r
494 # GDB Init Filename.
\r
495 GDBINIT_FILE = __avr_gdbinit
\r
497 # When using avarice settings for the JTAG
\r
498 JTAG_DEV = /dev/com1
\r
500 # Debugging port used to communicate between GDB / avarice / simulavr.
\r
503 # Debugging host used to communicate between GDB / avarice / simulavr, normally
\r
504 # just set to localhost unless doing some sort of crazy debugging when
\r
505 # avarice is running on a different computer.
\r
506 DEBUG_HOST = localhost
\r
510 #============================================================================
\r
513 # Define programs and commands.
\r
516 OBJCOPY = avr-objcopy
\r
517 OBJDUMP = avr-objdump
\r
530 MSG_ERRORS_NONE = Errors: none
\r
531 MSG_BEGIN = -------- begin --------
\r
532 MSG_END = -------- end --------
\r
533 MSG_SIZE_BEFORE = Size before:
\r
534 MSG_SIZE_AFTER = Size after:
\r
535 MSG_COFF = Converting to AVR COFF:
\r
536 MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
\r
537 MSG_FLASH = Creating load file for Flash:
\r
538 MSG_EEPROM = Creating load file for EEPROM:
\r
539 MSG_EXTENDED_LISTING = Creating Extended Listing:
\r
540 MSG_SYMBOL_TABLE = Creating Symbol Table:
\r
541 MSG_LINKING = Linking:
\r
542 MSG_COMPILING = Compiling C:
\r
543 MSG_COMPILING_CPP = Compiling C++:
\r
544 MSG_ASSEMBLING = Assembling:
\r
545 MSG_CLEANING = Cleaning project:
\r
546 MSG_CREATING_LIBRARY = Creating library:
\r
551 # Define all object files.
\r
552 OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
\r
554 # Define all listing files.
\r
555 LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
\r
558 # Compiler flags to generate dependency files.
\r
559 GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
\r
562 # Combine all necessary flags and optional flags.
\r
563 # Add target processor to flags.
\r
564 ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
\r
565 ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS)
\r
566 ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
\r
573 all: begin gccversion sizebefore build sizeafter end
\r
575 # Change the build target to build a HEX file or a library.
\r
576 build: elf hex eep lss sym
\r
585 LIBNAME=lib$(TARGET).a
\r
591 # AVR Studio 3.x does not check make's exit code but relies on
\r
592 # the following magic strings to be generated by the compile job.
\r
602 # Display size of file.
\r
603 HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
\r
604 ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf
\r
605 MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) )
\r
606 FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr )
\r
610 @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
\r
611 2>/dev/null; echo; fi
\r
614 @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
\r
615 2>/dev/null; echo; fi
\r
619 # Display compiler version information.
\r
624 # Program the device.
\r
625 program: $(TARGET).hex $(TARGET).eep
\r
626 $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
\r
628 flip: $(TARGET).hex
\r
629 batchisp -hardware usb -device $(MCU) -operation erase f
\r
630 batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program
\r
631 batchisp -hardware usb -device $(MCU) -operation start reset 0
\r
634 dfu-programmer $(MCU) erase
\r
635 dfu-programmer $(MCU) flash $(TARGET).hex
\r
636 dfu-programmer $(MCU) reset
\r
638 flip-ee: $(TARGET).hex $(TARGET).eep
\r
639 $(COPY) $(TARGET).eep $(TARGET)eep.hex
\r
640 batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase
\r
641 batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(TARGET)eep.hex program
\r
642 batchisp -hardware usb -device $(MCU) -operation start reset 0
\r
643 $(REMOVE) $(TARGET)eep.hex
\r
645 dfu-ee: $(TARGET).hex $(TARGET).eep
\r
646 dfu-programmer $(MCU) eeprom-flash $(TARGET).eep
\r
647 dfu-programmer $(MCU) reset
\r
650 # Generate avr-gdb config/init file which does the following:
\r
651 # define the reset signal, load the target file, connect to target, and set
\r
652 # a breakpoint at main().
\r
654 @$(REMOVE) $(GDBINIT_FILE)
\r
655 @echo define reset >> $(GDBINIT_FILE)
\r
656 @echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
\r
657 @echo end >> $(GDBINIT_FILE)
\r
658 @echo file $(TARGET).elf >> $(GDBINIT_FILE)
\r
659 @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE)
\r
660 ifeq ($(DEBUG_BACKEND),simulavr)
\r
661 @echo load >> $(GDBINIT_FILE)
\r
663 @echo break main >> $(GDBINIT_FILE)
\r
665 debug: gdb-config $(TARGET).elf
\r
666 ifeq ($(DEBUG_BACKEND), avarice)
\r
667 @echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
\r
668 @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
\r
669 $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
\r
670 @$(WINSHELL) /c pause
\r
673 @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
\r
674 $(DEBUG_MFREQ) --port $(DEBUG_PORT)
\r
676 @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
\r
681 # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
\r
682 COFFCONVERT = $(OBJCOPY) --debugging
\r
683 COFFCONVERT += --change-section-address .data-0x800000
\r
684 COFFCONVERT += --change-section-address .bss-0x800000
\r
685 COFFCONVERT += --change-section-address .noinit-0x800000
\r
686 COFFCONVERT += --change-section-address .eeprom-0x810000
\r
690 coff: $(TARGET).elf
\r
692 @echo $(MSG_COFF) $(TARGET).cof
\r
693 $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
\r
696 extcoff: $(TARGET).elf
\r
698 @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
\r
699 $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
\r
703 # Create final output files (.hex, .eep) from ELF output file.
\r
706 @echo $(MSG_FLASH) $@
\r
707 $(OBJCOPY) -O binary -R .eeprom -R .fuse -R .lock $< $(TARGET).bin
\r
708 $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock $< $@
\r
712 @echo $(MSG_EEPROM) $@
\r
713 -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
\r
714 --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0
\r
716 # Create extended listing file from ELF output file.
\r
719 @echo $(MSG_EXTENDED_LISTING) $@
\r
720 $(OBJDUMP) -h -S -z $< > $@
\r
722 # Create a symbol table from ELF output file.
\r
725 @echo $(MSG_SYMBOL_TABLE) $@
\r
730 # Create library from object files.
\r
731 .SECONDARY : $(TARGET).a
\r
735 @echo $(MSG_CREATING_LIBRARY) $@
\r
739 # Link: create ELF output file from object files.
\r
740 .SECONDARY : $(TARGET).elf
\r
744 @echo $(MSG_LINKING) $@
\r
745 $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
\r
748 # Compile: create object files from C source files.
\r
749 $(OBJDIR)/%.o : %.c
\r
751 @echo $(MSG_COMPILING) $<
\r
752 $(CC) -c $(ALL_CFLAGS) $< -o $@
\r
755 # Compile: create object files from C++ source files.
\r
756 $(OBJDIR)/%.o : %.cpp
\r
758 @echo $(MSG_COMPILING_CPP) $<
\r
759 $(CC) -c $(ALL_CPPFLAGS) $< -o $@
\r
762 # Compile: create assembler files from C source files.
\r
764 $(CC) -S $(ALL_CFLAGS) $< -o $@
\r
767 # Compile: create assembler files from C++ source files.
\r
769 $(CC) -S $(ALL_CPPFLAGS) $< -o $@
\r
772 # Assemble: create object files from assembler source files.
\r
773 $(OBJDIR)/%.o : %.S
\r
775 @echo $(MSG_ASSEMBLING) $<
\r
776 $(CC) -c $(ALL_ASFLAGS) $< -o $@
\r
779 # Create preprocessed source for use in sending a bug report.
\r
781 $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
\r
784 # Target: clean project.
\r
785 clean: begin clean_list end
\r
789 @echo $(MSG_CLEANING)
\r
790 $(REMOVE) $(TARGET).hex
\r
791 $(REMOVE) $(TARGET).eep
\r
792 $(REMOVE) $(TARGET).cof
\r
793 $(REMOVE) $(TARGET).elf
\r
794 $(REMOVE) $(TARGET).map
\r
795 $(REMOVE) $(TARGET).sym
\r
796 $(REMOVE) $(TARGET).lss
\r
797 $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
\r
798 $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
\r
799 $(REMOVE) $(SRC:.c=.s)
\r
800 $(REMOVE) $(SRC:.c=.d)
\r
801 $(REMOVE) $(SRC:.c=.i)
\r
805 @echo Generating Project Documentation \($(TARGET)\)...
\r
806 @doxygen Doxygen.conf
\r
807 @echo Documentation Generation Complete.
\r
810 rm -rf Documentation
\r
813 @for f in $(SRC) $(CPPSRC) $(ASRC); do \
\r
814 if [ -f $$f ]; then \
\r
815 echo "Found Source File: $$f" ; \
\r
817 echo "Source File Not Found: $$f" ; \
\r
821 # Create object files directory
\r
822 $(shell mkdir $(OBJDIR) 2>/dev/null)
\r
825 # Include the dependency files.
\r
826 -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
\r
829 # Listing of phony targets.
\r
830 .PHONY : all begin finish end sizebefore sizeafter gccversion \
\r
831 build elf hex eep lss sym coff extcoff doxygen clean \
\r
832 clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
\r
833 debug gdb-config checksource
\r