Build: Update to latest DMBS version.
authorDean Camera <dean@fourwalledcubicle.com>
Sun, 19 Jul 2020 01:50:52 +0000 (11:50 +1000)
committerDean Camera <dean@fourwalledcubicle.com>
Sun, 19 Jul 2020 01:50:52 +0000 (11:50 +1000)
LUFA/Build/DMBS/DMBS/HID_EEPROM_Loader/makefile
LUFA/Build/DMBS/DMBS/avrdude.md
LUFA/Build/DMBS/DMBS/avrdude.mk
LUFA/Build/DMBS/DMBS/core.mk
LUFA/Build/DMBS/DMBS/gcc.md
LUFA/Build/DMBS/DMBS/gcc.mk
LUFA/Build/DMBS/DMBS/hid.mk

index 879eda8..1b1185b 100644 (file)
@@ -17,17 +17,21 @@ SRC          = $(TARGET).c
 CC_FLAGS     =
 LD_FLAGS     =
 OBJECT_FILES = InputEEData.o
 CC_FLAGS     =
 LD_FLAGS     =
 OBJECT_FILES = InputEEData.o
+OBJDIR       = obj
 
 # Default target
 all:
 
 # Determine the AVR sub-architecture of the build main application object file
 
 # Default target
 all:
 
 # Determine the AVR sub-architecture of the build main application object file
-FIND_AVR_SUBARCH = avr$(shell avr-objdump -f $(TARGET).o | grep architecture | cut -d':' -f3 | cut -d',' -f1)
+FIND_AVR_SUBARCH = avr$(shell avr-objdump -f $(OBJDIR)/$(TARGET).o | grep architecture | cut -d':' -f3 | cut -d',' -f1)
 
 # Create a linkable object file with the input binary EEPROM data stored in the FLASH section
 
 # Create a linkable object file with the input binary EEPROM data stored in the FLASH section
-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 $(call FIND_AVR_SUBARCH) --rename-section .data=.progmem.data,contents,alloc,readonly,data $< $@
+$(OBJDIR)/InputEEData.o: $(OBJDIR)/$(TARGET).o
+       @echo $(MSG_OBJCPY_CMD) Converting \"InputEEData.eep\" to a binary file \"InputEEData.bin\"
+       avr-objcopy -I ihex -O binary InputEEData.eep InputEEData.bin
+
+       @echo $(MSG_OBJCPY_CMD) Converting \"InputEEData.bin\" to a object file \"InputEEData.o\"
+       avr-objcopy -I binary -O elf32-avr -B $(call FIND_AVR_SUBARCH) --rename-section .data=.progmem.data,contents,alloc,readonly,data InputEEData.bin $@
 
 # Include LUFA build script makefiles
 include ../core.mk
 
 # Include LUFA build script makefiles
 include ../core.mk
index 9d6a1bb..11ea46c 100644 (file)
@@ -48,7 +48,10 @@ The following targets are supported by this module:
    </tr>
    <tr>
     <td>avrdude-fuses</td>
    </tr>
    <tr>
     <td>avrdude-fuses</td>
-    <td>Program the device fuses (lfuse, hfuse, efuse, lock bits).</td>
+    <td>
+     Program the device fuses (lfuse, hfuse, efuse, lock bits).<br>
+     Requires AVRDUDE_LFUSE, AVRDUDE_HFUSE and AVRDUDE_LOCK variable set. AVRDUDE_EFUSE is optional.
+    </td>
    </tr>
    <tr>
     <td>avrdude</td>
    </tr>
    <tr>
     <td>avrdude</td>
@@ -96,6 +99,10 @@ be assumed.
 <table>
  <tbody>
    <tr>
 <table>
  <tbody>
    <tr>
+    <td>AVRDUDE_MCU</td>
+    <td>Override the `MCU` variable for `avrdude`. On some controllers, `avrdude` expects another spelling than the compiler needs. Default is `MCU`.</td>
+   </tr>
+   <tr>
     <td>AVRDUDE_PROGRAMMER</td>
     <td>Name of the programmer/debugger tool or bootloader to communicate with (e.g. `jtagicemkii`). Default is `jtagicemkii`.</td>
    </tr>
     <td>AVRDUDE_PROGRAMMER</td>
     <td>Name of the programmer/debugger tool or bootloader to communicate with (e.g. `jtagicemkii`). Default is `jtagicemkii`.</td>
    </tr>
