source: arduino-1-6-7/trunk/fuentes/arduino-ide-amd64/hardware/arduino/avr/bootloaders/optiboot/Makefile @ 4837

Last change on this file since 4837 was 4837, checked in by daduve, 3 years ago

Adding new version

File size: 12.9 KB
Line 
1# Makefile for ATmegaBOOT
2# E.Lins, 18.7.2005
3#
4# Instructions
5#
6# To make bootloader .hex file:
7# make diecimila
8# make lilypad
9# make ng
10# etc...
11#
12# To burn bootloader .hex file:
13# make diecimila_isp
14# make lilypad_isp
15# make ng_isp
16# etc...
17
18# program name should not be changed...
19PROGRAM    = optiboot
20
21# The default behavior is to build using tools that are in the users
22# current path variables, but we can also build using an installed
23# Arduino user IDE setup, or the Arduino source tree.
24# Uncomment this next lines to build within the arduino environment,
25# using the arduino-included avrgcc toolset (mac and pc)
26# ENV ?= arduino
27# ENV ?= arduinodev
28# OS ?= macosx
29# OS ?= windows
30
31
32# enter the parameters for the avrdude isp tool
33ISPTOOL    = stk500v2
34ISPPORT    = usb
35ISPSPEED   = -b 115200
36
37MCU_TARGET = atmega168
38LDSECTIONS  = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe
39
40# Build environments
41# Start of some ugly makefile-isms to allow optiboot to be built
42# in several different environments.  See the README.TXT file for
43# details.
44
45# default
46fixpath = $(1)
47
48ifeq ($(ENV), arduino)
49# For Arduino, we assume that we're connected to the optiboot directory
50# included with the arduino distribution, which means that the full set
51# of avr-tools are "right up there" in standard places.
52TOOLROOT = ../../../tools
53GCCROOT = $(TOOLROOT)/avr/bin/
54AVRDUDE_CONF = -C$(TOOLROOT)/avr/etc/avrdude.conf
55
56ifeq ($(OS), windows)
57# On windows, SOME of the tool paths will need to have backslashes instead
58# of forward slashes (because they use windows cmd.exe for execution instead
59# of a unix/mingw shell?)  We also have to ensure that a consistent shell
60# is used even if a unix shell is installed (ie as part of WINAVR)
61fixpath = $(subst /,\,$1)
62SHELL = cmd.exe
63endif
64
65else ifeq ($(ENV), arduinodev)
66# Arduino IDE source code environment.  Use the unpacked compilers created
67# by the build (you'll need to do "ant build" first.)
68ifeq ($(OS), macosx)
69TOOLROOT = ../../../../build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools
70endif
71ifeq ($(OS), windows)
72TOOLROOT = ../../../../build/windows/work/hardware/tools
73endif
74
75GCCROOT = $(TOOLROOT)/avr/bin/
76AVRDUDE_CONF = -C$(TOOLROOT)/avr/etc/avrdude.conf
77
78else
79GCCROOT =
80AVRDUDE_CONF =
81endif
82#
83# End of build environment code.
84
85
86# the efuse should really be 0xf8; since, however, only the lower
87# three bits of that byte are used on the atmega168, avrdude gets
88# confused if you specify 1's for the higher bits, see:
89# http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
90#
91# similarly, the lock bits should be 0xff instead of 0x3f (to
92# unlock the bootloader section) and 0xcf instead of 0x2f (to
93# lock it), but since the high two bits of the lock byte are
94# unused, avrdude would get confused.
95
96ISPFUSES    = $(GCCROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
97              -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
98              -e -u -U lock:w:0x3f:m -U efuse:w:0x$(EFUSE):m \
99              -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
100ISPFLASH    = $(GCCROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
101              -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
102              -U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x2f:m
103
104STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe"
105STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \
106-lFF -LFF -f$(HFUSE)$(LFUSE) -EF8 -ms -q -cUSB -I200kHz -s -wt
107STK500-2 = $(STK500) -d$(MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt
108
109OBJ        = $(PROGRAM).o
110OPTIMIZE = -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls
111
112DEFS       = 
113LIBS       =
114
115CC         = $(GCCROOT)avr-gcc
116
117# Override is only needed by avr-lib build system.
118
119override CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
120override LDFLAGS       = $(LDSECTIONS) -Wl,--relax -Wl,--gc-sections -nostartfiles -nostdlib
121
122OBJCOPY        = $(GCCROOT)avr-objcopy
123OBJDUMP        = $(call fixpath,$(GCCROOT)avr-objdump)
124
125SIZE           = $(GCCROOT)avr-size
126
127# Test platforms
128# Virtual boot block test
129virboot328: TARGET = atmega328
130virboot328: MCU_TARGET = atmega328p
131virboot328: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DVIRTUAL_BOOT'
132virboot328: AVR_FREQ = 16000000L
133virboot328: LDSECTIONS  = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
134virboot328: $(PROGRAM)_atmega328.hex
135virboot328: $(PROGRAM)_atmega328.lst
136
137# 20MHz clocked platforms
138#
139# These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue)
140#
141
142pro20: TARGET = pro_20mhz
143pro20: MCU_TARGET = atmega168
144pro20: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
145pro20: AVR_FREQ = 20000000L
146pro20: $(PROGRAM)_pro_20mhz.hex
147pro20: $(PROGRAM)_pro_20mhz.lst
148
149pro20_isp: pro20
150pro20_isp: TARGET = pro_20mhz
151# 2.7V brownout
152pro20_isp: HFUSE = DD
153# Full swing xtal (20MHz) 258CK/14CK+4.1ms
154pro20_isp: LFUSE = C6
155# 512 byte boot
156pro20_isp: EFUSE = 04
157pro20_isp: isp
158
159# 16MHz clocked platforms
160#
161# These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue)
162#
163
164pro16: TARGET = pro_16MHz
165pro16: MCU_TARGET = atmega168
166pro16: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
167pro16: AVR_FREQ = 16000000L
168pro16: $(PROGRAM)_pro_16MHz.hex
169pro16: $(PROGRAM)_pro_16MHz.lst
170
171pro16_isp: pro16
172pro16_isp: TARGET = pro_16MHz
173# 2.7V brownout
174pro16_isp: HFUSE = DD
175# Full swing xtal (20MHz) 258CK/14CK+4.1ms
176pro16_isp: LFUSE = C6
177# 512 byte boot
178pro16_isp: EFUSE = 04
179pro16_isp: isp
180
181# Diecimila, Duemilanove with m168, and NG use identical bootloaders
182# Call it "atmega168" for generality and clarity, keep "diecimila" for
183# backward compatibility of makefile
184#
185atmega168: TARGET = atmega168
186atmega168: MCU_TARGET = atmega168
187atmega168: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
188atmega168: AVR_FREQ = 16000000L
189atmega168: $(PROGRAM)_atmega168.hex
190atmega168: $(PROGRAM)_atmega168.lst
191
192atmega168_isp: atmega168
193atmega168_isp: TARGET = atmega168
194# 2.7V brownout
195atmega168_isp: HFUSE = DD
196# Low power xtal (16MHz) 16KCK/14CK+65ms
197atmega168_isp: LFUSE = FF
198# 512 byte boot
199atmega168_isp: EFUSE = 04
200atmega168_isp: isp
201
202diecimila: TARGET = diecimila
203diecimila: MCU_TARGET = atmega168
204diecimila: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
205diecimila: AVR_FREQ = 16000000L
206diecimila: $(PROGRAM)_diecimila.hex
207diecimila: $(PROGRAM)_diecimila.lst
208
209diecimila_isp: diecimila
210diecimila_isp: TARGET = diecimila
211# 2.7V brownout
212diecimila_isp: HFUSE = DD
213# Low power xtal (16MHz) 16KCK/14CK+65ms
214diecimila_isp: LFUSE = FF
215# 512 byte boot
216diecimila_isp: EFUSE = 04
217diecimila_isp: isp
218
219atmega328: TARGET = atmega328
220atmega328: MCU_TARGET = atmega328p
221atmega328: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
222atmega328: AVR_FREQ = 16000000L
223atmega328: LDSECTIONS  = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
224atmega328: $(PROGRAM)_atmega328.hex
225atmega328: $(PROGRAM)_atmega328.lst
226
227atmega328_isp: atmega328
228atmega328_isp: TARGET = atmega328
229atmega328_isp: MCU_TARGET = atmega328p
230# 512 byte boot, SPIEN
231atmega328_isp: HFUSE = DE
232# Low power xtal (16MHz) 16KCK/14CK+65ms
233atmega328_isp: LFUSE = FF
234# 2.7V brownout
235atmega328_isp: EFUSE = 05
236atmega328_isp: isp
237
238# Sanguino has a minimum boot size of 1024 bytes, so enable extra functions
239#
240sanguino: TARGET = atmega644p
241sanguino: MCU_TARGET = atmega644p
242sanguino: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT'
243sanguino: AVR_FREQ = 16000000L
244sanguino: LDSECTIONS  = -Wl,--section-start=.text=0xfc00
245sanguino: $(PROGRAM)_atmega644p.hex
246sanguino: $(PROGRAM)_atmega644p.lst
247
248sanguino_isp: sanguino
249sanguino_isp: TARGET = atmega644p
250sanguino_isp: MCU_TARGET = atmega644p
251# 1024 byte boot
252sanguino_isp: HFUSE = DE
253# Low power xtal (16MHz) 16KCK/14CK+65ms
254sanguino_isp: LFUSE = FF
255# 2.7V brownout
256sanguino_isp: EFUSE = 05
257sanguino_isp: isp
258
259# Mega has a minimum boot size of 1024 bytes, so enable extra functions
260#mega: TARGET = atmega1280
261mega: MCU_TARGET = atmega1280
262mega: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT'
263mega: AVR_FREQ = 16000000L
264mega: LDSECTIONS  = -Wl,--section-start=.text=0x1fc00
265mega: $(PROGRAM)_atmega1280.hex
266mega: $(PROGRAM)_atmega1280.lst
267
268mega_isp: mega
269mega_isp: TARGET = atmega1280
270mega_isp: MCU_TARGET = atmega1280
271# 1024 byte boot
272mega_isp: HFUSE = DE
273# Low power xtal (16MHz) 16KCK/14CK+65ms
274mega_isp: LFUSE = FF
275# 2.7V brownout
276mega_isp: EFUSE = 05
277mega_isp: isp
278
279# ATmega8
280#
281atmega8: TARGET = atmega8
282atmega8: MCU_TARGET = atmega8
283atmega8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
284atmega8: AVR_FREQ = 16000000L
285atmega8: LDSECTIONS  = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe
286atmega8: $(PROGRAM)_atmega8.hex
287atmega8: $(PROGRAM)_atmega8.lst
288
289atmega8_isp: atmega8
290atmega8_isp: TARGET = atmega8
291atmega8_isp: MCU_TARGET = atmega8
292# SPIEN, CKOPT, Bootsize=512B
293atmega8_isp: HFUSE = CC
294# 2.7V brownout, Low power xtal (16MHz) 16KCK/14CK+65ms
295atmega8_isp: LFUSE = BF
296atmega8_isp: isp
297
298# ATmega88
299#
300atmega88: TARGET = atmega88
301atmega88: MCU_TARGET = atmega88
302atmega88: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
303atmega88: AVR_FREQ = 16000000L
304atmega88: LDSECTIONS  = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe
305atmega88: $(PROGRAM)_atmega88.hex
306atmega88: $(PROGRAM)_atmega88.lst
307
308atmega88_isp: atmega88
309atmega88_isp: TARGET = atmega88
310atmega88_isp: MCU_TARGET = atmega88
311# 2.7V brownout
312atmega88_isp: HFUSE = DD
313# Low power xtal (16MHz) 16KCK/14CK+65ms
314atemga88_isp: LFUSE = FF
315# 512 byte boot
316atmega88_isp: EFUSE = 04
317atmega88_isp: isp
318
319
320# 8MHz clocked platforms
321#
322# These are capable of 115200 baud
323#
324
325lilypad: TARGET = lilypad
326lilypad: MCU_TARGET = atmega168
327lilypad: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
328lilypad: AVR_FREQ = 8000000L
329lilypad: $(PROGRAM)_lilypad.hex
330lilypad: $(PROGRAM)_lilypad.lst
331
332lilypad_isp: lilypad
333lilypad_isp: TARGET = lilypad
334# 2.7V brownout
335lilypad_isp: HFUSE = DD
336# Internal 8MHz osc (8MHz) Slow rising power
337lilypad_isp: LFUSE = E2
338# 512 byte boot
339lilypad_isp: EFUSE = 04
340lilypad_isp: isp
341
342lilypad_resonator: TARGET = lilypad_resonator
343lilypad_resonator: MCU_TARGET = atmega168
344lilypad_resonator: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
345lilypad_resonator: AVR_FREQ = 8000000L
346lilypad_resonator: $(PROGRAM)_lilypad_resonator.hex
347lilypad_resonator: $(PROGRAM)_lilypad_resonator.lst
348
349lilypad_resonator_isp: lilypad_resonator
350lilypad_resonator_isp: TARGET = lilypad_resonator
351# 2.7V brownout
352lilypad_resonator_isp: HFUSE = DD
353# Full swing xtal (20MHz) 258CK/14CK+4.1ms
354lilypad_resonator_isp: LFUSE = C6
355# 512 byte boot
356lilypad_resonator_isp: EFUSE = 04
357lilypad_resonator_isp: isp
358
359pro8: TARGET = pro_8MHz
360pro8: MCU_TARGET = atmega168
361pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
362pro8: AVR_FREQ = 8000000L
363pro8: $(PROGRAM)_pro_8MHz.hex
364pro8: $(PROGRAM)_pro_8MHz.lst
365
366pro8_isp: pro8
367pro8_isp: TARGET = pro_8MHz
368# 2.7V brownout
369pro8_isp: HFUSE = DD
370# Full swing xtal (20MHz) 258CK/14CK+4.1ms
371pro8_isp: LFUSE = C6
372# 512 byte boot
373pro8_isp: EFUSE = 04
374pro8_isp: isp
375
376atmega328_pro8: TARGET = atmega328_pro_8MHz
377atmega328_pro8: MCU_TARGET = atmega328p
378atmega328_pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
379atmega328_pro8: AVR_FREQ = 8000000L
380atmega328_pro8: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
381atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.hex
382atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.lst
383
384atmega328_pro8_isp: atmega328_pro8
385atmega328_pro8_isp: TARGET = atmega328_pro_8MHz
386atmega328_pro8_isp: MCU_TARGET = atmega328p
387# 512 byte boot, SPIEN
388atmega328_pro8_isp: HFUSE = DE
389# Low power xtal (16MHz) 16KCK/14CK+65ms
390atmega328_pro8_isp: LFUSE = FF
391# 2.7V brownout
392atmega328_pro8_isp: EFUSE = 05
393atmega328_pro8_isp: isp
394
395# 1MHz clocked platforms
396#
397# These are capable of 9600 baud
398#
399
400luminet: TARGET = luminet
401luminet: MCU_TARGET = attiny84
402luminet: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=9600'
403luminet: CFLAGS += '-DVIRTUAL_BOOT_PARTITION'
404luminet: AVR_FREQ = 1000000L
405luminet: LDSECTIONS = -Wl,--section-start=.text=0x1d00 -Wl,--section-start=.version=0x1efe
406luminet: $(PROGRAM)_luminet.hex
407luminet: $(PROGRAM)_luminet.lst
408
409luminet_isp: luminet
410luminet_isp: TARGET = luminet
411luminet_isp: MCU_TARGET = attiny84
412# Brownout disabled
413luminet_isp: HFUSE = DF
414# 1MHz internal oscillator, slowly rising power
415luminet_isp: LFUSE = 62
416# Self-programming enable
417luminet_isp: EFUSE = FE
418luminet_isp: isp
419
420#
421# Generic build instructions
422#
423#
424
425isp: $(TARGET)
426        $(ISPFUSES)
427        $(ISPFLASH)
428
429isp-stk500: $(PROGRAM)_$(TARGET).hex
430        $(STK500-1)
431        $(STK500-2)
432
433%.elf: $(OBJ)
434        $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
435        $(SIZE) $@
436
437clean:
438        rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
439
440%.lst: %.elf
441        $(OBJDUMP) -h -S $< > $@
442
443%.hex: %.elf
444        $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex $< $@
445
446%.srec: %.elf
447        $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O srec $< $@
448
449%.bin: %.elf
450        $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O binary $< $@
Note: See TracBrowser for help on using the repository browser.