Update to latest version of DMBS.
[pub/USBasp.git] / LUFA / Build / DMBS / DMBS / dfu.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 += DFU
10 DMBS_BUILD_TARGETS += flip flip-ee dfu dfu-ee
11 DMBS_BUILD_MANDATORY_VARS += MCU TARGET
12 DMBS_BUILD_OPTIONAL_VARS +=
13 DMBS_BUILD_PROVIDED_VARS +=
14 DMBS_BUILD_PROVIDED_MACROS +=
15
16 SHELL = /bin/sh
17
18 ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
19 ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
20 ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
21
22 # Sanity-check values of mandatory user-supplied variables
23 $(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
24 $(call ERROR_IF_EMPTY, MCU)
25 $(call ERROR_IF_EMPTY, TARGET)
26
27 # Output Messages
28 MSG_COPY_CMD := ' [CP] :'
29 MSG_REMOVE_CMD := ' [RM] :'
30 MSG_DFU_CMD := ' [DFU] :'
31
32 # Programs in the target FLASH memory using BATCHISP, the command line tool used by FLIP
33 flip: $(TARGET).hex $(MAKEFILE_LIST)
34 @echo $(MSG_DFU_CMD) Programming FLASH with batchisp using \"$<\"
35 batchisp -hardware usb -device $(MCU) -operation erase f loadbuffer $< program
36 batchisp -hardware usb -device $(MCU) -operation start reset 0
37
38 # Programs in the target EEPROM memory using BATCHISP, the command line tool used by FLIP
39 flip-ee: $(TARGET).eep $(MAKEFILE_LIST)
40 @echo $(MSG_COPY_CMD) Copying EEP file to temporary file \"$<.hex\"
41 cp $< $<.hex
42 @echo $(MSG_DFU_CMD) Programming EEPROM with batchisp using \"$<.hex\"
43 batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $<.hex program
44 batchisp -hardware usb -device $(MCU) -operation start reset 0
45 @echo $(MSG_REMOVE_CMD) Removing temporary file \"$<.hex\"
46 rm $<.hex
47
48 # Programs in the target FLASH memory using DFU-PROGRAMMER
49 dfu: $(TARGET).hex $(MAKEFILE_LIST)
50 @echo $(MSG_DFU_CMD) Programming FLASH with dfu-programmer using \"$<\"
51 dfu-programmer $(MCU) erase
52 dfu-programmer $(MCU) flash $<
53 dfu-programmer $(MCU) reset
54
55 # Programs in the target EEPROM memory using DFU-PROGRAMMER
56 dfu-ee: $(TARGET).eep $(MAKEFILE_LIST)
57 @echo $(MSG_DFU_CMD) Programming EEPROM with dfu-programmer using \"$<\"
58 dfu-programmer $(MCU) flash --eeprom $<
59 dfu-programmer $(MCU) reset
60
61 # Phony build targets for this module
62 .PHONY: $(DMBS_BUILD_TARGETS)