MCU = ### INSERT NAME OF MICROCONTROLLER MODEL HERE ###\r
\r
\r
-# Target architecture (see library "Board Types" documentation).\r
+# Targeted chip architecture (see library "Architectures" documentation)\r
ARCH = AVR8\r
\r
\r
\r
# Place -D or -U options here for C sources\r
CDEFS = -DF_CPU=$(F_CPU)UL\r
-CDEFS += -DF_CLOCK=$(F_CLOCK)UL\r
+CDEFS += -DF_USB=$(F_USB)UL\r
CDEFS += -DBOARD=BOARD_$(BOARD)\r
+CDEFS += -DARCH=ARCH_$(ARCH)\r
CDEFS += $(LUFA_OPTS)\r
\r
\r
# Place -D or -U options here for ASM sources\r
ADEFS = -DF_CPU=$(F_CPU)\r
-ADEFS += -DF_CLOCK=$(F_CLOCK)UL\r
+ADEFS += -DF_USB=$(F_USB)UL\r
ADEFS += -DBOARD=BOARD_$(BOARD)\r
+ADEFS += -DARCH=ARCH_$(ARCH)\r
ADEFS += $(LUFA_OPTS)\r
\r
# Place -D or -U options here for C++ sources\r
CPPDEFS = -DF_CPU=$(F_CPU)UL\r
-CPPDEFS += -DF_CLOCK=$(F_CLOCK)UL\r
+CPPDEFS += -DF_USB=$(F_USB)UL\r
CPPDEFS += -DBOARD=BOARD_$(BOARD)\r
+CPPDEFS += -DARCH=ARCH_$(ARCH)\r
CPPDEFS += $(LUFA_OPTS)\r
#CPPDEFS += -D__STDC_LIMIT_MACROS\r
#CPPDEFS += -D__STDC_CONSTANT_MACROS\r
CFLAGS += -fno-strict-aliasing\r
CFLAGS += -Wall\r
CFLAGS += -Wstrict-prototypes\r
-#CFLAGS += -mshort-calls\r
-#CFLAGS += -fno-unit-at-a-time\r
-#CFLAGS += -Wundef\r
-#CFLAGS += -Wunreachable-code\r
-#CFLAGS += -Wsign-compare\r
CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst)\r
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))\r
CFLAGS += $(CSTANDARD)\r
CPPFLAGS += -funsigned-bitfields\r
CPPFLAGS += -fpack-struct\r
CPPFLAGS += -fshort-enums\r
+CPPFLAGS += -ffunction-sections\r
+CPPFLAGS += -fno-strict-aliasing\r
CPPFLAGS += -fno-exceptions\r
CPPFLAGS += -Wall\r
CPPFLAGS += -Wundef\r
-#CPPFLAGS += -mshort-calls\r
-#CPPFLAGS += -fno-unit-at-a-time\r
-#CPPFLAGS += -Wstrict-prototypes\r
-#CPPFLAGS += -Wunreachable-code\r
-#CPPFLAGS += -Wsign-compare\r
CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst)\r
CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))\r
#CPPFLAGS += $(CSTANDARD)\r
%.hex: %.elf\r
@echo\r
@echo $(MSG_FLASH) $@\r
- $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock $< $@\r
+ $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature $< $@\r
\r
%.eep: %.elf\r
@echo\r
\r
\r
# Target board (see library "Board Types" documentation, NONE for projects not requiring\r
-# LUFA board drivers). If USER is selected, put custom board drivers in a directory called\r
+# LUFA board drivers). If USER is selected, put custom board drivers in a directory called \r
# "Board" inside the application directory.\r
BOARD = ### INSERT NAME OF BOARD HERE, OR NONE IF NO BOARD DRIVERS USED ###\r
\r
LUFA_PATH = ### INSERT PATH TO LUFA LIBRARY RELATIVE TO PROJECT DIRECTORY HERE ###\r
\r
\r
-# LUFA library compile-time options and predefined tokens\r
-LUFA_OPTS = ### INSERT LUFA COMPILE TIME TOKES HERE ###\r
+# LUFA library compile-time options and predefined tokens (add '-D' before each token)\r
+LUFA_OPTS = ### INSERT LUFA COMPILE TIME TOKES HERE ###\r
\r
\r
# Create the LUFA source path variables by including the LUFA root makefile\r
\r
\r
# List C++ source files here. (C dependencies are automatically generated.)\r
-CPPSRC =\r
+CPPSRC = \r
\r
\r
# List Assembler source files here.\r
# Even though the DOS/Win* filesystem matches both .s and .S the same,\r
# it will preserve the spelling of the filenames, and gcc itself does\r
# care about how the name is spelled on its command-line.\r
-ASRC = Exception.S\r
+ASRC =\r
\r
\r
-# Optimization level, can be [0, 1, 2, 3, s].\r
+# Optimization level, can be [0, 1, 2, 3, s]. \r
# 0 = turn off optimization. s = optimize for size.\r
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)\r
-OPT = 0\r
+OPT = s\r
\r
\r
# Debugging level.\r
CPPDEFS += -DBOARD=BOARD_$(BOARD)\r
CPPDEFS += -DARCH=ARCH_$(ARCH)\r
CPPDEFS += $(LUFA_OPTS)\r
-#CPPDEFS += -D__STDC_LIMIT_MACROS\r
-#CPPDEFS += -D__STDC_CONSTANT_MACROS\r
\r
\r
\r
CFLAGS += -funsigned-bitfields\r
CFLAGS += -ffunction-sections\r
CFLAGS += -fno-strict-aliasing\r
-CFLAGS += -masm-addr-pseudos\r
CFLAGS += -Wall\r
CFLAGS += -Wstrict-prototypes\r
+CFLAGS += -masm-addr-pseudos\r
CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst)\r
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))\r
CFLAGS += $(CSTANDARD)\r
# for use in COFF files, additional information about filenames\r
# and function names needs to be present in the assembler source\r
# files -- see avr-libc docs [FIXME: not yet described there]\r
-# -listing-cont-lines: Sets the maximum number of continuation lines of hex\r
+# -listing-cont-lines: Sets the maximum number of continuation lines of hex \r
# dump that will be displayed for a given single line of source input.\r
-ASFLAGS = -g3 $(ADEFS)\r
+ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100\r
\r
\r
#---------------- Linker Options ----------------\r
# -Map: create map file\r
# --cref: add cross reference to map file\r
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref\r
-LDFLAGS += -Wl,--gc-sections --rodata-writable\r
+LDFLAGS += -Wl,--relax \r
+LDFLAGS += -Wl,--gc-sections\r
+LDFLAGS += -Wl,--rodata-writable\r
LDFLAGS += -Wl,--direct-data\r
-#LDFLAGS += -T avr32elf_uc3b0256.x\r
+#LDFLAGS += -T linker_script.x\r
\r
\r
#============================================================================\r
MSG_ERRORS_NONE = Errors: none\r
MSG_BEGIN = -------- begin --------\r
MSG_END = -------- end --------\r
-MSG_SIZE_BEFORE = Size before:\r
+MSG_SIZE_BEFORE = Size before: \r
MSG_SIZE_AFTER = Size after:\r
MSG_COFF = Converting to AVR COFF:\r
MSG_FLASH = Creating load file for Flash:\r
\r
\r
# Define all object files.\r
-OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)\r
+OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) \r
\r
# Define all listing files.\r
-LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)\r
+LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) \r
\r
\r
# Compiler flags to generate dependency files.\r
\r
\r
# Display compiler version information.\r
-gccversion :\r
+gccversion : \r
@$(CC) --version\r
\r
\r
-# Program the device.\r
+# Program the device. \r
flip: $(TARGET).hex\r
batchisp -hardware usb -device $(MCU) -operation erase f\r
batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program\r
%.lss: %.elf\r
@echo\r
@echo $(MSG_EXTENDED_LISTING) $@\r
- $(OBJDUMP) -h -S $< > $@\r
+ $(OBJDUMP) -h -S -z $< > $@\r
\r
# Create a symbol table from ELF output file.\r
%.sym: %.elf\r
$(OBJDIR)/%.o : %.c\r
@echo\r
@echo $(MSG_COMPILING) $<\r
- $(CC) -c $(ALL_CFLAGS) $< -o $@\r
+ $(CC) -c $(ALL_CFLAGS) $< -o $@ \r
\r
\r
# Compile: create object files from C++ source files.\r
$(OBJDIR)/%.o : %.cpp\r
@echo\r
@echo $(MSG_COMPILING_CPP) $<\r
- $(CC) -c $(ALL_CPPFLAGS) $< -o $@\r
+ $(CC) -c $(ALL_CPPFLAGS) $< -o $@ \r
\r
\r
# Compile: create assembler files from C source files.\r
\r
# Create preprocessed source for use in sending a bug report.\r
%.i : %.c\r
- $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@\r
+ $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ \r
\r
\r
# Target: clean project.\r