2012-06-02 00:32:43 +02:00
#
# LUFA Library
# Copyright (C) Dean Camera, 2012.
#
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
2012-06-02 13:38:12 +02:00
LUFA_BUILD_MODULES += AVRDUDE
2012-06-04 18:31:50 +02:00
LUFA_BUILD_TARGETS += avrdude avrdude-ee
2012-06-02 13:38:12 +02:00
LUFA_BUILD_MANDATORY_VARS += MCU TARGET
LUFA_BUILD_OPTIONAL_VARS += AVRDUDE_PROGRAMMER AVRDUDE_PORT AVRDUDE_FLAGS
2012-06-02 00:32:43 +02:00
# -----------------------------------------------------------------------------
2012-06-02 23:47:16 +02:00
# LUFA AVRDUDE Programmer Buildsystem Makefile Module.
2012-06-02 00:32:43 +02:00
# -----------------------------------------------------------------------------
# DESCRIPTION:
# Provides a set of targets to re-program a device using the open source
# avr-dude utility.
# -----------------------------------------------------------------------------
# TARGETS:
#
2012-06-04 18:31:50 +02:00
# avrdude - Program target FLASH with application using
2012-06-02 14:21:14 +02:00
# avrdude
2012-06-04 18:31:50 +02:00
# avrdude-ee - Program target EEPROM with application data
2012-06-02 14:21:14 +02:00
# using avrdude
2012-06-02 00:32:43 +02:00
#
# MANDATORY PARAMETERS:
#
# MCU - Microcontroller device model name
# TARGET - Application name
#
# OPTIONAL PARAMETERS:
#
# AVRDUDE_PROGRAMMER - Name of programming hardware to use
# AVRDUDE_PORT - Name of communication port to use
# AVRDUDE_FLAGS - Flags to pass to avr-dude
#
# -----------------------------------------------------------------------------
2012-06-02 14:04:34 +02:00
# Sanity-check values of mandatory user-supplied variables
2012-06-03 14:39:53 +02:00
MCU ?= $(error Makefile MCU value not set)
TARGET ?= $(error Makefile TARGET value not set)
ifeq ($(MCU),)
$(error Makefile MCU option cannot be blank)
endif
ifeq ($(TARGET),)
$(error Makefile TARGET option cannot be blank)
endif
2012-06-02 00:32:43 +02:00
2012-06-02 14:04:34 +02:00
# Default values of optionally user-supplied variables
2012-06-02 14:00:51 +02:00
AVRDUDE_PROGRAMMER ?= jtagicemkii
AVRDUDE_PORT ?= usb
2012-06-02 14:21:14 +02:00
AVRDUDE_FLAGS ?=
2012-06-02 00:32:43 +02:00
2012-06-02 14:04:34 +02:00
# Output Messages
2012-06-02 23:45:51 +02:00
MSG_AVRDUDE_CMD := ' [AVRDUDE] :'
2012-06-02 00:32:43 +02:00
2012-06-04 18:31:50 +02:00
avrdude: $(TARGET).hex $(MAKEFILE_LIST)
@echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" FLASH with settings \"$(AVRDUDE_FLASH_FLAGS)\" using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
2012-06-06 21:22:20 +02:00
avrdude -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -U flash:w:$< $(AVRDUDE_FLAGS)
2012-06-02 14:21:14 +02:00
2012-06-04 18:31:50 +02:00
avrdude-ee: $(TARGET).eep $(MAKEFILE_LIST)
@echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" EEPROM with settings \"$(AVRDUDE_EEP_FLAGS)\" using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
2012-06-06 21:22:20 +02:00
avrdude -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -U eeprom:w:$< $(AVRDUDE_FLAGS)
2012-06-03 14:17:37 +02:00
# Phony build targets for this module
2012-06-04 18:31:50 +02:00
.PHONY: avrdude avrdude-ee