+
+/* References to the binary EEPROM data linked in the AVR's FLASH memory space */
+extern const char InputEEData[];
+extern const char InputEEData_size_sym[];
+#define InputEEData_size ((int)InputEEData_size_sym)
+
+int main(void)
+{
+ /* Copy out the embedded EEPROM data from FLASH to EEPROM memory space */
+ for (uint16_t i = 0; i < InputEEData_size; i++)
+ eeprom_update_byte((uint8_t*)i, pgm_read_byte(&InputEEData[i]));
+
+ /* Infinite loop once complete */
+ for (;;);
+}
diff --git a/LUFA/Build/HID_EEPROM_Loader/makefile b/LUFA/Build/HID_EEPROM_Loader/makefile
new file mode 100644
index 0000000000..6cdd8cf0d6
--- /dev/null
+++ b/LUFA/Build/HID_EEPROM_Loader/makefile
@@ -0,0 +1,45 @@
+#
+# LUFA Library
+# Copyright (C) Dean Camera, 2012.
+#
+# dean [at] fourwalledcubicle [dot] com
+# www.lufa-lib.org
+#
+# --------------------------------------
+# LUFA Project Makefile.
+# --------------------------------------
+
+MCU = at90usb1287
+ARCH = AVR8
+F_CPU = 1000000
+F_USB = $(F_CPU)
+OPTIMIZATION = 0
+TARGET = HID_EEPROM_Loader
+SRC = $(TARGET).c
+LUFA_PATH = ../../../LUFA/
+CC_FLAGS =
+LD_FLAGS =
+OBJECT_FILES = InputEEData.o
+
+# Default target
+all: InputEEData.o hex
+
+.PHONY: InputEEData.o
+InputEEData.o: InputEEData.bin $(TARGET).o $(MAKEFILE_LIST)
+ @echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a object file \"$@\"
+ avr-objcopy -I binary -O elf32-avr -B avr$(shell avr-objdump -f $(TARGET).o | grep architecture | cut -d':' -f3 | cut -d',' -f1) \
+ --rename-section .data=.progmem.data,contents,alloc,readonly,data \
+ --redefine-sym _binary_$(basename $@)_bin_start=$(basename $@) \
+ --redefine-sym _binary_$(basename $@)_bin_size=$(basename $@)_size_sym \
+ $< $@
+
+# Include LUFA build script makefiles
+include $(LUFA_PATH)/Build/lufa.core.in
+include $(LUFA_PATH)/Build/lufa.sources.in
+include $(LUFA_PATH)/Build/lufa.build.in
+include $(LUFA_PATH)/Build/lufa.cppcheck.in
+include $(LUFA_PATH)/Build/lufa.doxygen.in
+include $(LUFA_PATH)/Build/lufa.dfu.in
+include $(LUFA_PATH)/Build/lufa.hid.in
+include $(LUFA_PATH)/Build/lufa.avrdude.in
+include $(LUFA_PATH)/Build/lufa.atprogram.in
diff --git a/LUFA/Build/lufa.build.in b/LUFA/Build/lufa.build.in
index 91c54f969c..e76a230332 100644
--- a/LUFA/Build/lufa.build.in
+++ b/LUFA/Build/lufa.build.in
@@ -9,7 +9,7 @@
LUFA_BUILD_MODULES += BUILD
LUFA_BUILD_TARGETS += size check-source symbol-sizes all lib elf hex lss clean mostlyclean
LUFA_BUILD_MANDATORY_VARS += TARGET ARCH MCU SRC F_USB LUFA_PATH
-LUFA_BUILD_OPTIONAL_VARS += BOARD OPTIMIZATION C_STANDARD CPP_STANDARD F_CPU C_FLAGS CPP_FLAGS ASM_FLAGS CC_FLAGS LD_FLAGS OBJDIR
+LUFA_BUILD_OPTIONAL_VARS += BOARD OPTIMIZATION C_STANDARD CPP_STANDARD F_CPU C_FLAGS CPP_FLAGS ASM_FLAGS CC_FLAGS LD_FLAGS OBJDIR OBJECT_FILES
LUFA_BUILD_PROVIDED_VARS +=
LUFA_BUILD_PROVIDED_MACROS +=
@@ -63,6 +63,7 @@ LUFA_BUILD_PROVIDED_MACROS +=
# OBJDIR - Directory for the output object and dependency
# files; if equal to ".", the output files will
# be generated in the same folder as the sources
+# OBJECT_FILES - Extra object files to link in to the binaries
#
# PROVIDED VARIABLES:
#
@@ -91,6 +92,7 @@ CPP_FLAGS ?=
ASM_FLAGS ?=
CC_FLAGS ?=
OBJDIR ?= .
+OBJECT_FILES ?=
# Sanity check user supplied values
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
@@ -141,7 +143,7 @@ ifneq ($(UNKNOWN_SOURCE),)
endif
# Convert input source filenames into a list of required output object files
-OBJECT_FILES := $(addsuffix .o, $(basename $(SRC)))
+OBJECT_FILES += $(addsuffix .o, $(basename $(SRC)))
ifneq ($(OBJDIR),.)
$(shell mkdir $(OBJDIR) 2>&1 > /dev/null)
VPATH += $(dir $(SRC))
diff --git a/LUFA/Build/lufa.hid.in b/LUFA/Build/lufa.hid.in
index 34d1e2b809..8fd246864a 100644
--- a/LUFA/Build/lufa.hid.in
+++ b/LUFA/Build/lufa.hid.in
@@ -7,7 +7,7 @@
#
LUFA_BUILD_MODULES += HID
-LUFA_BUILD_TARGETS += hid hid-teensy
+LUFA_BUILD_TARGETS += hid hid-ee hid-teensy hid-teensy-ee
LUFA_BUILD_MANDATORY_VARS += MCU TARGET
LUFA_BUILD_OPTIONAL_VARS +=
LUFA_BUILD_PROVIDED_VARS +=
@@ -24,8 +24,12 @@ LUFA_BUILD_PROVIDED_MACROS +=
#
# hid - Program FLASH into target via
# hid_bootloader_cli
+# hid-ee - Program EEPROM into target via a temporary
+# AVR application and hid_bootloader_cli
# hid-teensy - Program FLASH into target via
# teensy_loader_cli
+# hid-teensy-ee - Program EEPROM into target via a temporary
+# AVR application and teensy_loader_cli
#
# MANDATORY PARAMETERS:
#
@@ -57,14 +61,28 @@ $(call ERROR_IF_EMPTY, TARGET)
# Output Messages
MSG_HID_BOOTLOADER_CMD := ' [HID] :'
+MSG_OBJCPY_CMD := ' [OBJCPY] :'
+MSG_MAKE_CMD := ' [MAKE] :'
hid: $(TARGET).hex $(MAKEFILE_LIST)
@echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with hid_bootloader_cli using \"$<\"
hid_bootloader_cli -mmcu=$(MCU) -v $<
+hid-ee: $(TARGET).eep $(MAKEFILE_LIST)
+ @echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\"
+ avr-objcopy -I ihex -O binary $< $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/InputEEData.bin
+ @echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"
+ make -C $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/ MCU=$(MCU) hid clean
+
hid-teensy: $(TARGET).hex $(MAKEFILE_LIST)
@echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with teensy_loader_cli using \"$<\"
teensy_loader_cli -mmcu=$(MCU) -v $<
+hid-teensy-ee: $(TARGET).hex $(MAKEFILE_LIST)
+ @echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\"
+ avr-objcopy -I ihex -O binary $< $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/InputEEData.bin
+ @echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"
+ make -s -C $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/ MCU=$(MCU) hid-teensy clean
+
# Phony build targets for this module
-.PHONY: hid hid-teensy
+.PHONY: hid hid-ee hid-teensy hid-teensy-ee
diff --git a/LUFA/DoxygenPages/BuildSystem.txt b/LUFA/DoxygenPages/BuildSystem.txt
index d50dd7f13c..2c42c7da8b 100644
--- a/LUFA/DoxygenPages/BuildSystem.txt
+++ b/LUFA/DoxygenPages/BuildSystem.txt
@@ -183,6 +183,10 @@
* Directory to place the generated object and dependency files. If set to "." the same folder as the source file will be used.
* \note When this option is enabled, all source filenames must be unique. |
*
+ *
+ * OBJECT_FILES |
+ * List of additional object files that should be linked into the resulting binary. |
+ *
*
*
* \section SSec_BuildModule_BUILD_ProvidedVariables Module Provided Variables
@@ -696,9 +700,21 @@
* Program the device FLASH memory with the application's executable data using hid_bootloader_cli. |
*
*
+ * hid-ee |
+ * Program the device EEPROM memory with the application's EEPROM data using hid_bootloader_cli and
+ * a temporary AVR application programmed into the target's FLASH.
+ * \note This will erase the currently loaded application in the target. |
+ *
+ *
* hid-teensy |
* Program the device FLASH memory with the application's executable data using teensy_loader_cli. |
*
+ *
+ * hid-teensy-ee |
+ * Program the device EEPROM memory with the application's EEPROM data using teensy_loader_cli and
+ * a temporary AVR application programmed into the target's FLASH.
+ * \note This will erase the currently loaded application in the target. |
+ *
*
*
* \section SSec_BuildModule_HID_MandatoryParams Mandatory Parameters