3 # Released into the public domain.
5 # dean [at] fourwalledcubicle [dot] com
6 # www.fourwalledcubicle.com
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
+=
16 # Import the CORE module of DMBS
17 DMBS_MODULE_PATH
:= $(patsubst %/,%,$(dir $(lastword
$(MAKEFILE_LIST
))))
18 include $(DMBS_MODULE_PATH
)/core.mk
20 # Sanity-check values of mandatory user-supplied variables
21 $(foreach MANDATORY_VAR
, $(DMBS_BUILD_MANDATORY_VARS
), $(call ERROR_IF_UNSET
, $(MANDATORY_VAR
)))
22 $(call ERROR_IF_EMPTY
, MCU
)
23 $(call ERROR_IF_EMPTY
, TARGET
)
26 MSG_COPY_CMD
:= ' [CP] :'
27 MSG_REMOVE_CMD
:= ' [RM] :'
28 MSG_DFU_CMD
:= ' [DFU] :'
30 # Programs in the target FLASH memory using BATCHISP, the command line tool used by FLIP
31 flip
: $(TARGET
).hex
$(MAKEFILE_LIST
)
32 @echo
$(MSG_DFU_CMD
) Programming FLASH with batchisp using
\"$<\"
33 batchisp
-hardware usb
-device
$(MCU
) -operation erase f loadbuffer
$< program
34 batchisp
-hardware usb
-device
$(MCU
) -operation start reset
0
36 # Programs in the target EEPROM memory using BATCHISP, the command line tool used by FLIP
37 flip-ee
: $(TARGET
).eep
$(MAKEFILE_LIST
)
38 @echo
$(MSG_COPY_CMD
) Copying EEP file to temporary file
\"$<.hex
\"
40 @echo
$(MSG_DFU_CMD
) Programming EEPROM with batchisp using
\"$<.hex
\"
41 batchisp
-hardware usb
-device
$(MCU
) -operation memory EEPROM loadbuffer
$<.hex program
42 batchisp
-hardware usb
-device
$(MCU
) -operation start reset
0
43 @echo
$(MSG_REMOVE_CMD
) Removing temporary file
\"$<.hex
\"
46 # Programs in the target FLASH memory using DFU-PROGRAMMER
47 dfu
: $(TARGET
).hex
$(MAKEFILE_LIST
)
48 @echo
$(MSG_DFU_CMD
) Programming FLASH with dfu-programmer using
\"$<\"
49 dfu-programmer
$(MCU
) erase
50 dfu-programmer
$(MCU
) flash
$<
51 dfu-programmer
$(MCU
) reset
53 # Programs in the target EEPROM memory using DFU-PROGRAMMER
54 dfu-ee
: $(TARGET
).eep
$(MAKEFILE_LIST
)
55 @echo
$(MSG_DFU_CMD
) Programming EEPROM with dfu-programmer using
\"$<\"
56 dfu-programmer
$(MCU
) flash
--eeprom
$<
57 dfu-programmer
$(MCU
) reset
59 # Phony build targets for this module
60 .PHONY
: $(DMBS_BUILD_TARGETS
)