3 # Copyright (C) Dean Camera, 2012.
5 # dean [at] fourwalledcubicle [dot] com
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 +=
14 # -----------------------------------------------------------------------------
15 # LUFA DFU Bootloader Buildsystem Makefile Module.
16 # -----------------------------------------------------------------------------
18 # Provides a set of targets to re-program a device currently running a DFU
19 # class bootloader with a project's FLASH and EEPROM files.
20 # -----------------------------------------------------------------------------
23 # flip - Program FLASH into target via Atmel FLIP
24 # flip-ee - Program EEPROM into target via Atmel FLIP
25 # dfu - Program FLASH into target via dfu-programmer
26 # dfu-ee - Program EEPROM into target via dfu-programmer
28 # MANDATORY PARAMETERS:
30 # MCU - Microcontroller device model name
31 # TARGET - Application name
33 # OPTIONAL PARAMETERS:
37 # -----------------------------------------------------------------------------
39 # Sanity-check values of mandatory user-supplied variables
40 MCU ?= $(error Makefile MCU value not set.)
41 TARGET ?= $(error Makefile TARGET value not set.)
44 MSG_COPY_CMD = ' [CP] :'
45 MSG_REMOVE_CMD = ' [RM] :'
46 MSG_DFU_CMD = ' [DFU] :'
49 @echo $(MSG_DFU_CMD) Programming FLASH with batchisp using \"$(TARGET).hex\"
50 batchisp -hardware usb -device $(MCU) -operation erase f
51 batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program
52 batchisp -hardware usb -device $(MCU) -operation start reset 0
54 flip-ee: $(TARGET).eep
55 @echo $(MSG_DFU_CMD) Copying EEP file to temporary file \"$(TARGET)eep.hex\"
56 cp $(TARGET).eep $(TARGET)eep.hex
57 @echo $(MSG_DFU_CMD) Programming EEPROM with batchisp using \"$(TARGET).eep\"
58 batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase
59 batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(TARGET)eep.hex program
60 batchisp -hardware usb -device $(MCU) -operation start reset 0
61 @echo $(MSG_DFU_CMD) Removing temporary file \"$(TARGET)eep.hex\"
65 @echo $(MSG_DFU_CMD) Programming FLASH with dfu-programmer using \"$(TARGET).hex\"
66 dfu-programmer $(MCU) erase
67 dfu-programmer $(MCU) flash $(TARGET).hex
68 dfu-programmer $(MCU) reset
70 dfu-ee: $(TARGET).hex $(TARGET).eep
71 @echo $(MSG_DFU_CMD) Programming EEPROM with dfu-programmer using \"$(TARGET).eep\"
72 dfu-programmer $(MCU) eeprom-flash $(TARGET).eep
73 dfu-programmer $(MCU) reset