7 |
pfowler |
1 |
# Hey Emacs, this is a -*- makefile -*-
|
|
|
2 |
#----------------------------------------------------------------------------
|
|
|
3 |
# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
|
|
|
4 |
#
|
|
|
5 |
# Released to the Public Domain
|
|
|
6 |
#
|
|
|
7 |
# Additional material for this makefile was written by:
|
|
|
8 |
# Peter Fleury
|
|
|
9 |
# Tim Henigan
|
|
|
10 |
# Colin O'Flynn
|
|
|
11 |
# Reiner Patommel
|
|
|
12 |
# Markus Pfaff
|
|
|
13 |
# Sander Pool
|
|
|
14 |
# Frederik Rouleau
|
|
|
15 |
# Carlos Lamas
|
|
|
16 |
#
|
|
|
17 |
#----------------------------------------------------------------------------
|
|
|
18 |
# On command line:
|
|
|
19 |
#
|
|
|
20 |
# make all = Make software.
|
|
|
21 |
#
|
|
|
22 |
# make clean = Clean out built project files.
|
|
|
23 |
#
|
|
|
24 |
# make coff = Convert ELF to AVR COFF.
|
|
|
25 |
#
|
|
|
26 |
# make extcoff = Convert ELF to AVR Extended COFF.
|
|
|
27 |
#
|
|
|
28 |
# make program = Download the hex file to the device, using avrdude.
|
|
|
29 |
# Please customize the avrdude settings below first!
|
|
|
30 |
#
|
|
|
31 |
# make fuse = Program fuse bits using avrdude
|
|
|
32 |
#
|
|
|
33 |
# make debug = Start either simulavr or avarice as specified for debugging,
|
|
|
34 |
# with avr-gdb or avr-insight as the front end for debugging.
|
|
|
35 |
#
|
|
|
36 |
# make filename.s = Just compile filename.c into the assembler code only.
|
|
|
37 |
#
|
|
|
38 |
# make filename.i = Create a preprocessed source file for use in submitting
|
|
|
39 |
# bug reports to the GCC project.
|
|
|
40 |
#
|
|
|
41 |
# To rebuild project do "make clean" then "make all".
|
|
|
42 |
#----------------------------------------------------------------------------
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
# MCU name
|
|
|
46 |
MCU = attiny85
|
|
|
47 |
|
|
|
48 |
# FUSE Settings for device
|
|
|
49 |
# Note - varies from device to device. Some devices have efuse too.
|
|
|
50 |
FUSES = -U hfuse:w:hfuse.hex:i -U lfuse:w:lfuse.hex:i -U efuse:w:efuse.hex:i -u
|
|
|
51 |
|
|
|
52 |
# Processor frequency.
|
|
|
53 |
# This will define a symbol, F_CPU, in all source code files equal to the
|
|
|
54 |
# processor frequency. You can then use this symbol in your source code to
|
|
|
55 |
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
|
|
56 |
# automatically to create a 32-bit value in your source code.
|
|
|
57 |
# Typical values are:
|
|
|
58 |
# F_CPU = 1000000
|
|
|
59 |
# F_CPU = 1843200
|
|
|
60 |
# F_CPU = 2000000
|
|
|
61 |
# F_CPU = 3686400
|
|
|
62 |
# F_CPU = 4000000
|
|
|
63 |
# F_CPU = 7372800
|
|
|
64 |
# F_CPU = 8000000
|
|
|
65 |
# F_CPU = 11059200
|
|
|
66 |
# F_CPU = 14745600
|
|
|
67 |
# F_CPU = 16000000
|
|
|
68 |
# F_CPU = 18432000
|
|
|
69 |
# F_CPU = 20000000
|
|
|
70 |
F_CPU = 16500000
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
# Output format. (can be srec, ihex, binary)
|
|
|
74 |
FORMAT = ihex
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
# Target file name (without extension).
|
|
|
78 |
TARGET = main
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
# Object files directory
|
|
|
82 |
# To put object files in current directory, use a dot (.), do NOT make
|
|
|
83 |
# this an empty or blank macro!
|
|
|
84 |
OBJDIR = .
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
# List C source files here. (C dependencies are automatically generated.)
|
|
|
88 |
SRC = $(TARGET).c usbdrv/usbdrv.c /usbdrv/oddebug.c
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
# List C++ source files here. (C dependencies are automatically generated.)
|
|
|
92 |
CPPSRC =
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
# List Assembler source files here.
|
|
|
96 |
# Make them always end in a capital .S. Files ending in a lowercase .s
|
|
|
97 |
# will not be considered source files but generated files (assembler
|
|
|
98 |
# output from the compiler), and will be deleted upon "make clean"!
|
|
|
99 |
# Even though the DOS/Win* filesystem matches both .s and .S the same,
|
|
|
100 |
# it will preserve the spelling of the filenames, and gcc itself does
|
|
|
101 |
# care about how the name is spelled on its command-line.
|
|
|
102 |
ASRC = usbdrv/usbdrvasm.S
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
# Optimization level, can be [0, 1, 2, 3, s].
|
|
|
106 |
# 0 = turn off optimization. s = optimize for size.
|
|
|
107 |
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
|
|
108 |
OPT = 2
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
# Debugging format.
|
|
|
112 |
# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
|
|
|
113 |
# AVR Studio 4.10 requires dwarf-2.
|
|
|
114 |
# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
|
|
|
115 |
DEBUG = dwarf-2
|
|
|
116 |
|
|
|
117 |
|
|
|
118 |
# List any extra directories to look for include files here.
|
|
|
119 |
# Each directory must be seperated by a space.
|
|
|
120 |
# Use forward slashes for directory separators.
|
|
|
121 |
# For a directory that has spaces, enclose it in quotes.
|
|
|
122 |
EXTRAINCDIRS = .
|
|
|
123 |
|
|
|
124 |
|
|
|
125 |
# Compiler flag to set the C Standard level.
|
|
|
126 |
# c89 = "ANSI" C
|
|
|
127 |
# gnu89 = c89 plus GCC extensions
|
|
|
128 |
# c99 = ISO C99 standard (not yet fully implemented)
|
|
|
129 |
# gnu99 = c99 plus GCC extensions
|
|
|
130 |
CSTANDARD = -std=gnu99
|
|
|
131 |
|
|
|
132 |
|
|
|
133 |
# Place -D or -U options here for C sources
|
|
|
134 |
CDEFS = -DF_CPU=$(F_CPU)UL
|
|
|
135 |
|
|
|
136 |
|
|
|
137 |
# Place -D or -U options here for ASM sources
|
|
|
138 |
ADEFS = -DF_CPU=$(F_CPU)
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
# Place -D or -U options here for C++ sources
|
|
|
142 |
CPPDEFS = -DF_CPU=$(F_CPU)UL
|
|
|
143 |
#CPPDEFS += -D__STDC_LIMIT_MACROS
|
|
|
144 |
#CPPDEFS += -D__STDC_CONSTANT_MACROS
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
|
|
|
148 |
#---------------- Compiler Options C ----------------
|
|
|
149 |
# -g*: generate debugging information
|
|
|
150 |
# -O*: optimization level
|
|
|
151 |
# -f...: tuning, see GCC manual and avr-libc documentation
|
|
|
152 |
# -Wall...: warning level
|
|
|
153 |
# -Wa,...: tell GCC to pass this to the assembler.
|
|
|
154 |
# -adhlns...: create assembler listing
|
|
|
155 |
CFLAGS = -g$(DEBUG)
|
|
|
156 |
CFLAGS += $(CDEFS)
|
|
|
157 |
CFLAGS += -O$(OPT)
|
|
|
158 |
CFLAGS += -funsigned-char
|
|
|
159 |
CFLAGS += -funsigned-bitfields
|
|
|
160 |
CFLAGS += -fpack-struct
|
|
|
161 |
CFLAGS += -fshort-enums
|
|
|
162 |
CFLAGS += -Wall
|
|
|
163 |
CFLAGS += -Wstrict-prototypes
|
|
|
164 |
#CFLAGS += -mshort-calls
|
|
|
165 |
#CFLAGS += -fno-unit-at-a-time
|
|
|
166 |
#CFLAGS += -Wundef
|
|
|
167 |
#CFLAGS += -Wunreachable-code
|
|
|
168 |
#CFLAGS += -Wsign-compare
|
|
|
169 |
CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst)
|
|
|
170 |
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|
|
171 |
CFLAGS += $(CSTANDARD)
|
|
|
172 |
CFLAGS += -DDEBUG_LEVEL=0
|
|
|
173 |
|
|
|
174 |
|
|
|
175 |
#---------------- Compiler Options C++ ----------------
|
|
|
176 |
# -g*: generate debugging information
|
|
|
177 |
# -O*: optimization level
|
|
|
178 |
# -f...: tuning, see GCC manual and avr-libc documentation
|
|
|
179 |
# -Wall...: warning level
|
|
|
180 |
# -Wa,...: tell GCC to pass this to the assembler.
|
|
|
181 |
# -adhlns...: create assembler listing
|
|
|
182 |
CPPFLAGS = -g$(DEBUG)
|
|
|
183 |
CPPFLAGS += $(CPPDEFS)
|
|
|
184 |
CPPFLAGS += -O$(OPT)
|
|
|
185 |
CPPFLAGS += -funsigned-char
|
|
|
186 |
CPPFLAGS += -funsigned-bitfields
|
|
|
187 |
CPPFLAGS += -fpack-struct
|
|
|
188 |
CPPFLAGS += -fshort-enums
|
|
|
189 |
CPPFLAGS += -fno-exceptions
|
|
|
190 |
CPPFLAGS += -Wall
|
|
|
191 |
CPPFLAGS += -Wundef
|
|
|
192 |
#CPPFLAGS += -mshort-calls
|
|
|
193 |
#CPPFLAGS += -fno-unit-at-a-time
|
|
|
194 |
#CPPFLAGS += -Wstrict-prototypes
|
|
|
195 |
#CPPFLAGS += -Wunreachable-code
|
|
|
196 |
#CPPFLAGS += -Wsign-compare
|
|
|
197 |
CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst)
|
|
|
198 |
CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|
|
199 |
#CPPFLAGS += $(CSTANDARD)
|
|
|
200 |
|
|
|
201 |
|
|
|
202 |
#---------------- Assembler Options ----------------
|
|
|
203 |
# -Wa,...: tell GCC to pass this to the assembler.
|
|
|
204 |
# -adhlns: create listing
|
|
|
205 |
# -gstabs: have the assembler create line number information; note that
|
|
|
206 |
# for use in COFF files, additional information about filenames
|
|
|
207 |
# and function names needs to be present in the assembler source
|
|
|
208 |
# files -- see avr-libc docs [FIXME: not yet described there]
|
|
|
209 |
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
|
|
210 |
# dump that will be displayed for a given single line of source input.
|
|
|
211 |
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
|
|
212 |
|
|
|
213 |
|
|
|
214 |
#---------------- Library Options ----------------
|
|
|
215 |
# Minimalistic printf version
|
|
|
216 |
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|
|
217 |
|
|
|
218 |
# Floating point printf version (requires MATH_LIB = -lm below)
|
|
|
219 |
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
|
|
220 |
|
|
|
221 |
# If this is left blank, then it will use the Standard printf version.
|
|
|
222 |
PRINTF_LIB =
|
|
|
223 |
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
|
|
224 |
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
|
|
225 |
|
|
|
226 |
|
|
|
227 |
# Minimalistic scanf version
|
|
|
228 |
SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|
|
229 |
|
|
|
230 |
# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
|
|
|
231 |
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
|
|
232 |
|
|
|
233 |
# If this is left blank, then it will use the Standard scanf version.
|
|
|
234 |
SCANF_LIB =
|
|
|
235 |
#SCANF_LIB = $(SCANF_LIB_MIN)
|
|
|
236 |
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
|
|
237 |
|
|
|
238 |
|
|
|
239 |
MATH_LIB = -lm
|
|
|
240 |
|
|
|
241 |
|
|
|
242 |
# List any extra directories to look for libraries here.
|
|
|
243 |
# Each directory must be seperated by a space.
|
|
|
244 |
# Use forward slashes for directory separators.
|
|
|
245 |
# For a directory that has spaces, enclose it in quotes.
|
|
|
246 |
EXTRALIBDIRS =
|
|
|
247 |
|
|
|
248 |
|
|
|
249 |
|
|
|
250 |
#---------------- External Memory Options ----------------
|
|
|
251 |
|
|
|
252 |
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
|
|
|
253 |
# used for variables (.data/.bss) and heap (malloc()).
|
|
|
254 |
#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
|
|
|
255 |
|
|
|
256 |
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
|
|
|
257 |
# only used for heap (malloc()).
|
|
|
258 |
#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
|
|
|
259 |
|
|
|
260 |
EXTMEMOPTS =
|
|
|
261 |
|
|
|
262 |
|
|
|
263 |
|
|
|
264 |
#---------------- Linker Options ----------------
|
|
|
265 |
# -Wl,...: tell GCC to pass this to linker.
|
|
|
266 |
# -Map: create map file
|
|
|
267 |
# --cref: add cross reference to map file
|
|
|
268 |
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
|
|
269 |
LDFLAGS += $(EXTMEMOPTS)
|
|
|
270 |
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
|
|
271 |
LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
|
|
|
272 |
#LDFLAGS += -T linker_script.x
|
|
|
273 |
|
|
|
274 |
|
|
|
275 |
|
|
|
276 |
#---------------- Programming Options (avrdude) ----------------
|
|
|
277 |
|
|
|
278 |
# Programming hardware
|
|
|
279 |
# Type: avrdude -c ?
|
|
|
280 |
# to get a full listing.
|
|
|
281 |
#
|
|
|
282 |
AVRDUDE_PROGRAMMER = usbtiny
|
|
|
283 |
|
|
|
284 |
# com1 = serial port. Use lpt1 to connect to parallel port.
|
|
|
285 |
AVRDUDE_PORT = com3 # programmer connected to serial device
|
|
|
286 |
|
|
|
287 |
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|
|
288 |
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
|
|
|
289 |
|
|
|
290 |
|
|
|
291 |
# Uncomment the following if you want avrdude's erase cycle counter.
|
|
|
292 |
# Note that this counter needs to be initialized first using -Yn,
|
|
|
293 |
# see avrdude manual.
|
|
|
294 |
#AVRDUDE_ERASE_COUNTER = -y
|
|
|
295 |
|
|
|
296 |
# Uncomment the following if you do /not/ wish a verification to be
|
|
|
297 |
# performed after programming the device.
|
|
|
298 |
#AVRDUDE_NO_VERIFY = -V
|
|
|
299 |
|
|
|
300 |
# Increase verbosity level. Please use this when submitting bug
|
|
|
301 |
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
|
|
302 |
# to submit bug reports.
|
|
|
303 |
#AVRDUDE_VERBOSE = -v -v
|
|
|
304 |
|
|
|
305 |
AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
|
|
|
306 |
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
|
|
|
307 |
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
|
|
|
308 |
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
|
|
|
309 |
|
|
|
310 |
|
|
|
311 |
|
|
|
312 |
#---------------- Debugging Options ----------------
|
|
|
313 |
|
|
|
314 |
# For simulavr only - target MCU frequency.
|
|
|
315 |
DEBUG_MFREQ = $(F_CPU)
|
|
|
316 |
|
|
|
317 |
# Set the DEBUG_UI to either gdb or insight.
|
|
|
318 |
# DEBUG_UI = gdb
|
|
|
319 |
DEBUG_UI = insight
|
|
|
320 |
|
|
|
321 |
# Set the debugging back-end to either avarice, simulavr.
|
|
|
322 |
DEBUG_BACKEND = avarice
|
|
|
323 |
#DEBUG_BACKEND = simulavr
|
|
|
324 |
|
|
|
325 |
# GDB Init Filename.
|
|
|
326 |
GDBINIT_FILE = __avr_gdbinit
|
|
|
327 |
|
|
|
328 |
# When using avarice settings for the JTAG
|
|
|
329 |
JTAG_DEV = /dev/com1
|
|
|
330 |
|
|
|
331 |
# Debugging port used to communicate between GDB / avarice / simulavr.
|
|
|
332 |
DEBUG_PORT = 4242
|
|
|
333 |
|
|
|
334 |
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
|
|
335 |
# just set to localhost unless doing some sort of crazy debugging when
|
|
|
336 |
# avarice is running on a different computer.
|
|
|
337 |
DEBUG_HOST = localhost
|
|
|
338 |
|
|
|
339 |
|
|
|
340 |
|
|
|
341 |
#============================================================================
|
|
|
342 |
|
|
|
343 |
|
|
|
344 |
# Define programs and commands.
|
|
|
345 |
SHELL = sh
|
|
|
346 |
CC = avr-gcc
|
|
|
347 |
OBJCOPY = avr-objcopy
|
|
|
348 |
OBJDUMP = avr-objdump
|
|
|
349 |
SIZE = avr-size
|
|
|
350 |
AR = avr-ar rcs
|
|
|
351 |
NM = avr-nm
|
|
|
352 |
AVRDUDE = avrdude
|
|
|
353 |
REMOVE = rm -f
|
|
|
354 |
REMOVEDIR = rm -rf
|
|
|
355 |
COPY = cp
|
|
|
356 |
WINSHELL = cmd
|
|
|
357 |
|
|
|
358 |
|
|
|
359 |
# Define Messages
|
|
|
360 |
# English
|
|
|
361 |
MSG_ERRORS_NONE = Errors: none
|
|
|
362 |
MSG_BEGIN = -------- begin --------
|
|
|
363 |
MSG_END = -------- end --------
|
|
|
364 |
MSG_SIZE_BEFORE = Size before:
|
|
|
365 |
MSG_SIZE_AFTER = Size after:
|
|
|
366 |
MSG_COFF = Converting to AVR COFF:
|
|
|
367 |
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
|
|
368 |
MSG_FLASH = Creating load file for Flash:
|
|
|
369 |
MSG_EEPROM = Creating load file for EEPROM:
|
|
|
370 |
MSG_EXTENDED_LISTING = Creating Extended Listing:
|
|
|
371 |
MSG_SYMBOL_TABLE = Creating Symbol Table:
|
|
|
372 |
MSG_LINKING = Linking:
|
|
|
373 |
MSG_COMPILING = Compiling C:
|
|
|
374 |
MSG_COMPILING_CPP = Compiling C++:
|
|
|
375 |
MSG_ASSEMBLING = Assembling:
|
|
|
376 |
MSG_CLEANING = Cleaning project:
|
|
|
377 |
MSG_CREATING_LIBRARY = Creating library:
|
|
|
378 |
|
|
|
379 |
|
|
|
380 |
|
|
|
381 |
|
|
|
382 |
# Define all object files.
|
|
|
383 |
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
|
|
384 |
|
|
|
385 |
# Define all listing files.
|
|
|
386 |
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
|
|
387 |
|
|
|
388 |
|
|
|
389 |
# Compiler flags to generate dependency files.
|
|
|
390 |
GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
|
|
|
391 |
|
|
|
392 |
|
|
|
393 |
# Combine all necessary flags and optional flags.
|
|
|
394 |
# Add target processor to flags.
|
|
|
395 |
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
|
|
|
396 |
ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS)
|
|
|
397 |
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
|
|
|
398 |
|
|
|
399 |
|
|
|
400 |
|
|
|
401 |
|
|
|
402 |
|
|
|
403 |
# Default target.
|
|
|
404 |
all: begin gccversion sizebefore build sizeafter end
|
|
|
405 |
|
|
|
406 |
# Change the build target to build a HEX file or a library.
|
|
|
407 |
build: elf hex eep lss sym
|
|
|
408 |
#build: lib
|
|
|
409 |
|
|
|
410 |
|
|
|
411 |
elf: $(TARGET).elf
|
|
|
412 |
hex: $(TARGET).hex
|
|
|
413 |
eep: $(TARGET).eep
|
|
|
414 |
lss: $(TARGET).lss
|
|
|
415 |
sym: $(TARGET).sym
|
|
|
416 |
LIBNAME=lib$(TARGET).a
|
|
|
417 |
lib: $(LIBNAME)
|
|
|
418 |
|
|
|
419 |
|
|
|
420 |
# Eye candy.
|
|
|
421 |
# AVR Studio 3.x does not check make's exit code but relies on
|
|
|
422 |
# the following magic strings to be generated by the compile job.
|
|
|
423 |
begin:
|
|
|
424 |
@echo
|
|
|
425 |
@echo $(MSG_BEGIN)
|
|
|
426 |
|
|
|
427 |
end:
|
|
|
428 |
@echo $(MSG_END)
|
|
|
429 |
@echo
|
|
|
430 |
|
|
|
431 |
|
|
|
432 |
# Display size of file.
|
|
|
433 |
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
|
|
|
434 |
ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf
|
|
|
435 |
|
|
|
436 |
sizebefore:
|
|
|
437 |
@echo $(MSG_SIZE_BEFORE)
|
|
|
438 |
|
|
|
439 |
sizeafter:
|
|
|
440 |
@echo $(MSG_SIZE_AFTER)
|
|
|
441 |
|
|
|
442 |
|
|
|
443 |
|
|
|
444 |
# Display compiler version information.
|
|
|
445 |
gccversion :
|
|
|
446 |
@$(CC) --version
|
|
|
447 |
|
|
|
448 |
|
|
|
449 |
|
|
|
450 |
# Write program memory to the device.
|
|
|
451 |
program: $(TARGET).hex $(TARGET).eep
|
|
|
452 |
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
|
|
453 |
|
|
|
454 |
|
|
|
455 |
|
|
|
456 |
# Write fuses to the device
|
|
|
457 |
fuse: $(TARGET).elf
|
|
|
458 |
avr-objcopy -j .fuse -O ihex $(TARGET).elf fuses.hex --change-section-lma .fuse=0
|
|
|
459 |
srec_cat fuses.hex -Intel -crop 0x00 0x01 -offset 0x00 -O lfuse.hex -Intel
|
|
|
460 |
srec_cat fuses.hex -Intel -crop 0x01 0x02 -offset -0x01 -O hfuse.hex -Intel
|
|
|
461 |
srec_cat fuses.hex -Intel -crop 0x02 0x03 -offset -0x02 -O efuse.hex -Intel
|
|
|
462 |
$(AVRDUDE) $(AVRDUDE_FLAGS) $(FUSES)
|
|
|
463 |
|
|
|
464 |
|
|
|
465 |
# Generate avr-gdb config/init file which does the following:
|
|
|
466 |
# define the reset signal, load the target file, connect to target, and set
|
|
|
467 |
# a breakpoint at main().
|
|
|
468 |
gdb-config:
|
|
|
469 |
@$(REMOVE) $(GDBINIT_FILE)
|
|
|
470 |
@echo define reset >> $(GDBINIT_FILE)
|
|
|
471 |
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
|
|
472 |
@echo end >> $(GDBINIT_FILE)
|
|
|
473 |
@echo file $(TARGET).elf >> $(GDBINIT_FILE)
|
|
|
474 |
@echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE)
|
|
|
475 |
ifeq ($(DEBUG_BACKEND),simulavr)
|
|
|
476 |
@echo load >> $(GDBINIT_FILE)
|
|
|
477 |
endif
|
|
|
478 |
@echo break main >> $(GDBINIT_FILE)
|
|
|
479 |
|
|
|
480 |
debug: gdb-config $(TARGET).elf
|
|
|
481 |
ifeq ($(DEBUG_BACKEND), avarice)
|
|
|
482 |
@echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
|
|
|
483 |
@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
|
|
|
484 |
$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
|
|
|
485 |
@$(WINSHELL) /c pause
|
|
|
486 |
|
|
|
487 |
else
|
|
|
488 |
@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
|
|
|
489 |
$(DEBUG_MFREQ) --port $(DEBUG_PORT)
|
|
|
490 |
endif
|
|
|
491 |
@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
|
|
|
492 |
|
|
|
493 |
|
|
|
494 |
|
|
|
495 |
|
|
|
496 |
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
|
|
|
497 |
COFFCONVERT = $(OBJCOPY) --debugging
|
|
|
498 |
COFFCONVERT += --change-section-address .data-0x800000
|
|
|
499 |
COFFCONVERT += --change-section-address .bss-0x800000
|
|
|
500 |
COFFCONVERT += --change-section-address .noinit-0x800000
|
|
|
501 |
COFFCONVERT += --change-section-address .eeprom-0x810000
|
|
|
502 |
|
|
|
503 |
|
|
|
504 |
|
|
|
505 |
coff: $(TARGET).elf
|
|
|
506 |
@echo
|
|
|
507 |
@echo $(MSG_COFF) $(TARGET).cof
|
|
|
508 |
$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
|
|
|
509 |
|
|
|
510 |
|
|
|
511 |
extcoff: $(TARGET).elf
|
|
|
512 |
@echo
|
|
|
513 |
@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
|
|
|
514 |
$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
|
|
|
515 |
|
|
|
516 |
|
|
|
517 |
|
|
|
518 |
# Create final output files (.hex, .eep) from ELF output file.
|
|
|
519 |
%.hex: %.elf
|
|
|
520 |
@echo
|
|
|
521 |
@echo $(MSG_FLASH) $@
|
|
|
522 |
$(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature $< $@
|
|
|
523 |
|
|
|
524 |
%.eep: %.elf
|
|
|
525 |
@echo
|
|
|
526 |
@echo $(MSG_EEPROM) $@
|
|
|
527 |
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@
|
|
|
528 |
|
|
|
529 |
# Create extended listing file from ELF output file.
|
|
|
530 |
%.lss: %.elf
|
|
|
531 |
@echo
|
|
|
532 |
@echo $(MSG_EXTENDED_LISTING) $@
|
|
|
533 |
$(OBJDUMP) -h -S -z $< > $@
|
|
|
534 |
|
|
|
535 |
# Create a symbol table from ELF output file.
|
|
|
536 |
%.sym: %.elf
|
|
|
537 |
@echo
|
|
|
538 |
@echo $(MSG_SYMBOL_TABLE) $@
|
|
|
539 |
$(NM) -n $< > $@
|
|
|
540 |
|
|
|
541 |
|
|
|
542 |
|
|
|
543 |
# Create library from object files.
|
|
|
544 |
.SECONDARY : $(TARGET).a
|
|
|
545 |
.PRECIOUS : $(OBJ)
|
|
|
546 |
%.a: $(OBJ)
|
|
|
547 |
@echo
|
|
|
548 |
@echo $(MSG_CREATING_LIBRARY) $@
|
|
|
549 |
$(AR) $@ $(OBJ)
|
|
|
550 |
|
|
|
551 |
|
|
|
552 |
# Link: create ELF output file from object files.
|
|
|
553 |
.SECONDARY : $(TARGET).elf
|
|
|
554 |
.PRECIOUS : $(OBJ)
|
|
|
555 |
%.elf: $(OBJ)
|
|
|
556 |
@echo
|
|
|
557 |
@echo $(MSG_LINKING) $@
|
|
|
558 |
$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
|
|
|
559 |
|
|
|
560 |
|
|
|
561 |
# Compile: create object files from C source files.
|
|
|
562 |
$(OBJDIR)/%.o : %.c
|
|
|
563 |
@echo
|
|
|
564 |
@echo $(MSG_COMPILING) $<
|
|
|
565 |
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
|
|
566 |
|
|
|
567 |
|
|
|
568 |
# Compile: create object files from C++ source files.
|
|
|
569 |
$(OBJDIR)/%.o : %.cpp
|
|
|
570 |
@echo
|
|
|
571 |
@echo $(MSG_COMPILING_CPP) $<
|
|
|
572 |
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
|
|
573 |
|
|
|
574 |
|
|
|
575 |
# Compile: create assembler files from C source files.
|
|
|
576 |
%.s : %.c
|
|
|
577 |
$(CC) -S $(ALL_CFLAGS) $< -o $@
|
|
|
578 |
|
|
|
579 |
|
|
|
580 |
# Compile: create assembler files from C++ source files.
|
|
|
581 |
%.s : %.cpp
|
|
|
582 |
$(CC) -S $(ALL_CPPFLAGS) $< -o $@
|
|
|
583 |
|
|
|
584 |
|
|
|
585 |
# Assemble: create object files from assembler source files.
|
|
|
586 |
$(OBJDIR)/%.o : %.S
|
|
|
587 |
@echo
|
|
|
588 |
@echo $(MSG_ASSEMBLING) $<
|
|
|
589 |
$(CC) -c $(ALL_ASFLAGS) $< -o $@
|
|
|
590 |
|
|
|
591 |
|
|
|
592 |
# Create preprocessed source for use in sending a bug report.
|
|
|
593 |
%.i : %.c
|
|
|
594 |
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
|
|
595 |
|
|
|
596 |
|
|
|
597 |
# Target: clean project.
|
|
|
598 |
clean: begin clean_list end
|
|
|
599 |
|
|
|
600 |
clean_list :
|
|
|
601 |
@echo
|
|
|
602 |
@echo $(MSG_CLEANING)
|
|
|
603 |
$(REMOVE) $(TARGET).hex
|
|
|
604 |
$(REMOVE) fuses.hex
|
|
|
605 |
$(REMOVE) lfuse.hex
|
|
|
606 |
$(REMOVE) hfuse.hex
|
|
|
607 |
$(REMOVE) efuse.hex
|
|
|
608 |
$(REMOVE) $(TARGET).eep
|
|
|
609 |
$(REMOVE) $(TARGET).cof
|
|
|
610 |
$(REMOVE) $(TARGET).elf
|
|
|
611 |
$(REMOVE) $(TARGET).map
|
|
|
612 |
$(REMOVE) $(TARGET).sym
|
|
|
613 |
$(REMOVE) $(TARGET).lss
|
|
|
614 |
$(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o)
|
|
|
615 |
$(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst)
|
|
|
616 |
$(REMOVE) $(SRC:.c=.s)
|
|
|
617 |
$(REMOVE) $(SRC:.c=.d)
|
|
|
618 |
$(REMOVE) $(SRC:.c=.i)
|
|
|
619 |
$(REMOVEDIR) .dep
|
|
|
620 |
|
|
|
621 |
|
|
|
622 |
# Create object files directory
|
|
|
623 |
$(shell mkdir $(OBJDIR) 2>/dev/null)
|
|
|
624 |
|
|
|
625 |
|
|
|
626 |
# Include the dependency files.
|
|
|
627 |
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
|
|
|
628 |
|
|
|
629 |
|
|
|
630 |
# Listing of phony targets.
|
|
|
631 |
.PHONY : all begin finish end sizebefore sizeafter gccversion \
|
|
|
632 |
build elf hex eep lss sym coff extcoff \
|
|
|
633 |
clean clean_list program debug gdb-config
|