Project

General

Profile

Statistics
| Branch: | Revision:

root / arduino-1.0 / hardware / arduino / bootloaders / optiboot / Makefile @ 58d82c77

History | View | Annotate | Download (12.9 KB)

1
# Makefile for ATmegaBOOT
2
# E.Lins, 18.7.2005
3
# $Id$
4
#
5
# Instructions
6
#
7
# To make bootloader .hex file:
8
# make diecimila
9
# make lilypad
10
# make ng
11
# etc...
12
#
13
# To burn bootloader .hex file:
14
# make diecimila_isp
15
# make lilypad_isp
16
# make ng_isp
17
# etc...
18

    
19
# program name should not be changed...
20
PROGRAM    = optiboot
21

    
22
# The default behavior is to build using tools that are in the users
23
# current path variables, but we can also build using an installed
24
# Arduino user IDE setup, or the Arduino source tree.
25
# Uncomment this next lines to build within the arduino environment,
26
# using the arduino-included avrgcc toolset (mac and pc)
27
# ENV ?= arduino
28
# ENV ?= arduinodev
29
# OS ?= macosx
30
# OS ?= windows
31

    
32

    
33
# enter the parameters for the avrdude isp tool
34
ISPTOOL	   = stk500v2
35
ISPPORT	   = usb
36
ISPSPEED   = -b 115200
37

    
38
MCU_TARGET = atmega168
39
LDSECTIONS  = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe
40

    
41
# Build environments
42
# Start of some ugly makefile-isms to allow optiboot to be built
43
# in several different environments.  See the README.TXT file for
44
# details.
45

    
46
# default
47
fixpath = $(1)
48

    
49
ifeq ($(ENV), arduino)
50
# For Arduino, we assume that we're connected to the optiboot directory
51
# included with the arduino distribution, which means that the full set
52
# of avr-tools are "right up there" in standard places.
53
TOOLROOT = ../../../tools
54
GCCROOT = $(TOOLROOT)/avr/bin/
55
AVRDUDE_CONF = -C$(TOOLROOT)/avr/etc/avrdude.conf
56

    
57
ifeq ($(OS), windows)
58
# On windows, SOME of the tool paths will need to have backslashes instead
59
# of forward slashes (because they use windows cmd.exe for execution instead
60
# of a unix/mingw shell?)  We also have to ensure that a consistent shell
61
# is used even if a unix shell is installed (ie as part of WINAVR)
62
fixpath = $(subst /,\,$1)
63
SHELL = cmd.exe
64
endif
65

    
66
else ifeq ($(ENV), arduinodev)
67
# Arduino IDE source code environment.  Use the unpacked compilers created
68
# by the build (you'll need to do "ant build" first.)
69
ifeq ($(OS), macosx)
70
TOOLROOT = ../../../../build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools
71
endif
72
ifeq ($(OS), windows)
73
TOOLROOT = ../../../../build/windows/work/hardware/tools
74
endif
75

    
76
GCCROOT = $(TOOLROOT)/avr/bin/
77
AVRDUDE_CONF = -C$(TOOLROOT)/avr/etc/avrdude.conf
78

    
79
else
80
GCCROOT =
81
AVRDUDE_CONF =
82
endif
83
#
84
# End of build environment code.
85

    
86

    
87
# the efuse should really be 0xf8; since, however, only the lower
88
# three bits of that byte are used on the atmega168, avrdude gets
89
# confused if you specify 1's for the higher bits, see:
90
# http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
91
#
92
# similarly, the lock bits should be 0xff instead of 0x3f (to
93
# unlock the bootloader section) and 0xcf instead of 0x2f (to
94
# lock it), but since the high two bits of the lock byte are
95
# unused, avrdude would get confused.
96

    
97
ISPFUSES    = $(GCCROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
98
              -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
99
              -e -u -U lock:w:0x3f:m -U efuse:w:0x$(EFUSE):m \
100
              -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
101
ISPFLASH    = $(GCCROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
102
              -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
103
              -U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x2f:m
104

    
105
STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe"
106
STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \
107
-lFF -LFF -f$(HFUSE)$(LFUSE) -EF8 -ms -q -cUSB -I200kHz -s -wt
108
STK500-2 = $(STK500) -d$(MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt
109

    
110
OBJ        = $(PROGRAM).o
111
OPTIMIZE = -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls
112

    
113
DEFS       = 
114
LIBS       =
115

    
116
CC         = $(GCCROOT)avr-gcc
117

    
118
# Override is only needed by avr-lib build system.
119

    
120
override CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
121
override LDFLAGS       = $(LDSECTIONS) -Wl,--relax -Wl,--gc-sections -nostartfiles -nostdlib
122

    
123
OBJCOPY        = $(GCCROOT)avr-objcopy
124
OBJDUMP        = $(call fixpath,$(GCCROOT)avr-objdump)
125

    
126
SIZE           = $(GCCROOT)avr-size
127

    
128
# Test platforms
129
# Virtual boot block test
130
virboot328: TARGET = atmega328
131
virboot328: MCU_TARGET = atmega328p
132
virboot328: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DVIRTUAL_BOOT'
133
virboot328: AVR_FREQ = 16000000L
134
virboot328: LDSECTIONS  = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
135
virboot328: $(PROGRAM)_atmega328.hex
136
virboot328: $(PROGRAM)_atmega328.lst
137

    
138
# 20MHz clocked platforms
139
#
140
# These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue)
141
#
142

    
143
pro20: TARGET = pro_20mhz
144
pro20: MCU_TARGET = atmega168
145
pro20: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
146
pro20: AVR_FREQ = 20000000L
147
pro20: $(PROGRAM)_pro_20mhz.hex
148
pro20: $(PROGRAM)_pro_20mhz.lst
149

    
150
pro20_isp: pro20
151
pro20_isp: TARGET = pro_20mhz
152
# 2.7V brownout
153
pro20_isp: HFUSE = DD
154
# Full swing xtal (20MHz) 258CK/14CK+4.1ms
155
pro20_isp: LFUSE = C6
156
# 512 byte boot
157
pro20_isp: EFUSE = 04
158
pro20_isp: isp
159

    
160
# 16MHz clocked platforms
161
#
162
# These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue)
163
#
164

    
165
pro16: TARGET = pro_16MHz
166
pro16: MCU_TARGET = atmega168
167
pro16: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
168
pro16: AVR_FREQ = 16000000L
169
pro16: $(PROGRAM)_pro_16MHz.hex
170
pro16: $(PROGRAM)_pro_16MHz.lst
171

    
172
pro16_isp: pro16
173
pro16_isp: TARGET = pro_16MHz
174
# 2.7V brownout
175
pro16_isp: HFUSE = DD
176
# Full swing xtal (20MHz) 258CK/14CK+4.1ms
177
pro16_isp: LFUSE = C6
178
# 512 byte boot
179
pro16_isp: EFUSE = 04
180
pro16_isp: isp
181

    
182
# Diecimila, Duemilanove with m168, and NG use identical bootloaders
183
# Call it "atmega168" for generality and clarity, keep "diecimila" for
184
# backward compatibility of makefile
185
#
186
atmega168: TARGET = atmega168
187
atmega168: MCU_TARGET = atmega168
188
atmega168: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
189
atmega168: AVR_FREQ = 16000000L 
190
atmega168: $(PROGRAM)_atmega168.hex
191
atmega168: $(PROGRAM)_atmega168.lst
192

    
193
atmega168_isp: atmega168
194
atmega168_isp: TARGET = atmega168
195
# 2.7V brownout
196
atmega168_isp: HFUSE = DD
197
# Low power xtal (16MHz) 16KCK/14CK+65ms
198
atmega168_isp: LFUSE = FF
199
# 512 byte boot
200
atmega168_isp: EFUSE = 04
201
atmega168_isp: isp
202

    
203
diecimila: TARGET = diecimila
204
diecimila: MCU_TARGET = atmega168
205
diecimila: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
206
diecimila: AVR_FREQ = 16000000L 
207
diecimila: $(PROGRAM)_diecimila.hex
208
diecimila: $(PROGRAM)_diecimila.lst
209

    
210
diecimila_isp: diecimila
211
diecimila_isp: TARGET = diecimila
212
# 2.7V brownout
213
diecimila_isp: HFUSE = DD
214
# Low power xtal (16MHz) 16KCK/14CK+65ms
215
diecimila_isp: LFUSE = FF
216
# 512 byte boot
217
diecimila_isp: EFUSE = 04
218
diecimila_isp: isp
219

    
220
atmega328: TARGET = atmega328
221
atmega328: MCU_TARGET = atmega328p
222
atmega328: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
223
atmega328: AVR_FREQ = 16000000L
224
atmega328: LDSECTIONS  = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
225
atmega328: $(PROGRAM)_atmega328.hex
226
atmega328: $(PROGRAM)_atmega328.lst
227

    
228
atmega328_isp: atmega328
229
atmega328_isp: TARGET = atmega328
230
atmega328_isp: MCU_TARGET = atmega328p
231
# 512 byte boot, SPIEN
232
atmega328_isp: HFUSE = DE
233
# Low power xtal (16MHz) 16KCK/14CK+65ms
234
atmega328_isp: LFUSE = FF
235
# 2.7V brownout
236
atmega328_isp: EFUSE = 05
237
atmega328_isp: isp
238

    
239
# Sanguino has a minimum boot size of 1024 bytes, so enable extra functions
240
#
241
sanguino: TARGET = atmega644p
242
sanguino: MCU_TARGET = atmega644p
243
sanguino: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT'
244
sanguino: AVR_FREQ = 16000000L
245
sanguino: LDSECTIONS  = -Wl,--section-start=.text=0xfc00
246
sanguino: $(PROGRAM)_atmega644p.hex
247
sanguino: $(PROGRAM)_atmega644p.lst
248

    
249
sanguino_isp: sanguino
250
sanguino_isp: TARGET = atmega644p
251
sanguino_isp: MCU_TARGET = atmega644p
252
# 1024 byte boot
253
sanguino_isp: HFUSE = DE
254
# Low power xtal (16MHz) 16KCK/14CK+65ms
255
sanguino_isp: LFUSE = FF
256
# 2.7V brownout
257
sanguino_isp: EFUSE = 05
258
sanguino_isp: isp
259

    
260
# Mega has a minimum boot size of 1024 bytes, so enable extra functions
261
#mega: TARGET = atmega1280
262
mega: MCU_TARGET = atmega1280
263
mega: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT'
264
mega: AVR_FREQ = 16000000L
265
mega: LDSECTIONS  = -Wl,--section-start=.text=0x1fc00
266
mega: $(PROGRAM)_atmega1280.hex
267
mega: $(PROGRAM)_atmega1280.lst
268

    
269
mega_isp: mega
270
mega_isp: TARGET = atmega1280
271
mega_isp: MCU_TARGET = atmega1280
272
# 1024 byte boot
273
mega_isp: HFUSE = DE
274
# Low power xtal (16MHz) 16KCK/14CK+65ms
275
mega_isp: LFUSE = FF
276
# 2.7V brownout
277
mega_isp: EFUSE = 05
278
mega_isp: isp
279

    
280
# ATmega8
281
#
282
atmega8: TARGET = atmega8
283
atmega8: MCU_TARGET = atmega8
284
atmega8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
285
atmega8: AVR_FREQ = 16000000L 
286
atmega8: LDSECTIONS  = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe
287
atmega8: $(PROGRAM)_atmega8.hex
288
atmega8: $(PROGRAM)_atmega8.lst
289

    
290
atmega8_isp: atmega8
291
atmega8_isp: TARGET = atmega8
292
atmega8_isp: MCU_TARGET = atmega8
293
# SPIEN, CKOPT, Bootsize=512B
294
atmega8_isp: HFUSE = CC
295
# 2.7V brownout, Low power xtal (16MHz) 16KCK/14CK+65ms
296
atmega8_isp: LFUSE = BF
297
atmega8_isp: isp
298

    
299
# ATmega88
300
#
301
atmega88: TARGET = atmega88
302
atmega88: MCU_TARGET = atmega88
303
atmega88: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
304
atmega88: AVR_FREQ = 16000000L 
305
atmega88: LDSECTIONS  = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe
306
atmega88: $(PROGRAM)_atmega88.hex
307
atmega88: $(PROGRAM)_atmega88.lst
308

    
309
atmega88_isp: atmega88
310
atmega88_isp: TARGET = atmega88
311
atmega88_isp: MCU_TARGET = atmega88
312
# 2.7V brownout
313
atmega88_isp: HFUSE = DD
314
# Low power xtal (16MHz) 16KCK/14CK+65ms
315
atemga88_isp: LFUSE = FF
316
# 512 byte boot
317
atmega88_isp: EFUSE = 04
318
atmega88_isp: isp
319

    
320

    
321
# 8MHz clocked platforms
322
#
323
# These are capable of 115200 baud
324
#
325

    
326
lilypad: TARGET = lilypad
327
lilypad: MCU_TARGET = atmega168
328
lilypad: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
329
lilypad: AVR_FREQ = 8000000L
330
lilypad: $(PROGRAM)_lilypad.hex
331
lilypad: $(PROGRAM)_lilypad.lst
332

    
333
lilypad_isp: lilypad
334
lilypad_isp: TARGET = lilypad
335
# 2.7V brownout
336
lilypad_isp: HFUSE = DD
337
# Internal 8MHz osc (8MHz) Slow rising power
338
lilypad_isp: LFUSE = E2
339
# 512 byte boot
340
lilypad_isp: EFUSE = 04
341
lilypad_isp: isp
342

    
343
lilypad_resonator: TARGET = lilypad_resonator
344
lilypad_resonator: MCU_TARGET = atmega168
345
lilypad_resonator: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
346
lilypad_resonator: AVR_FREQ = 8000000L
347
lilypad_resonator: $(PROGRAM)_lilypad_resonator.hex
348
lilypad_resonator: $(PROGRAM)_lilypad_resonator.lst
349

    
350
lilypad_resonator_isp: lilypad_resonator
351
lilypad_resonator_isp: TARGET = lilypad_resonator
352
# 2.7V brownout
353
lilypad_resonator_isp: HFUSE = DD
354
# Full swing xtal (20MHz) 258CK/14CK+4.1ms
355
lilypad_resonator_isp: LFUSE = C6
356
# 512 byte boot
357
lilypad_resonator_isp: EFUSE = 04
358
lilypad_resonator_isp: isp
359

    
360
pro8: TARGET = pro_8MHz
361
pro8: MCU_TARGET = atmega168
362
pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
363
pro8: AVR_FREQ = 8000000L
364
pro8: $(PROGRAM)_pro_8MHz.hex
365
pro8: $(PROGRAM)_pro_8MHz.lst
366

    
367
pro8_isp: pro8
368
pro8_isp: TARGET = pro_8MHz
369
# 2.7V brownout
370
pro8_isp: HFUSE = DD
371
# Full swing xtal (20MHz) 258CK/14CK+4.1ms
372
pro8_isp: LFUSE = C6
373
# 512 byte boot
374
pro8_isp: EFUSE = 04
375
pro8_isp: isp
376

    
377
atmega328_pro8: TARGET = atmega328_pro_8MHz
378
atmega328_pro8: MCU_TARGET = atmega328p
379
atmega328_pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
380
atmega328_pro8: AVR_FREQ = 8000000L
381
atmega328_pro8: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
382
atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.hex
383
atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.lst
384

    
385
atmega328_pro8_isp: atmega328_pro8
386
atmega328_pro8_isp: TARGET = atmega328_pro_8MHz
387
atmega328_pro8_isp: MCU_TARGET = atmega328p
388
# 512 byte boot, SPIEN
389
atmega328_pro8_isp: HFUSE = DE
390
# Low power xtal (16MHz) 16KCK/14CK+65ms
391
atmega328_pro8_isp: LFUSE = FF
392
# 2.7V brownout
393
atmega328_pro8_isp: EFUSE = 05
394
atmega328_pro8_isp: isp
395

    
396
# 1MHz clocked platforms
397
#
398
# These are capable of 9600 baud
399
#
400

    
401
luminet: TARGET = luminet
402
luminet: MCU_TARGET = attiny84
403
luminet: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=9600'
404
luminet: CFLAGS += '-DVIRTUAL_BOOT_PARTITION'
405
luminet: AVR_FREQ = 1000000L
406
luminet: LDSECTIONS = -Wl,--section-start=.text=0x1d00 -Wl,--section-start=.version=0x1efe
407
luminet: $(PROGRAM)_luminet.hex
408
luminet: $(PROGRAM)_luminet.lst
409

    
410
luminet_isp: luminet
411
luminet_isp: TARGET = luminet
412
luminet_isp: MCU_TARGET = attiny84
413
# Brownout disabled
414
luminet_isp: HFUSE = DF
415
# 1MHz internal oscillator, slowly rising power
416
luminet_isp: LFUSE = 62
417
# Self-programming enable
418
luminet_isp: EFUSE = FE
419
luminet_isp: isp
420

    
421
#
422
# Generic build instructions
423
#
424
#
425

    
426
isp: $(TARGET)
427
	$(ISPFUSES)
428
	$(ISPFLASH)
429

    
430
isp-stk500: $(PROGRAM)_$(TARGET).hex
431
	$(STK500-1)
432
	$(STK500-2)
433

    
434
%.elf: $(OBJ)
435
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
436
	$(SIZE) $@
437

    
438
clean:
439
	rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
440

    
441
%.lst: %.elf
442
	$(OBJDUMP) -h -S $< > $@
443

    
444
%.hex: %.elf
445
	$(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex $< $@
446

    
447
%.srec: %.elf
448
	$(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O srec $< $@
449

    
450
%.bin: %.elf
451
	$(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O binary $< $@