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
-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
-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
</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>
<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_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>
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.
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 +=
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_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)))
-$(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)
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_BITCLK),)
+ BASE_AVRDUDE_FLAGS += -B $(AVRDUDE_BITCLK)
+endif
# 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)
- @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)
- @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)
- @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)
- @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)
- @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)
-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
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)))
</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>
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.
OPTIMIZATION ?= s
F_CPU ?=
C_STANDARD ?= gnu99
-CPP_STANDARD ?= gnu++98
+CPP_STANDARD ?= gnu++11
C_FLAGS ?=
CPP_FLAGS ?=
ASM_FLAGS ?=
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
# 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
-
+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)
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
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 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
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