Project

General

Profile

Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (2.83 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
atmega328_bt: TARGET = atmega328_bt
71
atmega328_bt: MCU_TARGET = atmega328p
72
atmega328_bt: AVR_FREQ = 16000000L 
73
atmega328_bt: LDSECTION  = --section-start=.text=0x7000
74
atmega328_bt: $(PROGRAM)_atmega328_bt.hex
75

    
76
atmega328_bt_isp: atmega328_bt
77
atmega328_bt_isp: TARGET = atmega328_bt
78
atmega328_bt_isp: MCU_TARGET = atmega328p
79
atmega328_bt_isp: HFUSE = D8
80
atmega328_bt_isp: LFUSE = FF
81
atmega328_bt_isp: EFUSE = 05
82
atmega328_bt_isp: isp
83

    
84
isp: $(TARGET)
85
	$(ISPFUSES)
86
	$(ISPFLASH)
87

    
88
isp-stk500: $(PROGRAM)_$(TARGET).hex
89
	$(STK500-1)
90
	$(STK500-2)
91

    
92
%.elf: $(OBJ)
93
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
94

    
95
clean:
96
	rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
97

    
98
%.lst: %.elf
99
	$(OBJDUMP) -h -S $< > $@
100

    
101
%.hex: %.elf
102
	$(OBJCOPY) -j .text -j .data -O ihex $< $@
103

    
104
%.srec: %.elf
105
	$(OBJCOPY) -j .text -j .data -O srec $< $@
106

    
107
%.bin: %.elf
108
	$(OBJCOPY) -j .text -j .data -O binary $< $@
109