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-02 23:58:24 +02:00
LUFA_BUILD_TARGETS += program program-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-02 14:21:14 +02:00
# program - Program target FLASH with application using
# avrdude
2012-06-02 23:58:24 +02:00
# program-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-02 14:21:14 +02:00
AVRDUDE_FLASH_FLAGS = -U flash:w:$< $(AVRDUDE_FLAGS)
AVRDUDE_EEP_FLAGS = -U eeprom:w:$< $(AVRDUDE_FLAGS)
2012-06-03 13:00:38 +02:00
program: $(TARGET).hex $(MAKEFILE_LIST)
2012-06-02 14:21:14 +02:00
@echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" with settings \"$(AVRDUDE_FLASH_FLAGS)\" using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
avrdude -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) $(AVRDUDE_FLASH_FLAGS)
2012-06-03 13:00:38 +02:00
program-ee: $(TARGET).eep $(MAKEFILE_LIST)
2012-06-02 14:21:14 +02:00
@echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" with settings \"$(AVRDUDE_EEP_FLAGS)\" using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
avrdude -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) $(AVRDUDE_EEP_FLAGS)
2012-06-03 14:17:37 +02:00
# Phony build targets for this module
.PHONY: program program-ee