Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (5.97 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    = ATmegaBOOT_168
21

    
22
# enter the parameters for the avrdude isp tool
23
ISPTOOL	   = stk500v2
24
ISPPORT	   = usb
25
ISPSPEED   = -b 115200
26

    
27
MCU_TARGET = atmega168
28
LDSECTION  = --section-start=.text=0x3800
29

    
30
# the efuse should really be 0xf8; since, however, only the lower
31
# three bits of that byte are used on the atmega168, avrdude gets
32
# confused if you specify 1's for the higher bits, see:
33
# http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
34
#
35
# similarly, the lock bits should be 0xff instead of 0x3f (to
36
# unlock the bootloader section) and 0xcf instead of 0x0f (to
37
# lock it), but since the high two bits of the lock byte are
38
# unused, avrdude would get confused.
39

    
40
ISPFUSES    = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
41
-e -u -U lock:w:0x3f:m -U efuse:w:0x$(EFUSE):m -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
42
ISPFLASH    = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
43
-U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x0f:m
44

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

    
50

    
51
OBJ        = $(PROGRAM).o
52
OPTIMIZE   = -O2
53

    
54
DEFS       = 
55
LIBS       =
56

    
57
CC         = avr-gcc
58

    
59
# Override is only needed by avr-lib build system.
60

    
61
override CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
62
override LDFLAGS       = -Wl,$(LDSECTION)
63
#override LDFLAGS       = -Wl,-Map,$(PROGRAM).map,$(LDSECTION)
64

    
65
OBJCOPY        = avr-objcopy
66
OBJDUMP        = avr-objdump
67

    
68
all:
69

    
70
lilypad: TARGET = lilypad
71
lilypad: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>1' '-DNUM_LED_FLASHES=3'
72
lilypad: AVR_FREQ = 8000000L
73
lilypad: $(PROGRAM)_lilypad.hex
74

    
75
lilypad_isp: lilypad
76
lilypad_isp: TARGET = lilypad
77
lilypad_isp: HFUSE = DD
78
lilypad_isp: LFUSE = E2
79
lilypad_isp: EFUSE = 00
80
lilypad_isp: isp
81

    
82
lilypad_resonator: TARGET = lilypad_resonator
83
lilypad_resonator: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=3'
84
lilypad_resonator: AVR_FREQ = 8000000L
85
lilypad_resonator: $(PROGRAM)_lilypad_resonator.hex
86

    
87
lilypad_resonator_isp: lilypad_resonator
88
lilypad_resonator_isp: TARGET = lilypad_resonator
89
lilypad_resonator_isp: HFUSE = DD
90
lilypad_resonator_isp: LFUSE = C6
91
lilypad_resonator_isp: EFUSE = 00
92
lilypad_resonator_isp: isp
93

    
94
pro8: TARGET = pro_8MHz
95
pro8: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS'
96
pro8: AVR_FREQ = 8000000L
97
pro8: $(PROGRAM)_pro_8MHz.hex
98

    
99
pro8_isp: pro8
100
pro8_isp: TARGET = pro_8MHz
101
pro8_isp: HFUSE = DD
102
pro8_isp: LFUSE = C6
103
pro8_isp: EFUSE = 00
104
pro8_isp: isp
105

    
106
pro16: TARGET = pro_16MHz
107
pro16: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS'
108
pro16: AVR_FREQ = 16000000L
109
pro16: $(PROGRAM)_pro_16MHz.hex
110

    
111
pro16_isp: pro16
112
pro16_isp: TARGET = pro_16MHz
113
pro16_isp: HFUSE = DD
114
pro16_isp: LFUSE = C6
115
pro16_isp: EFUSE = 00
116
pro16_isp: isp
117

    
118
pro20: TARGET = pro_20mhz
119
pro20: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS'
120
pro20: AVR_FREQ = 20000000L
121
pro20: $(PROGRAM)_pro_20mhz.hex
122

    
123
pro20_isp: pro20
124
pro20_isp: TARGET = pro_20mhz
125
pro20_isp: HFUSE = DD
126
pro20_isp: LFUSE = C6
127
pro20_isp: EFUSE = 00
128
pro20_isp: isp
129

    
130
diecimila: TARGET = diecimila
131
diecimila: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1'
132
diecimila: AVR_FREQ = 16000000L 
133
diecimila: $(PROGRAM)_diecimila.hex
134

    
135
diecimila_isp: diecimila
136
diecimila_isp: TARGET = diecimila
137
diecimila_isp: HFUSE = DD
138
diecimila_isp: LFUSE = FF
139
diecimila_isp: EFUSE = 00
140
diecimila_isp: isp
141

    
142
ng: TARGET = ng
143
ng: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>1' '-DNUM_LED_FLASHES=3'
144
ng: AVR_FREQ = 16000000L
145
ng: $(PROGRAM)_ng.hex
146

    
147
ng_isp: ng
148
ng_isp: TARGET = ng
149
ng_isp: HFUSE = DD
150
ng_isp: LFUSE = FF
151
ng_isp: EFUSE = 00
152
ng_isp: isp
153

    
154
atmega328: TARGET = atmega328
155
atmega328: MCU_TARGET = atmega328p
156
atmega328: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=57600
157
atmega328: AVR_FREQ = 16000000L 
158
atmega328: LDSECTION  = --section-start=.text=0x7800
159
atmega328: $(PROGRAM)_atmega328.hex
160

    
161
atmega328_isp: atmega328
162
atmega328_isp: TARGET = atmega328
163
atmega328_isp: MCU_TARGET = atmega328p
164
atmega328_isp: HFUSE = DA
165
atmega328_isp: LFUSE = FF
166
atmega328_isp: EFUSE = 05
167
atmega328_isp: isp
168

    
169
atmega328_pro8: TARGET = atmega328_pro_8MHz
170
atmega328_pro8: MCU_TARGET = atmega328p
171
atmega328_pro8: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=57600 -DDOUBLE_SPEED
172
atmega328_pro8: AVR_FREQ = 8000000L 
173
atmega328_pro8: LDSECTION  = --section-start=.text=0x7800
174
atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.hex
175

    
176
atmega328_pro8_isp: atmega328_pro8
177
atmega328_pro8_isp: TARGET = atmega328_pro_8MHz
178
atmega328_pro8_isp: MCU_TARGET = atmega328p
179
atmega328_pro8_isp: HFUSE = DA
180
atmega328_pro8_isp: LFUSE = FF
181
atmega328_pro8_isp: EFUSE = 05
182
atmega328_pro8_isp: isp
183

    
184
mega: TARGET = atmega1280
185
mega: MCU_TARGET = atmega1280
186
mega: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=0' -DBAUD_RATE=57600
187
mega: AVR_FREQ = 16000000L 
188
mega: LDSECTION  = --section-start=.text=0x1F000
189
mega: $(PROGRAM)_atmega1280.hex
190

    
191
mega_isp: mega
192
mega_isp: TARGET = atmega1280
193
mega_isp: MCU_TARGET = atmega1280
194
mega_isp: HFUSE = DA
195
mega_isp: LFUSE = FF
196
mega_isp: EFUSE = F5
197
mega_isp: isp
198

    
199
isp: $(TARGET)
200
	$(ISPFUSES)
201
	$(ISPFLASH)
202

    
203
isp-stk500: $(PROGRAM)_$(TARGET).hex
204
	$(STK500-1)
205
	$(STK500-2)
206

    
207
%.elf: $(OBJ)
208
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
209

    
210
clean:
211
	rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
212

    
213
%.lst: %.elf
214
	$(OBJDUMP) -h -S $< > $@
215

    
216
%.hex: %.elf
217
	$(OBJCOPY) -j .text -j .data -O ihex $< $@
218

    
219
%.srec: %.elf
220
	$(OBJCOPY) -j .text -j .data -O srec $< $@
221

    
222
%.bin: %.elf
223
	$(OBJCOPY) -j .text -j .data -O binary $< $@
224