Fix XPLAIN Dataflash and LED drivers.
[pub/USBasp.git] / Bootloaders / TeensyHID / makefile
index ea528fb..c7210f0 100644 (file)
 # make program = Download the hex file to the device, using avrdude.\r
 #                Please customize the avrdude settings below first!\r
 #\r
+# make dfu = Download the hex file to the device, using dfu-programmer (must\r
+#            have dfu-programmer installed).\r
+#\r
+# make flip = Download the hex file to the device, using Atmel FLIP (must\r
+#             have Atmel FLIP installed).\r
+#\r
+# make dfu-ee = Download the eeprom file to the device, using dfu-programmer\r
+#               (must have dfu-programmer installed).\r
+#\r
+# make flip-ee = Download the eeprom file to the device, using Atmel FLIP\r
+#                (must have Atmel FLIP installed).\r
+#\r
 # make doxygen = Generate DoxyGen documentation for the project (must have\r
 #                DoxyGen installed)\r
 #\r
 \r
 \r
 # MCU name\r
-MCU = at90usb162\r
+MCU = atmega32u4\r
 \r
 \r
 # Target board (see library "Board Types" documentation, USER or blank for projects not requiring\r
 # LUFA board drivers). If USER is selected, put custom board drivers in a directory called \r
 # "Board" inside the application directory.\r
-BOARD  = USBKEY\r
+BOARD  = \r
 \r
 \r
 # Processor frequency.\r
 #     This will define a symbol, F_CPU, in all source code files equal to the \r
-#     processor frequency. You can then use this symbol in your source code to \r
+#     processor frequency in Hz. You can then use this symbol in your source code to \r
 #     calculate timings. Do NOT tack on a 'UL' at the end, this will be done\r
 #     automatically to create a 32-bit value in your source code.\r
-#     Typical values are:\r
-#         F_CPU =  1000000\r
-#         F_CPU =  1843200\r
-#         F_CPU =  2000000\r
-#         F_CPU =  3686400\r
-#         F_CPU =  4000000\r
-#         F_CPU =  7372800\r
-#         F_CPU =  8000000\r
-#         F_CPU = 11059200\r
-#         F_CPU = 14745600\r
-#         F_CPU = 16000000\r
-#         F_CPU = 18432000\r
-#         F_CPU = 20000000\r
+#\r
+#     This will be an integer division of F_CLOCK below, as it is sourced by\r
+#     F_CLOCK after it has run through any CPU prescalers. Note that this value\r
+#     does not *change* the processor frequency - it should merely be updated to\r
+#     reflect the processor speed set externally so that the code can use accurate\r
+#     software delays.\r
 F_CPU = 16000000\r
 \r
 \r
 # Input clock frequency.\r
 #     This will define a symbol, F_CLOCK, in all source code files equal to the \r
-#     input clock frequency (before any prescaling is performed). This value may\r
+#     input clock frequency (before any prescaling is performed) in Hz. This value may\r
 #     differ from F_CPU if prescaling is used on the latter, and is required as the\r
 #     raw input clock is fed directly to the PLL sections of the AVR for high speed\r
 #     clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'\r
@@ -89,7 +94,11 @@ F_CPU = 16000000
 #\r
 #     If no clock division is performed on the input clock inside the AVR (via the\r
 #     CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.\r
-F_CLOCK = 16000000\r
+F_CLOCK = $(F_CPU)\r
+\r
+\r
+# Starting byte address of the bootloader\r
+BOOT_START = 0x7000\r
 \r
 \r
 # Output format. (can be srec, ihex, binary)\r
@@ -112,12 +121,14 @@ LUFA_PATH = ../..
 \r
 # LUFA library compile-time options\r
 LUFA_OPTS  = -D USB_DEVICE_ONLY\r
-LUFA_OPTS += -D USE_NONSTANDARD_DESCRIPTOR_NAMES\r
-LUFA_OPTS += -D CONTROL_ONLY_DEVICE\r
-LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8\r
-LUFA_OPTS += -D USE_SINGLE_DEVICE_CONFIGURATION\r
-LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"\r
+LUFA_OPTS += -D DEVICE_STATE_AS_GPIOR=0\r
+LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=64\r
+LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1\r
 LUFA_OPTS += -D USE_RAM_DESCRIPTORS\r
+LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"\r
+LUFA_OPTS += -D NO_INTERNAL_SERIAL\r
+LUFA_OPTS += -D NO_DEVICE_SELF_POWER\r
+LUFA_OPTS += -D NO_DEVICE_REMOTE_WAKEUP\r
 \r
 \r
 # List C source files here. (C dependencies are automatically generated.)\r
@@ -177,10 +188,6 @@ EXTRAINCDIRS = $(LUFA_PATH)/
 CSTANDARD = -std=gnu99\r
 \r
 \r
-# Starting byte address of the bootloader\r
-BOOT_START = 0xC000\r
-\r
-\r
 # Place -D or -U options here for C sources\r
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD) $(LUFA_OPTS)\r
 CDEFS += -DBOOT_START_ADDR=$(BOOT_START)UL\r
@@ -318,9 +325,9 @@ EXTMEMOPTS =
 #    -Map:      create map file\r
 #    --cref:    add cross reference to  map file\r
 LDFLAGS = -Wl,-Map=$(TARGET).map,--cref\r
+LDFLAGS += -Wl,--section-start=.text=$(BOOT_START)\r
 LDFLAGS += -Wl,--relax \r
 LDFLAGS += -Wl,--gc-sections\r
