]> git.gir.st - tmk_keyboard.git/blob - protocol/lufa/LUFA-120730/LUFA/Build/lufa_atprogram.mk
Change TOP_DIR to TMK_DIR in makefiles
[tmk_keyboard.git] / protocol / lufa / LUFA-120730 / LUFA / Build / lufa_atprogram.mk
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 += ATPROGRAM
10 LUFA_BUILD_TARGETS += atprogram atprogram-ee
11 LUFA_BUILD_MANDATORY_VARS += MCU TARGET
12 LUFA_BUILD_OPTIONAL_VARS += ATPROGRAM_PROGRAMMER ATPROGRAM_INTERFACE ATPROGRAM_PORT
13 LUFA_BUILD_PROVIDED_VARS +=
14 LUFA_BUILD_PROVIDED_MACROS +=
15
16 # -----------------------------------------------------------------------------
17 # LUFA ATPROGRAM Programmer Buildsystem Makefile Module.
18 # -----------------------------------------------------------------------------
19 # DESCRIPTION:
20 # Provides a set of targets to re-program a device using the Atmel atprogram
21 # utility in AVR Studio 5.x and Atmel Studio 6.0 onwards.
22 # -----------------------------------------------------------------------------
23 # TARGETS:
24 #
25 # atprogram - Program target FLASH with application using
26 # atprogram
27 # atprogram-ee - Program target EEPROM with application data
28 # using atprogram
29 #
30 # MANDATORY PARAMETERS:
31 #
32 # MCU - Microcontroller device model name
33 # TARGET - Application name
34 #
35 # OPTIONAL PARAMETERS:
36 #
37 # ATPROGRAM_PROGRAMMER - Name of programming hardware to use
38 # ATPROGRAM_INTERFACE - Name of programming interface to use
39 # ATPROGRAM_PORT - Name of communication port to use
40 #
41 # PROVIDED VARIABLES:
42 #
43 # (None)
44 #
45 # PROVIDED MACROS:
46 #
47 # (None)
48 #
49 # -----------------------------------------------------------------------------
50
51 SHELL = /bin/sh
52
53 ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
54 ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
55 ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
56
57 # Default values of optionally user-supplied variables
58 ATPROGRAM_PROGRAMMER ?= jtagice3
59 ATPROGRAM_INTERFACE ?= jtag
60 ATPROGRAM_PORT ?=
61
62 # Sanity check user supplied values
63 $(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
64 $(call ERROR_IF_EMPTY, MCU)
65 $(call ERROR_IF_EMPTY, TARGET)
66 $(call ERROR_IF_EMPTY, ATPROGRAM_PROGRAMMER)
67 $(call ERROR_IF_EMPTY, ATPROGRAM_INTERFACE)
68
69 # Output Messages
70 MSG_ATPROGRAM_CMD := ' [ATPRGRM] :'
71
72 # Construct base atprogram command flags
73 BASE_ATPROGRAM_FLAGS := --tool $(ATPROGRAM_PROGRAMMER) --interface $(ATPROGRAM_INTERFACE) --device $(MCU)
74 ifneq ($(ATPROGRAM_PORT),)
75 BASE_ATPROGRAM_FLAGS += --port $(ATPROGRAM_PORT)
76 endif
77
78 # Construct the flags to use for the various memory spaces
79 ifeq ($(ARCH), AVR8)
80 ATPROGRAM_FLASH_FLAGS := --chiperase --flash
81 ATPROGRAM_EEPROM_FLAGS := --eeprom
82 else ifeq ($(ARCH), XMEGA)
83 ATPROGRAM_FLASH_FLAGS := --erase --flash
84 ATPROGRAM_EEPROM_FLAGS := --eeprom
85 else ifeq ($(ARCH), UC3)
86 ATPROGRAM_FLASH_FLAGS := --erase
87 ATPROGRAM_EEPROM_FLAGS := --eeprom
88 else
89 $(error Unsupported architecture "$(ARCH)")
90 endif
91
92 atprogram: $(TARGET).elf $(MAKEFILE_LIST)
93 @echo $(MSG_ATPROGRAM_CMD) Programming device \"$(MCU)\" FLASH using \"$(ATPROGRAM_PROGRAMMER)\"
94 atprogram $(BASE_ATPROGRAM_FLAGS) program $(ATPROGRAM_FLASH_FLAGS) --file $<
95
96 atprogram-ee: $(TARGET).elf $(MAKEFILE_LIST)
97 @echo $(MSG_ATPROGRAM_CMD) Programming device \"$(MCU)\" EEPROM using \"$(ATPROGRAM_PROGRAMMER)\"
98 atprogram $(BASE_ATPROGRAM_FLAGS) program $(ATPROGRAM_EEPROM_FLAGS) --file $<
99
100 # Phony build targets for this module
101 .PHONY: atprogram atprogram-ee
Imprint / Impressum