@@ -111,25 +118,30 @@ be assumed.
     <td>AVRDUDE_MEMORY</td>
     <td>Memory space to program when executing the `avrdude` target (e.g. 'application` for an XMEGA device). Default is `flash`.</td>
    </tr>
     <td>AVRDUDE_MEMORY</td>
     <td>Memory space to program when executing the `avrdude` target (e.g. 'application` for an XMEGA device). Default is `flash`.</td>
    </tr>
-   <td>AVRDUDE_BAUD</td>
-   <td>Baud rate to use when executing the `avrdude` target (e.g. '115200` for an Optiboot device). Default is empty.</td>
-  </tr>
-  </tr>
-   <td>AVRDUDE_HFUSE</td>
-   <td>Fuse setting to use when executing the `avrdude-hfuse` target (format: 0x??). Default is empty.</td>
-  </tr>
-  </tr>
-   <td>AVRDUDE_EFUSE</td>
-   <td>Fuse setting to use when executing the `avrdude-efuse` target (format: 0x??). Default is empty.</td>
-  </tr>
-  </tr>
-   <td>AVRDUDE_LFUSE</td>
-   <td>Fuse setting to use when executing the `avrdude-lfuse` target (format: 0x??). Default is empty.</td>
-  </tr>
-  </tr>
-  <td>AVRDUDE_LOCK</td>
-  <td>Bit bits setting to use when executing the `avrdude-lock` target (format: 0x??). Default is empty.</td>
- </tr>
+   <tr>
+    <td>AVRDUDE_BAUD</td>
+    <td>Baud rate to use when executing the `avrdude` target (e.g. '115200` for an Optiboot device). Default is empty.</td>
+   </tr>
+   <tr>
+    <td>AVRDUDE_BITCLK</td>
+    <td>ISP bit clock period in microseconds to use when executing the `avrdude` target (format: float). Must be minimum 4x longer than MCU clock period. Default is 1 us.</td>
+   </tr>
+   <tr>
+    <td>AVRDUDE_HFUSE</td>
+    <td>Fuse setting to use when executing the `avrdude-hfuse` target (format: 0x??). Default is empty.</td>
+   </tr>
+   <tr>
+    <td>AVRDUDE_EFUSE</td>
+    <td>Fuse setting to use when executing the `avrdude-efuse` target (format: 0x??). Default is empty.</td>
+   </tr>
+   <tr>
+    <td>AVRDUDE_LFUSE</td>
+    <td>Fuse setting to use when executing the `avrdude-lfuse` target (format: 0x??). Default is empty.</td>
+   </tr>
+   <tr>
+    <td>AVRDUDE_LOCK</td>
+    <td>Bit bits setting to use when executing the `avrdude-lock` target (format: 0x??). Default is empty.</td>
+   </tr>
  </tbody>
 </table>
 
  </tbody>
 </table>
 
@@ -167,5 +179,12 @@ this module.
 The changes to this module since its initial release are listed below, as of the
 DMBS version where the change was made.
 
 The changes to this module since its initial release are listed below, as of the
 DMBS version where the change was made.
 
+### 20200412
+Made `AVRDUDE_EFUSE` optional for `avrdude-fuses` because not every AVR has this fuse.
+
+### 20171231
+Added `AVRDUDE_BAUD`, `AVRDUDE_HFUSE`, `AVRDUDE_EFUSE`, `AVRDUDE_LFUSE` and
+`AVRDUDE_LOCK` optional variables.
+
 ### 20160403
 Initial release.
 ### 20160403
 Initial release.
index 7b5f64a..64cb445 100644 (file)
@@ -10,8 +10,8 @@ DMBS_BUILD_MODULES         += AVRDUDE
 DMBS_BUILD_TARGETS         += avrdude-lfuse avrdude-hfuse avrdude-efuse avrdude-lock avrdude-fuses
 DMBS_BUILD_TARGETS         += avrdude avrdude-ee avrdude-all avrdude-all-ee
 DMBS_BUILD_MANDATORY_VARS  += MCU TARGET
 DMBS_BUILD_TARGETS         += avrdude-lfuse avrdude-hfuse avrdude-efuse avrdude-lock avrdude-fuses
 DMBS_BUILD_TARGETS         += avrdude avrdude-ee avrdude-all avrdude-all-ee
 DMBS_BUILD_MANDATORY_VARS  += MCU TARGET
-DMBS_BUILD_OPTIONAL_VARS   += AVRDUDE_PROGRAMMER AVRDUDE_PORT AVRDUDE_FLAGS AVRDUDE_MEMORY AVRDUDE_BAUD
-DMBS_BUILD_OPTIONAL_VARS   += AVRDUDE_LFUSE AVRDUDE_HFUSE AVRDUDE_EUSE AVRDUDE_LOCK
+DMBS_BUILD_OPTIONAL_VARS   += AVRDUDE_MCU AVRDUDE_PROGRAMMER AVRDUDE_PORT AVRDUDE_FLAGS AVRDUDE_MEMORY AVRDUDE_BAUD
+DMBS_BUILD_OPTIONAL_VARS   += AVRDUDE_LFUSE AVRDUDE_HFUSE AVRDUDE_EFUSE AVRDUDE_LOCK AVRDUDE_BITCLK
 DMBS_BUILD_PROVIDED_VARS   +=
 DMBS_BUILD_PROVIDED_MACROS +=
 
 DMBS_BUILD_PROVIDED_VARS   +=
 DMBS_BUILD_PROVIDED_MACROS +=
 
@@ -20,6 +20,7 @@ DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
 include $(DMBS_MODULE_PATH)/core.mk
 
 # Default values of optionally user-supplied variables
 include $(DMBS_MODULE_PATH)/core.mk
 
 # Default values of optionally user-supplied variables
+AVRDUDE_MCU        ?= $(MCU)
 AVRDUDE_PROGRAMMER ?= jtagicemkii
 AVRDUDE_PORT       ?= usb
 AVRDUDE_FLAGS      ?=
 AVRDUDE_PROGRAMMER ?= jtagicemkii
 AVRDUDE_PORT       ?= usb
 AVRDUDE_FLAGS      ?=
@@ -29,10 +30,18 @@ AVRDUDE_HFUSE      ?=
 AVRDUDE_EFUSE      ?=
 AVRDUDE_LOCK       ?=
 AVRDUDE_BAUD       ?=
 AVRDUDE_EFUSE      ?=
 AVRDUDE_LOCK       ?=
 AVRDUDE_BAUD       ?=
+AVRDUDE_BITCLK     ?=
+
+# Set avrdude-efuse-target as dependency for avrdude-fuses only if defined, because not every AVR has this fuse
+ifneq ($(AVRDUDE_EFUSE),)
+  AVRDUDE_EFUSE_TARGET := avrdude-efuse
+else
+  AVRDUDE_EFUSE_TARGET :=
+endif
 
 # Sanity check user supplied values
 $(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
 
 # Sanity check user supplied values
 $(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
-$(call ERROR_IF_EMPTY, MCU)
+$(call ERROR_IF_EMPTY, AVRDUDE_MCU)
 $(call ERROR_IF_EMPTY, TARGET)
 $(call ERROR_IF_EMPTY, AVRDUDE_PROGRAMMER)
 $(call ERROR_IF_EMPTY, AVRDUDE_PORT)
 $(call ERROR_IF_EMPTY, TARGET)
 $(call ERROR_IF_EMPTY, AVRDUDE_PROGRAMMER)
 $(call ERROR_IF_EMPTY, AVRDUDE_PORT)
@@ -41,43 +50,46 @@ $(call ERROR_IF_EMPTY, AVRDUDE_PORT)
 MSG_AVRDUDE_CMD    := ' [AVRDUDE] :'
 
 # Construct base avrdude command flags
 MSG_AVRDUDE_CMD    := ' [AVRDUDE] :'
 
 # Construct base avrdude command flags
-BASE_AVRDUDE_FLAGS := -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+BASE_AVRDUDE_FLAGS := -p $(AVRDUDE_MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
 ifneq ($(AVRDUDE_BAUD),)
   BASE_AVRDUDE_FLAGS += -b $(AVRDUDE_BAUD)
 endif
 ifneq ($(AVRDUDE_BAUD),)
   BASE_AVRDUDE_FLAGS += -b $(AVRDUDE_BAUD)
 endif
+ifneq ($(AVRDUDE_BITCLK),)
+  BASE_AVRDUDE_FLAGS += -B $(AVRDUDE_BITCLK)
+endif
 
 # Programs in the target FLASH memory using AVRDUDE
 avrdude: $(TARGET).hex $(MAKEFILE_LIST)
 
 # Programs in the target FLASH memory using AVRDUDE
 avrdude: $(TARGET).hex $(MAKEFILE_LIST)
-       @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" FLASH using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
+       @echo $(MSG_AVRDUDE_CMD) Programming device \"$(AVRDUDE_MCU)\" FLASH using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
        avrdude $(BASE_AVRDUDE_FLAGS) -U $(AVRDUDE_MEMORY):w:$< $(AVRDUDE_FLAGS)
 
 # Programs in the target EEPROM memory using AVRDUDE
 avrdude-ee: $(TARGET).eep $(MAKEFILE_LIST)
        avrdude $(BASE_AVRDUDE_FLAGS) -U $(AVRDUDE_MEMORY):w:$< $(AVRDUDE_FLAGS)
 
 # Programs in the target EEPROM memory using AVRDUDE
 avrdude-ee: $(TARGET).eep $(MAKEFILE_LIST)
-       @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" EEPROM using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
+       @echo $(MSG_AVRDUDE_CMD) Programming device \"$(AVRDUDE_MCU)\" EEPROM using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
        avrdude $(BASE_AVRDUDE_FLAGS) -U eeprom:w:$< $(AVRDUDE_FLAGS)
 
 # Programs in the target fuses using AVRDUDE
 avrdude-lfuse: $(MAKEFILE_LIST)
        avrdude $(BASE_AVRDUDE_FLAGS) -U eeprom:w:$< $(AVRDUDE_FLAGS)
 
 # Programs in the target fuses using AVRDUDE
 avrdude-lfuse: $(MAKEFILE_LIST)
-       @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" low fuse using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
+       @echo $(MSG_AVRDUDE_CMD) Programming device \"$(AVRDUDE_MCU)\" low fuse using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
        $(call ERROR_IF_EMPTY, AVRDUDE_LFUSE)
        avrdude $(BASE_AVRDUDE_FLAGS) -Ulfuse:w:$(AVRDUDE_LFUSE):m $(AVRDUDE_FLAGS)
 
 avrdude-hfuse: $(MAKEFILE_LIST)
        $(call ERROR_IF_EMPTY, AVRDUDE_LFUSE)
        avrdude $(BASE_AVRDUDE_FLAGS) -Ulfuse:w:$(AVRDUDE_LFUSE):m $(AVRDUDE_FLAGS)
 
 avrdude-hfuse: $(MAKEFILE_LIST)
-       @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" high fuse using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
+       @echo $(MSG_AVRDUDE_CMD) Programming device \"$(AVRDUDE_MCU)\" high fuse using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
        $(call ERROR_IF_EMPTY, AVRDUDE_HFUSE)
        avrdude $(BASE_AVRDUDE_FLAGS) -Uhfuse:w:$(AVRDUDE_HFUSE):m $(AVRDUDE_FLAGS)
 
 avrdude-efuse: $(MAKEFILE_LIST)
        $(call ERROR_IF_EMPTY, AVRDUDE_HFUSE)
        avrdude $(BASE_AVRDUDE_FLAGS) -Uhfuse:w:$(AVRDUDE_HFUSE):m $(AVRDUDE_FLAGS)
 
 avrdude-efuse: $(MAKEFILE_LIST)
-       @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" extended fuse using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
+       @echo $(MSG_AVRDUDE_CMD) Programming device \"$(AVRDUDE_MCU)\" extended fuse using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
        $(call ERROR_IF_EMPTY, AVRDUDE_EFUSE)
        avrdude $(BASE_AVRDUDE_FLAGS) -Uefuse:w:$(AVRDUDE_EFUSE):m $(AVRDUDE_FLAGS)
 
 avrdude-lock: $(MAKEFILE_LIST)
        $(call ERROR_IF_EMPTY, AVRDUDE_EFUSE)
        avrdude $(BASE_AVRDUDE_FLAGS) -Uefuse:w:$(AVRDUDE_EFUSE):m $(AVRDUDE_FLAGS)
 
 avrdude-lock: $(MAKEFILE_LIST)
-       @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" lock bits using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
+       @echo $(MSG_AVRDUDE_CMD) Programming device \"$(AVRDUDE_MCU)\" lock bits using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
        $(call ERROR_IF_EMPTY, AVRDUDE_LOCK)
        avrdude $(BASE_AVRDUDE_FLAGS) -Ulock:w:$(AVRDUDE_LOCK):m $(AVRDUDE_FLAGS)
 
        $(call ERROR_IF_EMPTY, AVRDUDE_LOCK)
        avrdude $(BASE_AVRDUDE_FLAGS) -Ulock:w:$(AVRDUDE_LOCK):m $(AVRDUDE_FLAGS)
 
-avrdude-fuses: avrdude-lfuse avrdude-hfuse avrdude-efuse avrdude-lock
+avrdude-fuses: avrdude-lfuse avrdude-hfuse $(AVRDUDE_EFUSE_TARGET) avrdude-lock
 
 avrdude-all: avrdude avrdude-fuses
 
 
 avrdude-all: avrdude avrdude-fuses
 
index d18d4ef..c9d6e21 100644 (file)
@@ -19,7 +19,7 @@ DMBS_BUILD_PROVIDED_MACROS += DMBS_CHECK_VERSION ERROR_IF_UNSET ERROR_IF_EMPTY E
 SHELL = /bin/sh
 
 # Current DMBS release version
 SHELL = /bin/sh
 
 # Current DMBS release version
-DMBS_VERSION       := 20171231
+DMBS_VERSION       := 20200719
 
 # Macro to check the DMBS version, aborts if the given DMBS version is below the current version
 DMBS_CHECK_VERSION ?= $(if $(filter-out 0, $(shell test $(DMBS_VERSION) -lt $(1); echo $$?)), , $(error DMBS version $(1) or newer required, current version is $(DMBS_VERSION)))
 
 # Macro to check the DMBS version, aborts if the given DMBS version is below the current version
 DMBS_CHECK_VERSION ?= $(if $(filter-out 0, $(shell test $(DMBS_VERSION) -lt $(1); echo $$?)), , $(error DMBS version $(1) or newer required, current version is $(DMBS_VERSION)))
index f7f3480..760de24 100644 (file)
@@ -117,7 +117,7 @@ be assumed.
    </tr>
    <tr>
     <td>CPP_STANDARD</td>
    </tr>
    <tr>
     <td>CPP_STANDARD</td>
-    <td>C++ language standard used when compiling C++ language source files. Default is `gnu++98` (C++98 standard with GNU extensions)./td>
+    <td>C++ language standard used when compiling C++ language source files. Default is `gnu++11` (C++11 standard with GNU extensions)./td>
    </tr>
    <tr>
     <td>F_CPU</td>
    </tr>
    <tr>
     <td>F_CPU</td>
@@ -208,6 +208,15 @@ this module.
 The changes to this module since its initial release are listed below, as of the
 DMBS version where the change was made.
 
 The changes to this module since its initial release are listed below, as of the
 DMBS version where the change was made.
 
+### 20180122
+Changed C++ default language standard from gnu++98 to gnu++11.
+
+### 20171231
+Added `-fpack-struct` for C files only (not C++).
+Added `-fno-exceptions` and `-fno-threadsafe-statics` for C++ source files.
+Added file-specific compilation flags.
+Added `LTO` optional variable.
+
 ### 20170426
 Added `JUMP_TABLES` optional variable.
 
 ### 20170426
 Added `JUMP_TABLES` optional variable.
 
index 73065dc..24c9b07 100644 (file)
@@ -24,7 +24,7 @@ COMPILER_PATH      ?=
 OPTIMIZATION       ?= s
 F_CPU              ?=
 C_STANDARD         ?= gnu99
 OPTIMIZATION       ?= s
 F_CPU              ?=
 C_STANDARD         ?= gnu99
-CPP_STANDARD       ?= gnu++98
+CPP_STANDARD       ?= gnu++11
 C_FLAGS            ?=
 CPP_FLAGS          ?=
 ASM_FLAGS          ?=
 C_FLAGS            ?=
 CPP_FLAGS          ?=
 ASM_FLAGS          ?=
@@ -117,10 +117,7 @@ else ifneq ($(findstring $(ARCH), UC3),)
 endif
 BASE_CC_FLAGS += -Wall -fno-strict-aliasing -funsigned-char -funsigned-bitfields -ffunction-sections
 BASE_CC_FLAGS += -I.
 endif
 BASE_CC_FLAGS += -Wall -fno-strict-aliasing -funsigned-char -funsigned-bitfields -ffunction-sections
 BASE_CC_FLAGS += -I.
-BASE_CC_FLAGS += -DARCH=ARCH_$(ARCH)
-ifneq ($(F_CPU),)
-   BASE_CC_FLAGS += -DF_CPU=$(F_CPU)UL
-endif
+BASE_CC_FLAGS += -DARCH=ARCH_$(ARCH) -DDMBS_ARCH_$(ARCH)
 ifeq ($(LINKER_RELAXATIONS), Y)
    BASE_CC_FLAGS += -mrelax
 endif
 ifeq ($(LINKER_RELAXATIONS), Y)
    BASE_CC_FLAGS += -mrelax
 endif
@@ -131,17 +128,16 @@ ifeq ($(JUMP_TABLES), N)
    # in a pseudo-random jump target.
    BASE_CC_FLAGS += -fno-jump-tables
 endif
    # in a pseudo-random jump target.
    BASE_CC_FLAGS += -fno-jump-tables
 endif
-ifeq ($(LTO), Y)
-   # Enable link time optimization to reduce overall flash size.
-   BASE_CC_FLAGS += -flto -fuse-linker-plugin
-   BASE_LD_FLAGS += -flto -fuse-linker-plugin
-endif
 
 # Additional language specific compiler flags
 BASE_C_FLAGS   := -x c -O$(OPTIMIZATION) -std=$(C_STANDARD) -Wstrict-prototypes
 BASE_CPP_FLAGS := -x c++ -O$(OPTIMIZATION) -std=$(CPP_STANDARD) -fno-exceptions -fno-threadsafe-statics
 BASE_ASM_FLAGS := -x assembler-with-cpp
 
 # Additional language specific compiler flags
 BASE_C_FLAGS   := -x c -O$(OPTIMIZATION) -std=$(C_STANDARD) -Wstrict-prototypes
 BASE_CPP_FLAGS := -x c++ -O$(OPTIMIZATION) -std=$(CPP_STANDARD) -fno-exceptions -fno-threadsafe-statics
 BASE_ASM_FLAGS := -x assembler-with-cpp
-
+ifneq ($(F_CPU),)
+   BASE_C_FLAGS += -DF_CPU=$(F_CPU)UL
+   BASE_CPP_FLAGS += -DF_CPU=$(F_CPU)UL
+   BASE_ASM_FLAGS += -DF_CPU=$(F_CPU)
+endif
 # Create a list of flags to pass to the linker
 BASE_LD_FLAGS := -lm -Wl,-Map=$(TARGET).map,--cref -Wl,--gc-sections
 ifeq ($(LINKER_RELAXATIONS), Y)
 # Create a list of flags to pass to the linker
 BASE_LD_FLAGS := -lm -Wl,-Map=$(TARGET).map,--cref -Wl,--gc-sections
 ifeq ($(LINKER_RELAXATIONS), Y)
@@ -152,6 +148,11 @@ ifneq ($(findstring $(ARCH), AVR8 XMEGA),)
 else ifneq ($(findstring $(ARCH), UC3),)
    BASE_LD_FLAGS += -mpart=$(MCU:at32%=%) --rodata-writable --direct-data
 endif
 else ifneq ($(findstring $(ARCH), UC3),)
    BASE_LD_FLAGS += -mpart=$(MCU:at32%=%) --rodata-writable --direct-data
 endif
+ifeq ($(LTO), Y)
+   # Enable link time optimization to reduce overall flash size.
+   BASE_CC_FLAGS += -flto -fuse-linker-plugin
+   BASE_LD_FLAGS += -flto -fuse-linker-plugin
+endif
 
 # Determine flags to pass to the size utility based on its reported features (only invoke if size target required)
 # and on an architecture where this non-standard patch is available
 
 # Determine flags to pass to the size utility based on its reported features (only invoke if size target required)
 # and on an architecture where this non-standard patch is available
index d3195b2..3927504 100644 (file)
@@ -27,9 +27,6 @@ MSG_HID_BOOTLOADER_CMD := ' [HID]     :'
 MSG_OBJCPY_CMD         := ' [OBJCPY]  :'
 MSG_MAKE_CMD           := ' [MAKE]    :'
 
 MSG_OBJCPY_CMD         := ' [OBJCPY]  :'
 MSG_MAKE_CMD           := ' [MAKE]    :'
 
-# Set MAKE variable if the environment does not already define it
-MAKE ?= make
-
 # Programs in the target FLASH memory using the HID_BOOTLOADER_CLI tool
 hid: $(TARGET).hex $(MAKEFILE_LIST)
        @echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with hid_bootloader_cli using \"$<\"
 # Programs in the target FLASH memory using the HID_BOOTLOADER_CLI tool
 hid: $(TARGET).hex $(MAKEFILE_LIST)
        @echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with hid_bootloader_cli using \"$<\"
@@ -37,8 +34,7 @@ hid: $(TARGET).hex $(MAKEFILE_LIST)
 
 # Programs in the target EEPROM memory using the HID_BOOTLOADER_CLI tool (note: clears target FLASH memory)
 hid-ee: $(TARGET).eep $(MAKEFILE_LIST)
 
 # Programs in the target EEPROM memory using the HID_BOOTLOADER_CLI tool (note: clears target FLASH memory)
 hid-ee: $(TARGET).eep $(MAKEFILE_LIST)
-       @echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\"
-       avr-objcopy -I ihex -O binary $< $(DMBS_MODULE_PATH)/HID_EEPROM_Loader/InputEEData.bin
+       cp $< $(DMBS_MODULE_PATH)/HID_EEPROM_Loader/InputEEData.eep
        @echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"
        $(MAKE) -C $(DMBS_MODULE_PATH)/HID_EEPROM_Loader/ MCU=$(MCU) clean hid
 
        @echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"
        $(MAKE) -C $(DMBS_MODULE_PATH)/HID_EEPROM_Loader/ MCU=$(MCU) clean hid
 
@@ -48,9 +44,8 @@ teensy: $(TARGET).hex $(MAKEFILE_LIST)
        teensy_loader_cli -mmcu=$(MCU) -v $<
 
 # Programs in the target EEPROM memory using the TEENSY_BOOTLOADER_CLI tool (note: clears target FLASH memory)
        teensy_loader_cli -mmcu=$(MCU) -v $<
 
 # Programs in the target EEPROM memory using the TEENSY_BOOTLOADER_CLI tool (note: clears target FLASH memory)
-teensy-ee: $(TARGET).hex $(MAKEFILE_LIST)
-       @echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\"
-       avr-objcopy -I ihex -O binary $< $(DMBS_MODULE_PATH)/HID_EEPROM_Loader/InputEEData.bin
+teensy-ee: $(TARGET).eep $(MAKEFILE_LIST)
+       cp $< $(DMBS_MODULE_PATH)/HID_EEPROM_Loader/InputEEData.eep
        @echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"
        $(MAKE) -s -C $(DMBS_MODULE_PATH)/HID_EEPROM_Loader/ MCU=$(MCU) clean teensy
 
        @echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"
        $(MAKE) -s -C $(DMBS_MODULE_PATH)/HID_EEPROM_Loader/ MCU=$(MCU) clean teensy