3 # Released into the public domain.
5 # dean [at] fourwalledcubicle [dot] com
6 # www.fourwalledcubicle.com
9 DMBS_BUILD_MODULES += AVRDUDE
10 DMBS_BUILD_TARGETS += avrdude avrdude-ee
11 DMBS_BUILD_MANDATORY_VARS += MCU TARGET
12 DMBS_BUILD_OPTIONAL_VARS += AVRDUDE_PROGRAMMER AVRDUDE_PORT AVRDUDE_FLAGS AVRDUDE_MEMORY
13 DMBS_BUILD_PROVIDED_VARS +=
14 DMBS_BUILD_PROVIDED_MACROS +=
16 # Conditionally import the CORE module of DMBS if it is not already imported
17 DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
18 ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),)
19 include $(DMBS_MODULE_PATH)/core.mk
22 # Default values of optionally user-supplied variables
23 AVRDUDE_PROGRAMMER ?= jtagicemkii
26 AVRDUDE_MEMORY ?= flash
28 # Sanity check user supplied values
29 $(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
30 $(call ERROR_IF_EMPTY, MCU)
31 $(call ERROR_IF_EMPTY, TARGET)
32 $(call ERROR_IF_EMPTY, AVRDUDE_PROGRAMMER)
33 $(call ERROR_IF_EMPTY, AVRDUDE_PORT)
36 MSG_AVRDUDE_CMD := ' [AVRDUDE] :'
38 # Construct base avrdude command flags
39 BASE_AVRDUDE_FLAGS := -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
41 # Programs in the target FLASH memory using AVRDUDE
42 avrdude: $(TARGET).hex $(MAKEFILE_LIST)
43 @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" FLASH using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
44 avrdude $(BASE_AVRDUDE_FLAGS) -U $(AVRDUDE_MEMORY):w:$< $(AVRDUDE_FLAGS)
46 # Programs in the target EEPROM memory using AVRDUDE
47 avrdude-ee: $(TARGET).eep $(MAKEFILE_LIST)
48 @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" EEPROM using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
49 avrdude $(BASE_AVRDUDE_FLAGS) -U eeprom:w:$< $(AVRDUDE_FLAGS)
51 # Phony build targets for this module
52 .PHONY: $(DMBS_BUILD_TARGETS)