Skip to content

Commit

Permalink
Build: Update to latest DMBS version.
Browse files Browse the repository at this point in the history
  • Loading branch information
abcminiuser committed Jul 19, 2020
1 parent ca40bc7 commit 305ca46
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 56 deletions.
12 changes: 8 additions & 4 deletions LUFA/Build/DMBS/DMBS/HID_EEPROM_Loader/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@ SRC = $(TARGET).c
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
Expand Down
59 changes: 39 additions & 20 deletions LUFA/Build/DMBS/DMBS/avrdude.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ The following targets are supported by this module:
</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>
Expand Down Expand Up @@ -95,6 +98,10 @@ be assumed.

<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>
Expand All @@ -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_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>

Expand Down Expand Up @@ -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.

### 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.
34 changes: 23 additions & 11 deletions LUFA/Build/DMBS/DMBS/avrdude.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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_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 +=

Expand All @@ -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
AVRDUDE_MCU ?= $(MCU)
AVRDUDE_PROGRAMMER ?= jtagicemkii
AVRDUDE_PORT ?= usb
AVRDUDE_FLAGS ?=
Expand All @@ -29,10 +30,18 @@ AVRDUDE_HFUSE ?=
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)
Expand All @@ -41,43 +50,46 @@ $(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

Expand Down
2 changes: 1 addition & 1 deletion LUFA/Build/DMBS/DMBS/core.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
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)))
Expand Down
11 changes: 10 additions & 1 deletion LUFA/Build/DMBS/DMBS/gcc.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ be assumed.
</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>
Expand Down Expand Up @@ -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.

### 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.

Expand Down
23 changes: 12 additions & 11 deletions LUFA/Build/DMBS/DMBS/gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ COMPILER_PATH ?=
OPTIMIZATION ?= s
F_CPU ?=
C_STANDARD ?= gnu99
CPP_STANDARD ?= gnu++98
CPP_STANDARD ?= gnu++11
C_FLAGS ?=
CPP_FLAGS ?=
ASM_FLAGS ?=
Expand Down Expand Up @@ -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.
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
Expand All @@ -131,17 +128,16 @@ ifeq ($(JUMP_TABLES), N)
# 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)
Expand All @@ -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
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
Expand Down
11 changes: 3 additions & 8 deletions LUFA/Build/DMBS/DMBS/hid.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,14 @@ MSG_HID_BOOTLOADER_CMD := ' [HID] :'
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 \"$<\"
hid_bootloader_cli -mmcu=$(MCU) -v $<

# 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

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

Expand Down

0 comments on commit 305ca46

Please sign in to comment.