Debian Codegraph @

bootloaders/optiboot/Makefile

raw symbols SCIP
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 # enter the parameters for the avrdude isp tool
33 ISPTOOL = avrisp
34 ISPPORT = /dev/ttyUSB0
35 ISPSPEED = -b 19200
36
37 MCU_TARGET = atmega168
38 LDSECTIONS = -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
46 fixpath = $(1)
47
48 # the efuse should really be 0xf8; since, however, only the lower
49 # three bits of that byte are used on the atmega168, avrdude gets
50 # confused if you specify 1's for the higher bits, see:
51 # http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
52 #
53 # similarly, the lock bits should be 0xff instead of 0x3f (to
54 # unlock the bootloader section) and 0xcf instead of 0x2f (to
55 # lock it), but since the high two bits of the lock byte are
56 # unused, avrdude would get confused.
57
58 ISPFUSES = $(AVRDUDE_ROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
59 -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
60 -e -u -U lock:w:0x3f:m -U efuse:w:0x$(EFUSE):m \
61 -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
62 ISPFLASH = $(AVRDUDE_ROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
63 -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) -V \
64 -U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x2f:m
65
66 STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe"
67 STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \
68 -lFF -LFF -f$(HFUSE)$(LFUSE) -EF8 -ms -q -cUSB -I200kHz -s -wt
69 STK500-2 = $(STK500) -d$(MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt
70
71 OBJ = $(PROGRAM).o
72 OPTIMIZE = -Os -fno-inline-small-functions -fno-split-wide-types
73
74 DEFS =
75 LIBS =
76
77 CC = $(GCCROOT)avr-gcc
78
79 # Override is only needed by avr-lib build system.
80
81 override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
82 override LDFLAGS = $(LDSECTIONS) -Wl,--relax -Wl,--gc-sections -nostartfiles -nostdlib
83
84 OBJCOPY = $(GCCROOT)avr-objcopy
85 OBJDUMP = $(call fixpath,$(GCCROOT)avr-objdump)
86
87 SIZE = $(GCCROOT)avr-size
88
89 atmega1284: TARGET = atmega1284p
90 atmega1284: MCU_TARGET = atmega1284p
91 atmega1284: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT'
92 atmega1284: AVR_FREQ = 16000000L
93 atmega1284: LDSECTIONS = -Wl,--section-start=.text=0x1fc00
94 atmega1284: $(PROGRAM)_atmega1284p.hex
95 atmega1284: $(PROGRAM)_atmega1284p.lst
96
97 atmega1284_isp: atmega1284
98 atmega1284_isp: TARGET = atmega1284p
99 atmega1284_isp: MCU_TARGET = atmega1284p
100 # 1024 byte boot
101 atmega1284_isp: HFUSE = DE
102 # Low power xtal (16MHz) 16KCK/14CK+65ms
103 atmega1284_isp: LFUSE = FF
104 # 2.7V brownout
105 atmega1284_isp: EFUSE = FD
106 atmega1284_isp: isp
107
108 atmega1284_slow: TARGET = atmega1284p_slow
109 atmega1284_slow: MCU_TARGET = atmega1284p
110 atmega1284_slow: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=19200' '-DBIGBOOT'
111 atmega1284_slow: AVR_FREQ = 16000000L
112 atmega1284_slow: LDSECTIONS = -Wl,--section-start=.text=0x1fc00
113 atmega1284_slow: $(PROGRAM)_atmega1284p_slow.hex
114 atmega1284_slow: $(PROGRAM)_atmega1284p_slow.lst
115
116 atmega1284_slow_isp: atmega1284_slow
117 atmega1284_slow_isp: TARGET = atmega1284p_slow
118 atmega1284_slow_isp: MCU_TARGET = atmega1284p
119 # 1024 byte boot
120 atmega1284_slow_isp: HFUSE = DE
121 # Low power xtal (16MHz) 16KCK/14CK+65ms
122 atmega1284_slow_isp: LFUSE = FF
123 # 2.7V brownout
124 atmega1284_slow_isp: EFUSE = FD
125 atmega1284_slow_isp: isp
126
127 #
128 # Generic build instructions
129 #
130 #
131
132 isp: $(TARGET)
133 $(ISPFUSES)
134 $(ISPFLASH)
135
136 isp-stk500: $(PROGRAM)_$(TARGET).hex
137 $(STK500-1)
138 $(STK500-2)
139
140 %.elf: $(OBJ)
141 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
142 $(SIZE) $@
143
144 clean:
145 rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
146
147 %.lst: %.elf
148 $(OBJDUMP) -h -S $< > $@
149
150 %.hex: %.elf
151 $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex $< $@
152
153 %.srec: %.elf
154 $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O srec $< $@
155
156 %.bin: %.elf
157 $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O binary $< $@