3 # Copyright (C) Dean Camera, 2013.
5 # dean [at] fourwalledcubicle [dot] com
9 LUFA_BUILD_MODULES
+= HID
10 LUFA_BUILD_TARGETS
+= hid hid-ee teensy teensy-ee
11 LUFA_BUILD_MANDATORY_VARS
+= MCU TARGET
12 LUFA_BUILD_OPTIONAL_VARS
+=
13 LUFA_BUILD_PROVIDED_VARS
+=
14 LUFA_BUILD_PROVIDED_MACROS
+=
16 # -----------------------------------------------------------------------------
17 # LUFA HID Bootloader Buildsystem Makefile Module.
18 # -----------------------------------------------------------------------------
20 # Provides a set of targets to re-program a device currently running a HID
21 # class bootloader with a project's FLASH files.
22 # -----------------------------------------------------------------------------
25 # hid - Program FLASH into target via
27 # hid-ee - Program EEPROM into target via a temporary
28 # AVR application and hid_bootloader_cli
29 # teensy - Program FLASH into target via
31 # teensy-ee - Program EEPROM into target via a temporary
32 # AVR application and teensy_loader_cli
34 # MANDATORY PARAMETERS:
36 # MCU - Microcontroller device model name
37 # TARGET - Application name
39 # OPTIONAL PARAMETERS:
51 # -----------------------------------------------------------------------------
55 ERROR_IF_UNSET ?
= $(if
$(filter undefined
, $(origin $(strip $(1)))), $(error Makefile
$(strip $(1)) value not set
))
56 ERROR_IF_EMPTY ?
= $(if
$(strip $($(strip $(1)))), , $(error Makefile
$(strip $(1)) option cannot be blank
))
57 ERROR_IF_NONBOOL ?
= $(if
$(filter Y N
, $($(strip $(1)))), , $(error Makefile
$(strip $(1)) option must be Y or N
))
59 # Sanity-check values of mandatory user-supplied variables
60 $(foreach MANDATORY_VAR
, $(LUFA_BUILD_MANDATORY_VARS
), $(call ERROR_IF_UNSET
, $(MANDATORY_VAR
)))
61 $(call ERROR_IF_EMPTY
, MCU
)
62 $(call ERROR_IF_EMPTY
, TARGET
)
65 MSG_HID_BOOTLOADER_CMD
:= ' [HID] :'
66 MSG_OBJCPY_CMD
:= ' [OBJCPY] :'
67 MSG_MAKE_CMD
:= ' [MAKE] :'
69 # Programs in the target FLASH memory using the HID_BOOTLOADER_CLI tool
70 hid
: $(TARGET
).hex
$(MAKEFILE_LIST
)
71 @echo
$(MSG_HID_BOOTLOADER_CMD
) Programming FLASH with hid_bootloader_cli using
\"$<\"
72 hid_bootloader_cli
-mmcu
=$(MCU
) -v
$<
74 # Programs in the target EEPROM memory using the HID_BOOTLOADER_CLI tool (note: clears target FLASH memory)
75 hid-ee
: $(TARGET
).eep
$(MAKEFILE_LIST
)
76 @echo
$(MSG_OBJCPY_CMD
) Converting
\"$<\" to a binary file
\"InputEEData.bin
\"
77 avr-objcopy
-I ihex
-O binary
$< $(patsubst %/,%,$(LUFA_PATH
))/Build
/HID_EEPROM_Loader
/InputEEData.bin
78 @echo
$(MSG_MAKE_CMD
) Making EEPROM loader application for
\"$<\"
79 $(MAKE
) -C
$(patsubst %/,%,$(LUFA_PATH
))/Build
/HID_EEPROM_Loader
/ MCU
=$(MCU
) clean hid
81 # Programs in the target FLASH memory using the TEENSY_BOOTLOADER_CLI tool
82 teensy
: $(TARGET
).hex
$(MAKEFILE_LIST
)
83 @echo
$(MSG_HID_BOOTLOADER_CMD
) Programming FLASH with teensy_loader_cli using
\"$<\"
84 teensy_loader_cli
-mmcu
=$(MCU
) -v
$<
86 # Programs in the target EEPROM memory using the TEENSY_BOOTLOADER_CLI tool (note: clears target FLASH memory)
87 teensy-ee
: $(TARGET
).hex
$(MAKEFILE_LIST
)
88 @echo
$(MSG_OBJCPY_CMD
) Converting
\"$<\" to a binary file
\"InputEEData.bin
\"
89 avr-objcopy
-I ihex
-O binary
$< $(patsubst %/,%,$(LUFA_PATH
))/Build
/HID_EEPROM_Loader
/InputEEData.bin
90 @echo
$(MSG_MAKE_CMD
) Making EEPROM loader application for
\"$<\"
91 $(MAKE
) -s
-C
$(patsubst %/,%,$(LUFA_PATH
))/Build
/HID_EEPROM_Loader
/ MCU
=$(MCU
) clean hid-teensy
93 # Phony build targets for this module
94 .PHONY
: hid hid-ee teensy teensy-ee