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
+=
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
))
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
)
28 MSG_COPY_CMD
:= ' [CP] :'
29 MSG_REMOVE_CMD
:= ' [RM] :'
30 MSG_DFU_CMD
:= ' [DFU] :'
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
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
\"
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
\"
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
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
61 # Phony build targets for this module
62 .PHONY
: $(DMBS_BUILD_TARGETS
)