|
| 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 | +# 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=0x3e00 |
| 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 | +OBJ = $(PROGRAM).o |
| 51 | +OPTIMIZE = -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls |
| 52 | + |
| 53 | +DEFS = |
| 54 | +LIBS = |
| 55 | + |
| 56 | +CC = avr-gcc |
| 57 | + |
| 58 | +# Override is only needed by avr-lib build system. |
| 59 | + |
| 60 | +override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS) |
| 61 | +override LDFLAGS = -Wl,$(LDSECTION) -Wl,--relax -nostartfiles |
| 62 | + |
| 63 | +OBJCOPY = avr-objcopy |
| 64 | +OBJDUMP = avr-objdump |
| 65 | + |
| 66 | +# 20MHz clocked platforms |
| 67 | +# |
| 68 | +# These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue) |
| 69 | +# |
| 70 | + |
| 71 | +pro20: TARGET = pro_20mhz |
| 72 | +pro20: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' |
| 73 | +pro20: AVR_FREQ = 20000000L |
| 74 | +pro20: $(PROGRAM)_pro_20mhz.hex |
| 75 | +pro20: $(PROGRAM)_pro_20mhz.lst |
| 76 | + |
| 77 | +pro20_isp: pro20 |
| 78 | +pro20_isp: TARGET = pro_20mhz |
| 79 | +pro20_isp: HFUSE = DD # 2.7V brownout |
| 80 | +pro20_isp: LFUSE = C6 # Full swing xtal (20MHz) 258CK/14CK+4.1ms |
| 81 | +pro20_isp: EFUSE = 02 # 512 byte boot |
| 82 | +pro20_isp: isp |
| 83 | + |
| 84 | +# 16MHz clocked platforms |
| 85 | +# |
| 86 | +# These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue) |
| 87 | +# |
| 88 | + |
| 89 | +pro16: TARGET = pro_16MHz |
| 90 | +pro16: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' |
| 91 | +pro16: AVR_FREQ = 16000000L |
| 92 | +pro16: $(PROGRAM)_pro_16MHz.hex |
| 93 | +pro16: $(PROGRAM)_pro_16MHz.lst |
| 94 | + |
| 95 | +pro16_isp: pro16 |
| 96 | +pro16_isp: TARGET = pro_16MHz |
| 97 | +pro16_isp: HFUSE = DD # 2.7V brownout |
| 98 | +pro16_isp: LFUSE = C6 # Full swing xtal (20MHz) 258CK/14CK+4.1ms |
| 99 | +pro16_isp: EFUSE = 02 # 512 byte boot |
| 100 | +pro16_isp: isp |
| 101 | + |
| 102 | +# Diecimila and NG use identical bootloaders |
| 103 | +# |
| 104 | +diecimila: TARGET = diecimila |
| 105 | +diecimila: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' |
| 106 | +diecimila: AVR_FREQ = 16000000L |
| 107 | +diecimila: $(PROGRAM)_diecimila.hex |
| 108 | +diecimila: $(PROGRAM)_diecimila.lst |
| 109 | + |
| 110 | +diecimila_isp: diecimila |
| 111 | +diecimila_isp: TARGET = diecimila |
| 112 | +diecimila_isp: HFUSE = DD # 2.7V brownout |
| 113 | +diecimila_isp: LFUSE = FF # Low power xtal (16MHz) 16KCK/14CK+65ms |
| 114 | +diecimila_isp: EFUSE = 02 # 512 byte boot |
| 115 | +diecimila_isp: isp |
| 116 | + |
| 117 | +atmega328: TARGET = atmega328 |
| 118 | +atmega328: MCU_TARGET = atmega328p |
| 119 | +atmega328: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' |
| 120 | +atmega328: AVR_FREQ = 16000000L |
| 121 | +atmega328: LDSECTION = --section-start=.text=0x7e00 |
| 122 | +atmega328: $(PROGRAM)_atmega328.hex |
| 123 | +atmega328: $(PROGRAM)_atmega328.lst |
| 124 | + |
| 125 | +atmega328_isp: atmega328 |
| 126 | +atmega328_isp: TARGET = atmega328 |
| 127 | +atmega328_isp: MCU_TARGET = atmega328p |
| 128 | +atmega328_isp: HFUSE = DE # 512 byte boot |
| 129 | +atmega328_isp: LFUSE = FF # Low power xtal (16MHz) 16KCK/14CK+65ms |
| 130 | +atmega328_isp: EFUSE = 05 # 2.7V brownout |
| 131 | +atmega328_isp: isp |
| 132 | + |
| 133 | +# 8MHz clocked platforms |
| 134 | +# |
| 135 | +# These are capable of 115200 baud |
| 136 | +# |
| 137 | + |
| 138 | +lilypad: TARGET = lilypad |
| 139 | +lilypad: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=115200' |
| 140 | +lilypad: AVR_FREQ = 8000000L |
| 141 | +lilypad: $(PROGRAM)_lilypad.hex |
| 142 | +lilypad: $(PROGRAM)_lilypad.lst |
| 143 | + |
| 144 | +lilypad_isp: lilypad |
| 145 | +lilypad_isp: TARGET = lilypad |
| 146 | +lilypad_isp: HFUSE = DD # 2.7V brownout |
| 147 | +lilypad_isp: LFUSE = E2 # Internal 8MHz osc (8MHz) Slow rising power |
| 148 | +lilypad_isp: EFUSE = 02 # 512 byte boot |
| 149 | +lilypad_isp: isp |
| 150 | + |
| 151 | +lilypad_resonator: TARGET = lilypad_resonator |
| 152 | +lilypad_resonator: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=115200' |
| 153 | +lilypad_resonator: AVR_FREQ = 8000000L |
| 154 | +lilypad_resonator: $(PROGRAM)_lilypad_resonator.hex |
| 155 | +lilypad_resonator: $(PROGRAM)_lilypad_resonator.lst |
| 156 | + |
| 157 | +lilypad_resonator_isp: lilypad_resonator |
| 158 | +lilypad_resonator_isp: TARGET = lilypad_resonator |
| 159 | +lilypad_resonator_isp: HFUSE = DD # 2.7V brownout |
| 160 | +lilypad_resonator_isp: LFUSE = C6 # Full swing xtal (20MHz) 258CK/14CK+4.1ms |
| 161 | +lilypad_resonator_isp: EFUSE = 02 # 512 byte boot |
| 162 | +lilypad_resonator_isp: isp |
| 163 | + |
| 164 | +pro8: TARGET = pro_8MHz |
| 165 | +pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=115200' |
| 166 | +pro8: AVR_FREQ = 8000000L |
| 167 | +pro8: $(PROGRAM)_pro_8MHz.hex |
| 168 | +pro8: $(PROGRAM)_pro_8MHz.lst |
| 169 | + |
| 170 | +pro8_isp: pro8 |
| 171 | +pro8_isp: TARGET = pro_8MHz |
| 172 | +pro8_isp: HFUSE = DD # 2.7V brownout |
| 173 | +pro8_isp: LFUSE = C6 # Full swing xtal (20MHz) 258CK/14CK+4.1ms |
| 174 | +pro8_isp: EFUSE = 02 # 512 byte boot |
| 175 | +pro8_isp: isp |
| 176 | + |
| 177 | +atmega328_pro8: TARGET = atmega328_pro_8MHz |
| 178 | +atmega328_pro8: MCU_TARGET = atmega328p |
| 179 | +atmega328_pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' |
| 180 | +atmega328_pro8: AVR_FREQ = 8000000L |
| 181 | +atmega328_pro8: LDSECTION = --section-start=.text=0x7e00 |
| 182 | +atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.hex |
| 183 | +atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.lst |
| 184 | + |
| 185 | +atmega328_pro8_isp: atmega328_pro8 |
| 186 | +atmega328_pro8_isp: TARGET = atmega328_pro_8MHz |
| 187 | +atmega328_pro8_isp: MCU_TARGET = atmega328p |
| 188 | +atmega328_pro8_isp: HFUSE = DE # 512 byte boot |
| 189 | +atmega328_pro8_isp: LFUSE = FF # Low power xtal (16MHz) 16KCK/14CK+65ms |
| 190 | +atmega328_pro8_isp: EFUSE = 05 # 2.7V brownout |
| 191 | +atmega328_pro8_isp: isp |
| 192 | + |
| 193 | +# 1MHz clocked platforms |
| 194 | +# |
| 195 | +# These are capable of 9600 baud |
| 196 | +# |
| 197 | + |
| 198 | +luminet: TARGET = luminet |
| 199 | +luminet: MCU_TARGET = attiny84 |
| 200 | +luminet: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=9600' |
| 201 | +luminet: CFLAGS += '-DVIRTUAL_BOOT_PARTITION' |
| 202 | +luminet: AVR_FREQ = 1000000L |
| 203 | +luminet: LDSECTION = --section-start=.text=0x1d00 |
| 204 | +luminet: $(PROGRAM)_luminet.hex |
| 205 | +luminet: $(PROGRAM)_luminet.lst |
| 206 | + |
| 207 | +luminet_isp: luminet |
| 208 | +luminet_isp: TARGET = luminet |
| 209 | +luminet_isp: MCU_TARGET = attiny84 |
| 210 | +luminet_isp: HFUSE = DF # Brownout disabled |
| 211 | +luminet_isp: LFUSE = 62 # 1MHz internal oscillator, slowly rising power |
| 212 | +luminet_isp: EFUSE = FE # Self-programming enable |
| 213 | +luminet_isp: isp |
| 214 | + |
| 215 | +isp: $(TARGET) |
| 216 | + $(ISPFUSES) |
| 217 | + $(ISPFLASH) |
| 218 | + |
| 219 | +isp-stk500: $(PROGRAM)_$(TARGET).hex |
| 220 | + $(STK500-1) |
| 221 | + $(STK500-2) |
| 222 | + |
| 223 | +%.elf: $(OBJ) |
| 224 | + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
| 225 | + |
| 226 | +clean: |
| 227 | + rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex |
| 228 | + |
| 229 | +%.lst: %.elf |
| 230 | + $(OBJDUMP) -h -S $< > $@ |
| 231 | + |
| 232 | +%.hex: %.elf |
| 233 | + $(OBJCOPY) -j .text -j .data -O ihex $< $@ |
| 234 | + |
| 235 | +%.srec: %.elf |
| 236 | + $(OBJCOPY) -j .text -j .data -O srec $< $@ |
| 237 | + |
| 238 | +%.bin: %.elf |
| 239 | + $(OBJCOPY) -j .text -j .data -O binary $< $@ |
0 commit comments