Fix BUILD module so that user flags are applied after all auto-generated flags, ensur...
[pub/USBasp.git] / LUFA / Build / lufa.dfu.in
1 #
2 # LUFA Library
3 # Copyright (C) Dean Camera, 2012.
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
14 # -----------------------------------------------------------------------------
15 # LUFA DFU Bootloader Buildsystem Makefile Module.
16 # -----------------------------------------------------------------------------
17 # DESCRIPTION:
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 # -----------------------------------------------------------------------------
21 # TARGETS:
22 #
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
27 #
28 # MANDATORY PARAMETERS:
29 #
30 # MCU - Microcontroller device model name
31 # TARGET - Application name
32 #
33 # OPTIONAL PARAMETERS:
34 #
35 # (None)
36 #
37 # -----------------------------------------------------------------------------
38
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)
42
43 ifeq ($(MCU),)
44 $(error Makefile MCU option cannot be blank)
45 endif
46 ifeq ($(TARGET),)
47 $(error Makefile TARGET option cannot be blank)
48 endif
49
50 # Output Messages
51 MSG_COPY_CMD := ' [CP] :'
52 MSG_REMOVE_CMD := ' [RM] :'
53 MSG_DFU_CMD := ' [DFU] :'
54
55 flip: $(TARGET).hex $(MAKEFILE_LIST)
56 @echo $(MSG_DFU_CMD) Programming FLASH with batchisp using \"$<\"
57 batchisp -hardware usb -device $(MCU) -operation erase f
58 batchisp -hardware usb -device $(MCU) -operation loadbuffer $< program
59 batchisp -hardware usb -device $(MCU) -operation start reset 0
60
61 flip-ee: $(TARGET).eep $(MAKEFILE_LIST)
62 @echo $(MSG_DFU_CMD) Copying EEP file to temporary file \"$<.hex\"
63 cp $< $<.hex
64 @echo $(MSG_DFU_CMD) Programming EEPROM with batchisp using \"$<.hex\"
65 batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase
66 batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $<.hex program
67 batchisp -hardware usb -device $(MCU) -operation start reset 0
68 @echo $(MSG_DFU_CMD) Removing temporary file \"$<.hex\"
69 rm $<.hex
70
71 dfu: $(TARGET).hex $(MAKEFILE_LIST)
72 @echo $(MSG_DFU_CMD) Programming FLASH with dfu-programmer using \"$<\"
73 dfu-programmer $(MCU) erase
74 dfu-programmer $(MCU) flash $<
75 dfu-programmer $(MCU) reset
76
77 dfu-ee: $(TARGET).eep $(MAKEFILE_LIST)
78 @echo $(MSG_DFU_CMD) Programming EEPROM with dfu-programmer using \"$<\"
79 dfu-programmer $(MCU) eeprom-flash $<
80 dfu-programmer $(MCU) reset
81
82 # Phony build targets for this module
83 .PHONY: flip flip-ee dfu dfu-ee