-LDFLAGS += -Wl,--section-start=.text=$(BOOT_START)\r
 LDFLAGS += $(EXTMEMOPTS)\r
 LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))\r
 LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)\r
@@ -457,7 +464,7 @@ ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
 \r
 \r
 # Default target.\r
-all: begin gccversion sizebefore build checkhooks checklibmode checkboard sizeafter end\r
+all: begin gccversion sizebefore build checkinvalidevents showliboptions showtarget sizeafter end\r
 \r
 # Change the build target to build a HEX file or a library.\r
 build: elf hex eep lss sym\r
@@ -500,38 +507,64 @@ sizeafter:
        @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \\r
        2>/dev/null; echo; fi\r
 \r
-checkhooks: build\r
-       @echo\r
-       @echo ------- Unhooked LUFA Events -------\r
-       @$(shell) (grep -s '^EVENT_.*LUFA/.*\\.o' $(TARGET).map | \\r
-                  cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \\r
-                          echo "(None)"\r
-       @echo ------------------------------------\r
+$(LUFA_PATH)/LUFA/LUFA_Events.lst:\r
+       @make -C $(LUFA_PATH)/LUFA/ LUFA_Events.lst\r
 \r
-checklibmode:\r
+checkinvalidevents: $(LUFA_PATH)/LUFA/LUFA_Events.lst\r
+       @echo\r
+       @echo Checking for invalid events...\r
+       @$(shell) avr-nm $(OBJ) | sed -n -e 's/^.*EVENT_/EVENT_/p' | \\r
+                        grep -F -v --file=$(LUFA_PATH)/LUFA/LUFA_Events.lst > InvalidEvents.tmp || true\r
+       @sed -n -e 's/^/  WARNING - INVALID EVENT NAME: /p' InvalidEvents.tmp\r
+       @if test -s InvalidEvents.tmp; then exit 1; fi\r
+       \r
+showliboptions:\r
        @echo\r
-       @echo ----------- Library Mode -----------\r
-       @$(shell) ($(CC) $(ALL_CFLAGS) -E -dM - < /dev/null \\r
-                 | grep 'USB_\(DEVICE\|HOST\)_ONLY' | cut -d' ' -f2 | grep ".*") \\r
-                 || echo "No specific mode (both device and host mode allowable)."\r
-       @echo ------------------------------------\r
+       @echo ---- Compile Time Library Options ----\r
+       @for i in $(LUFA_OPTS:-D%=%); do \\r
+               echo $$i; \\r
+       done\r
+       @echo --------------------------------------\r
 \r
-checkboard:\r
+showtarget:\r
        @echo\r
-       @echo ---------- Selected Board ----------\r
-       @echo Selected board model is $(BOARD).\r
-       @echo ------------------------------------\r
+       @echo --------- Target Information ---------\r
+       @echo AVR Model: $(MCU)\r
+       @echo Board:     $(BOARD)\r
+       @echo Clock:     $(F_CPU)Hz CPU, $(F_CLOCK)Hz Master\r
+       @echo --------------------------------------\r
        \r
+\r
 # Display compiler version information.\r
 gccversion : \r
        @$(CC) --version\r
 \r
 \r
-\r
 # Program the device.  \r
 program: $(TARGET).hex $(TARGET).eep\r
        $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)\r
 \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
+       batchisp -hardware usb -device $(MCU) -operation start reset 0\r
+\r
+dfu: $(TARGET).hex\r
+       dfu-programmer $(MCU) erase\r
+       dfu-programmer $(MCU) flash --debug 1 $(TARGET).hex\r
+       dfu-programmer $(MCU) reset\r
+\r
+flip-ee: $(TARGET).hex $(TARGET).eep\r
+       $(COPY) $(TARGET).eep $(TARGET)eep.hex\r
+       batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase\r
+       batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(TARGET)eep.hex program\r
+       batchisp -hardware usb -device $(MCU) -operation start reset 0\r
+       $(REMOVE) $(TARGET)eep.hex\r
+\r
+dfu-ee: $(TARGET).hex $(TARGET).eep\r
+       dfu-programmer $(MCU) flash-eeprom --debug 1 --suppress-bootloader-mem $(TARGET).eep\r
+       dfu-programmer $(MCU) reset\r
+\r
 \r
 # Generate avr-gdb config/init file which does the following:\r
 #     define the reset signal, load the target file, connect to target, and set \r
@@ -686,9 +719,9 @@ clean_list:
        $(REMOVE) $(SRC:.c=.s)\r
        $(REMOVE) $(SRC:.c=.d)\r
        $(REMOVE) $(SRC:.c=.i)\r
+       $(REMOVE) InvalidEvents.tmp\r
        $(REMOVEDIR) .dep\r
 \r
-\r
 doxygen:\r
        @echo Generating Project Documentation...\r
        @doxygen Doxygen.conf\r
@@ -706,8 +739,8 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
 \r
 \r
 # Listing of phony targets.\r
-.PHONY : all checkhooks checklibmode checkboard   \\r
-begin finish end sizebefore sizeafter gccversion  \\r
-build elf hex eep lss sym coff extcoff clean      \\r
-clean_list clean_binary program debug gdb-config  \\r
-doxygen
\ No newline at end of file
+.PHONY : all checkinvalidevents showliboptions    \\r
+showtarget begin finish end sizebefore sizeafter  \\r
+gccversion build elf hex eep lss sym coff extcoff \\r
+program dfu flip flip-ee dfu-ee clean debug       \\r
+clean_list clean_binary gdb-config doxygen
\ No newline at end of file