]> git.gir.st - tmk_keyboard.git/blob - tmk_core/protocol/lufa/LUFA-git/LUFA/Build/lufa_dfu.mk
Merge commit 'f6d56675f9f981c5464f0ca7a1fbb0162154e8c5'
[tmk_keyboard.git] / tmk_core / protocol / lufa / LUFA-git / LUFA / Build / lufa_dfu.mk
1 #
2 # LUFA Library
3 # Copyright (C) Dean Camera, 2014.
4 #
5 # dean [at] fourwalledcubicle [dot] com
6 # www.lufa-lib.org
7 #
8
9 LUFA_BUILD_MODULES += DFU
10 LUFA_BUILD_TARGETS += flip flip-ee dfu dfu-ee
11 LUFA_BUILD_MANDATORY_VARS += MCU TARGET
12 LUFA_BUILD_OPTIONAL_VARS +=
13 LUFA_BUILD_PROVIDED_VARS +=
14 LUFA_BUILD_PROVIDED_MACROS +=
15
16 # -----------------------------------------------------------------------------
17 # LUFA DFU Bootloader Buildsystem Makefile Module.
18 # -----------------------------------------------------------------------------
19 # DESCRIPTION:
20 # Provides a set of targets to re-program a device currently running a DFU
21 # class bootloader with a project's FLASH and EEPROM files.
22 # -----------------------------------------------------------------------------
23 # TARGETS:
24 #
25 # flip - Program FLASH into target via Atmel FLIP
26 # flip-ee - Program EEPROM into target via Atmel FLIP
27 # dfu - Program FLASH into target via dfu-programmer
28 # dfu-ee - Program EEPROM into target via dfu-programmer
29 #
30 # MANDATORY PARAMETERS:
31 #
32 # MCU - Microcontroller device model name
33 # TARGET - Application name
34 #
35 # OPTIONAL PARAMETERS:
36 #
37 # (None)
38 #
39 # PROVIDED VARIABLES:
40 #
41 # (None)
42 #
43 # PROVIDED MACROS:
44 #
45 # (None)
46 #
47 # -----------------------------------------------------------------------------
48
49 SHELL = /bin/sh
50
51 ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
52 ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
53 ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
54
55 # Sanity-check values of mandatory user-supplied variables
56 $(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
57 $(call ERROR_IF_EMPTY, MCU)
58 $(call ERROR_IF_EMPTY, TARGET)
59
60 # Output Messages
61 MSG_COPY_CMD := ' [CP] :'
62 MSG_REMOVE_CMD := ' [RM] :'
63 MSG_DFU_CMD := ' [DFU] :'
64
65 # Programs in the target FLASH memory using BATCHISP, the command line tool used by FLIP
66 flip: $(TARGET).hex $(MAKEFILE_LIST)
67 @echo $(MSG_DFU_CMD) Programming FLASH with batchisp using \"$<\"
68 batchisp -hardware usb -device $(MCU) -operation erase f loadbuffer $< program
69 batchisp -hardware usb -device $(MCU) -operation start reset 0
70
71 # Programs in the target EEPROM memory using BATCHISP, the command line tool used by FLIP
72 flip-ee: $(TARGET).eep $(MAKEFILE_LIST)
73 @echo $(MSG_COPY_CMD) Copying EEP file to temporary file \"$<.hex\"
74 cp $< $<.hex
75 @echo $(MSG_DFU_CMD) Programming EEPROM with batchisp using \"$<.hex\"
76 batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $<.hex program
77 batchisp -hardware usb -device $(MCU) -operation start reset 0
78 @echo $(MSG_REMOVE_CMD) Removing temporary file \"$<.hex\"
79 rm $<.hex
80
81 # Programs in the target FLASH memory using DFU-PROGRAMMER
82 dfu: $(TARGET).hex $(MAKEFILE_LIST)
83 @echo $(MSG_DFU_CMD) Programming FLASH with dfu-programmer using \"$<\"
84 dfu-programmer $(MCU) erase
85 dfu-programmer $(MCU) flash $<
86 dfu-programmer $(MCU) reset
87
88 # Programs in the target EEPROM memory using DFU-PROGRAMMER
89 dfu-ee: $(TARGET).eep $(MAKEFILE_LIST)
90 @echo $(MSG_DFU_CMD) Programming EEPROM with dfu-programmer using \"$<\"
91 dfu-programmer $(MCU) eeprom-flash $<
92 dfu-programmer $(MCU) reset
93
94 # Phony build targets for this module
95 .PHONY: flip flip-ee dfu dfu-ee
Imprint / Impressum