lufa.avrdude.in 2.66 KB
Newer Older
1
2
3
4
5
6
7
8
#
#             LUFA Library
#     Copyright (C) Dean Camera, 2012.
#
#  dean [at] fourwalledcubicle [dot] com
#           www.lufa-lib.org
#

9
LUFA_BUILD_MODULES        += AVRDUDE
10
LUFA_BUILD_TARGETS        += avrdude avrdude-ee
11
12
LUFA_BUILD_MANDATORY_VARS += MCU TARGET
LUFA_BUILD_OPTIONAL_VARS  += AVRDUDE_PROGRAMMER AVRDUDE_PORT AVRDUDE_FLAGS
13
14

# -----------------------------------------------------------------------------
15
#             LUFA AVRDUDE Programmer Buildsystem Makefile Module.
16
17
18
19
20
21
22
# -----------------------------------------------------------------------------
# DESCRIPTION:
#   Provides a set of targets to re-program a device using the open source
#   avr-dude utility.
# -----------------------------------------------------------------------------
# TARGETS:
#
23
#    avrdude                   - Program target FLASH with application using
24
#                                avrdude
25
#    avrdude-ee                - Program target EEPROM with application data
26
#                                using avrdude
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#
# 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
#
# -----------------------------------------------------------------------------

41
# Sanity-check values of mandatory user-supplied variables
42
43
44
45
46
47
48
49
50
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
51

52
# Default values of optionally user-supplied variables
53
54
AVRDUDE_PROGRAMMER ?= jtagicemkii
AVRDUDE_PORT       ?= usb
55
AVRDUDE_FLAGS      ?= 
56

57
# Output Messages
58
MSG_AVRDUDE_CMD    := ' [AVRDUDE] :'
59

60
61
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)\"
62
	avrdude -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -U flash:w:$< $(AVRDUDE_FLAGS)
63

64
65
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)\"
66
	avrdude -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -U eeprom:w:$< $(AVRDUDE_FLAGS)
67
68

# Phony build targets for this module
69
.PHONY: avrdude avrdude-ee