Documentation: Fix Doxygen grouping.
[pub/USBasp.git] / LUFA / Build / DMBS / DMBS / avrdude.mk
1 #
2 # DMBS Build System
3 # Released into the public domain.
4 #
5 # dean [at] fourwalledcubicle [dot] com
6 # www.fourwalledcubicle.com
7 #
8
9 DMBS_BUILD_MODULES += AVRDUDE
10 DMBS_BUILD_TARGETS += avrdude-lfuse avrdude-hfuse avrdude-efuse avrdude-lock avrdude-fuses
11 DMBS_BUILD_TARGETS += avrdude avrdude-ee avrdude-all avrdude-all-ee
12 DMBS_BUILD_MANDATORY_VARS += MCU TARGET
13 DMBS_BUILD_OPTIONAL_VARS += AVRDUDE_PROGRAMMER AVRDUDE_PORT AVRDUDE_FLAGS AVRDUDE_MEMORY AVRDUDE_BAUD
14 DMBS_BUILD_OPTIONAL_VARS += AVRDUDE_LFUSE AVRDUDE_HFUSE AVRDUDE_EUSE AVRDUDE_LOCK
15 DMBS_BUILD_PROVIDED_VARS +=
16 DMBS_BUILD_PROVIDED_MACROS +=
17
18 # Import the CORE module of DMBS
19 DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
20 include $(DMBS_MODULE_PATH)/core.mk
21
22 # Default values of optionally user-supplied variables
23 AVRDUDE_PROGRAMMER ?= jtagicemkii
24 AVRDUDE_PORT ?= usb
25 AVRDUDE_FLAGS ?=
26 AVRDUDE_MEMORY ?= flash
27 AVRDUDE_LFUSE ?=
28 AVRDUDE_HFUSE ?=
29 AVRDUDE_EFUSE ?=
30 AVRDUDE_LOCK ?=
31 AVRDUDE_BAUD ?=
32
33 # Sanity check user supplied values
34 $(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
35 $(call ERROR_IF_EMPTY, MCU)
36 $(call ERROR_IF_EMPTY, TARGET)
37 $(call ERROR_IF_EMPTY, AVRDUDE_PROGRAMMER)
38 $(call ERROR_IF_EMPTY, AVRDUDE_PORT)
39
40 # Output Messages
41 MSG_AVRDUDE_CMD := ' [AVRDUDE] :'
42
43 # Construct base avrdude command flags
44 BASE_AVRDUDE_FLAGS := -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
45 ifneq ($(AVRDUDE_BAUD),)
46 BASE_AVRDUDE_FLAGS += -b $(AVRDUDE_BAUD)
47 endif
48
49 # Programs in the target FLASH memory using AVRDUDE
50 avrdude: $(TARGET).hex $(MAKEFILE_LIST)
51 @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" FLASH using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
52 avrdude $(BASE_AVRDUDE_FLAGS) -U $(AVRDUDE_MEMORY):w:$< $(AVRDUDE_FLAGS)
53
54 # Programs in the target EEPROM memory using AVRDUDE
55 avrdude-ee: $(TARGET).eep $(MAKEFILE_LIST)
56 @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" EEPROM using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
57 avrdude $(BASE_AVRDUDE_FLAGS) -U eeprom:w:$< $(AVRDUDE_FLAGS)
58
59 # Programs in the target fuses using AVRDUDE
60 avrdude-lfuse: $(MAKEFILE_LIST)
61 @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" low fuse using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
62 $(call ERROR_IF_EMPTY, AVRDUDE_LFUSE)
63 avrdude $(BASE_AVRDUDE_FLAGS) -Ulfuse:w:$(AVRDUDE_LFUSE):m $(AVRDUDE_FLAGS)
64
65 avrdude-hfuse: $(MAKEFILE_LIST)
66 @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" high fuse using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
67 $(call ERROR_IF_EMPTY, AVRDUDE_HFUSE)
68 avrdude $(BASE_AVRDUDE_FLAGS) -Uhfuse:w:$(AVRDUDE_HFUSE):m $(AVRDUDE_FLAGS)
69
70 avrdude-efuse: $(MAKEFILE_LIST)
71 @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" extended fuse using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
72 $(call ERROR_IF_EMPTY, AVRDUDE_EFUSE)
73 avrdude $(BASE_AVRDUDE_FLAGS) -Uefuse:w:$(AVRDUDE_EFUSE):m $(AVRDUDE_FLAGS)
74
75 avrdude-lock: $(MAKEFILE_LIST)
76 @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" lock bits using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
77 $(call ERROR_IF_EMPTY, AVRDUDE_LOCK)
78 avrdude $(BASE_AVRDUDE_FLAGS) -Ulock:w:$(AVRDUDE_LOCK):m $(AVRDUDE_FLAGS)
79
80 avrdude-fuses: avrdude-lfuse avrdude-hfuse avrdude-efuse avrdude-lock
81
82 avrdude-all: avrdude avrdude-fuses
83
84 avrdude-all-ee: avrdude avrdude-ee avrdude-fuses
85
86 # Phony build targets for this module
87 .PHONY: $(DMBS_BUILD_TARGETS)