Update BUILD build system module with OBJECT_FILES variable, for additional user-specified object files. Update HID build module with a small shim application to reprogram the EEPROM of a target.

pull/1469/head
Dean Camera 13 years ago
parent 56d368f2de
commit c4da1929cd

File diff suppressed because one or more lines are too long

@ -0,0 +1,48 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2012.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of
this software.
*/
#include <avr/io.h>
#include <avr/eeprom.h>
#include <avr/pgmspace.h>
/* 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 (;;);
}

@ -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

@ -9,7 +9,7 @@
LUFA_BUILD_MODULES += BUILD LUFA_BUILD_MODULES += BUILD
LUFA_BUILD_TARGETS += size check-source symbol-sizes all lib elf hex lss clean mostlyclean 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_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_VARS +=
LUFA_BUILD_PROVIDED_MACROS += LUFA_BUILD_PROVIDED_MACROS +=
@ -63,6 +63,7 @@ LUFA_BUILD_PROVIDED_MACROS +=
# OBJDIR - Directory for the output object and dependency # OBJDIR - Directory for the output object and dependency
# files; if equal to ".", the output files will # files; if equal to ".", the output files will
# be generated in the same folder as the sources # be generated in the same folder as the sources
# OBJECT_FILES - Extra object files to link in to the binaries
# #
# PROVIDED VARIABLES: # PROVIDED VARIABLES:
# #
@ -91,6 +92,7 @@ CPP_FLAGS ?=
ASM_FLAGS ?= ASM_FLAGS ?=
CC_FLAGS ?= CC_FLAGS ?=
OBJDIR ?= . OBJDIR ?= .
OBJECT_FILES ?=
# Sanity check user supplied values # Sanity check user supplied values
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) $(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
@ -141,7 +143,7 @@ ifneq ($(UNKNOWN_SOURCE),)
endif endif
# Convert input source filenames into a list of required output object files # 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),.) ifneq ($(OBJDIR),.)
$(shell mkdir $(OBJDIR) 2>&1 > /dev/null) $(shell mkdir $(OBJDIR) 2>&1 > /dev/null)
VPATH += $(dir $(SRC)) VPATH += $(dir $(SRC))

@ -7,7 +7,7 @@
# #
LUFA_BUILD_MODULES += HID 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_MANDATORY_VARS += MCU TARGET
LUFA_BUILD_OPTIONAL_VARS += LUFA_BUILD_OPTIONAL_VARS +=
LUFA_BUILD_PROVIDED_VARS += LUFA_BUILD_PROVIDED_VARS +=
@ -24,8 +24,12 @@ LUFA_BUILD_PROVIDED_MACROS +=
# #
# hid - Program FLASH into target via # hid - Program FLASH into target via
# hid_bootloader_cli # 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 # hid-teensy - Program FLASH into target via
# teensy_loader_cli # teensy_loader_cli
# hid-teensy-ee - Program EEPROM into target via a temporary
# AVR application and teensy_loader_cli
# #
# MANDATORY PARAMETERS: # MANDATORY PARAMETERS:
# #
@ -57,14 +61,28 @@ $(call ERROR_IF_EMPTY, TARGET)
# Output Messages # Output Messages
MSG_HID_BOOTLOADER_CMD := ' [HID] :' MSG_HID_BOOTLOADER_CMD := ' [HID] :'
MSG_OBJCPY_CMD := ' [OBJCPY] :'
MSG_MAKE_CMD := ' [MAKE] :'
hid: $(TARGET).hex $(MAKEFILE_LIST) hid: $(TARGET).hex $(MAKEFILE_LIST)
@echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with hid_bootloader_cli using \"$<\" @echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with hid_bootloader_cli using \"$<\"
hid_bootloader_cli -mmcu=$(MCU) -v $< 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) hid-teensy: $(TARGET).hex $(MAKEFILE_LIST)
@echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with teensy_loader_cli using \"$<\" @echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with teensy_loader_cli using \"$<\"
teensy_loader_cli -mmcu=$(MCU) -v $< 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 build targets for this module
.PHONY: hid hid-teensy .PHONY: hid hid-ee hid-teensy hid-teensy-ee

@ -183,6 +183,10 @@
* <td>Directory to place the generated object and dependency files. If set to "." the same folder as the source file will be used. * <td>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 <b>must</b> be unique.</td> * \note When this option is enabled, all source filenames <b>must</b> be unique.</td>
* </tr> * </tr>
* <tr>
* <td><tt>OBJECT_FILES</tt></td>
* <td>List of additional object files that should be linked into the resulting binary.</td>
* </tr>
* </table> * </table>
* *
* \section SSec_BuildModule_BUILD_ProvidedVariables Module Provided Variables * \section SSec_BuildModule_BUILD_ProvidedVariables Module Provided Variables
@ -696,9 +700,21 @@
* <td>Program the device FLASH memory with the application's executable data using <tt>hid_bootloader_cli</tt>.</td> * <td>Program the device FLASH memory with the application's executable data using <tt>hid_bootloader_cli</tt>.</td>
* </tr> * </tr>
* <tr> * <tr>
* <td><tt>hid-ee</tt></td>
* <td>Program the device EEPROM memory with the application's EEPROM data using <tt>hid_bootloader_cli</tt> and
* a temporary AVR application programmed into the target's FLASH.
* \note This will erase the currently loaded application in the target.</td>
* </tr>
* <tr>
* <td><tt>hid-teensy</tt></td> * <td><tt>hid-teensy</tt></td>
* <td>Program the device FLASH memory with the application's executable data using <tt>teensy_loader_cli</tt>.</td> * <td>Program the device FLASH memory with the application's executable data using <tt>teensy_loader_cli</tt>.</td>
* </tr> * </tr>
* <tr>
* <td><tt>hid-teensy-ee</tt></td>
* <td>Program the device EEPROM memory with the application's EEPROM data using <tt>teensy_loader_cli</tt> and
* a temporary AVR application programmed into the target's FLASH.
* \note This will erase the currently loaded application in the target.</td>
* </tr>
* </table> * </table>
* *
* \section SSec_BuildModule_HID_MandatoryParams Mandatory Parameters * \section SSec_BuildModule_HID_MandatoryParams Mandatory Parameters

Loading…
Cancel
Save