3 # Copyright (C) Dean Camera, 2012.
5 # dean [at] fourwalledcubicle [dot] com
9 LUFA_BUILD_MODULES += AVRDUDE
10 LUFA_BUILD_TARGETS += program program-ee
11 LUFA_BUILD_MANDATORY_VARS += MCU TARGET
12 LUFA_BUILD_OPTIONAL_VARS += AVRDUDE_PROGRAMMER AVRDUDE_PORT AVRDUDE_FLAGS
14 # -----------------------------------------------------------------------------
15 # LUFA AVRDUDE Programmer Buildsystem Makefile Module.
16 # -----------------------------------------------------------------------------
18 # Provides a set of targets to re-program a device using the open source
20 # -----------------------------------------------------------------------------
23 # program - Program target FLASH with application using
25 # program-ee - Program target EEPROM with application data
28 # MANDATORY PARAMETERS:
30 # MCU - Microcontroller device model name
31 # TARGET - Application name
33 # OPTIONAL PARAMETERS:
35 # AVRDUDE_PROGRAMMER - Name of programming hardware to use
36 # AVRDUDE_PORT - Name of communication port to use
37 # AVRDUDE_FLAGS - Flags to pass to avr-dude
39 # -----------------------------------------------------------------------------
41 # Sanity-check values of mandatory user-supplied variables
42 MCU ?= $(error Makefile MCU value not set)
43 TARGET ?= $(error Makefile TARGET value not set)
46 $(error Makefile MCU option cannot be blank)
49 $(error Makefile TARGET option cannot be blank)
52 # Default values of optionally user-supplied variables
53 AVRDUDE_PROGRAMMER ?= jtagicemkii
58 MSG_AVRDUDE_CMD := ' [AVRDUDE] :'
60 AVRDUDE_FLASH_FLAGS = -U flash:w:$< $(AVRDUDE_FLAGS)
61 AVRDUDE_EEP_FLAGS = -U eeprom:w:$< $(AVRDUDE_FLAGS)
63 program: $(TARGET).hex $(MAKEFILE_LIST)
64 @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" with settings \"$(AVRDUDE_FLASH_FLAGS)\" using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
65 avrdude -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) $(AVRDUDE_FLASH_FLAGS)
67 program-ee: $(TARGET).eep $(MAKEFILE_LIST)
68 @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" with settings \"$(AVRDUDE_EEP_FLAGS)\" using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
69 avrdude -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) $(AVRDUDE_EEP_FLAGS)
71 # Phony build targets for this module
72 .PHONY: program program-ee