| 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... |
| 19 |
PROGRAM = ATmegaBOOT_168 |
| 20 |
|
| 21 |
# enter the parameters for the avrdude isp tool |
| 22 |
ISPTOOL = stk500v2 |
| 23 |
ISPPORT = usb |
| 24 |
ISPSPEED = -b 115200 |
| 25 |
|
| 26 |
MCU_TARGET = atmega168 |
| 27 |
LDSECTION = --section-start=.text=0x3800 |
| 28 |
|
| 29 |
# the efuse should really be 0xf8; since, however, only the lower |
| 30 |
# three bits of that byte are used on the atmega168, avrdude gets |
| 31 |
# confused if you specify 1's for the higher bits, see: |
| 32 |
# http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/ |
| 33 |
# |
| 34 |
# similarly, the lock bits should be 0xff instead of 0x3f (to |
| 35 |
# unlock the bootloader section) and 0xcf instead of 0x0f (to |
| 36 |
# lock it), but since the high two bits of the lock byte are |
| 37 |
# unused, avrdude would get confused. |
| 38 |
|
| 39 |
ISPFUSES = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \ |
| 40 |
-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 |
| 41 |
ISPFLASH = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \ |
| 42 |
-U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x0f:m |
| 43 |
|
| 44 |
STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe" |
| 45 |
STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \ |
| 46 |
-lFF -LFF -f$(HFUSE)$(LFUSE) -EF8 -ms -q -cUSB -I200kHz -s -wt |
| 47 |
STK500-2 = $(STK500) -d$(MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt |
| 48 |
|
| 49 |
|
| 50 |
OBJ = $(PROGRAM).o |
| 51 |
OPTIMIZE = -Os |
| 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) |
| 62 |
#override LDFLAGS = -Wl,-Map,$(PROGRAM).map,$(LDSECTION) |
| 63 |
|
| 64 |
OBJCOPY = avr-objcopy |
| 65 |
OBJDUMP = avr-objdump |
| 66 |
|
| 67 |
all: |
| 68 |
|
| 69 |
lilypad: TARGET = lilypad |
| 70 |
lilypad: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>1' '-DNUM_LED_FLASHES=3' |
| 71 |
lilypad: AVR_FREQ = 8000000L |
| 72 |
lilypad: $(PROGRAM)_lilypad.hex |
| 73 |
|
| 74 |
lilypad_isp: lilypad |
| 75 |
lilypad_isp: TARGET = lilypad |
| 76 |
lilypad_isp: HFUSE = DD |
| 77 |
lilypad_isp: LFUSE = E2 |
| 78 |
lilypad_isp: EFUSE = 00 |
| 79 |
lilypad_isp: isp |
| 80 |
|
| 81 |
lilypad_resonator: TARGET = lilypad_resonator |
| 82 |
lilypad_resonator: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=3' |
| 83 |
lilypad_resonator: AVR_FREQ = 8000000L |
| 84 |
lilypad_resonator: $(PROGRAM)_lilypad_resonator.hex |
| 85 |
|
| 86 |
lilypad_resonator_isp: lilypad_resonator |
| 87 |
lilypad_resonator_isp: TARGET = lilypad_resonator |
| 88 |
lilypad_resonator_isp: HFUSE = DD |
| 89 |
lilypad_resonator_isp: LFUSE = C6 |
| 90 |
lilypad_resonator_isp: EFUSE = 00 |
| 91 |
lilypad_resonator_isp: isp |
| 92 |
|
| 93 |
pro8: TARGET = pro_8MHz |
| 94 |
pro8: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS' |
| 95 |
pro8: AVR_FREQ = 8000000L |
| 96 |
pro8: $(PROGRAM)_pro_8MHz.hex |
| 97 |
|
| 98 |
pro8_isp: pro8 |
| 99 |
pro8_isp: TARGET = pro_8MHz |
| 100 |
pro8_isp: HFUSE = DD |
| 101 |
pro8_isp: LFUSE = C6 |
| 102 |
pro8_isp: EFUSE = 00 |
| 103 |
pro8_isp: isp |
| 104 |
|
| 105 |
pro16: TARGET = pro_16MHz |
| 106 |
pro16: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS' |
| 107 |
pro16: AVR_FREQ = 16000000L |
| 108 |
pro16: $(PROGRAM)_pro_16MHz.hex |
| 109 |
|
| 110 |
pro16_isp: pro16 |
| 111 |
pro16_isp: TARGET = pro_16MHz |
| 112 |
pro16_isp: HFUSE = DD |
| 113 |
pro16_isp: LFUSE = C6 |
| 114 |
pro16_isp: EFUSE = 00 |
| 115 |
pro16_isp: isp |
| 116 |
|
| 117 |
pro20: TARGET = pro_20mhz |
| 118 |
pro20: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS' |
| 119 |
pro20: AVR_FREQ = 20000000L |
| 120 |
pro20: $(PROGRAM)_pro_20mhz.hex |
| 121 |
|
| 122 |
pro20_isp: pro20 |
| 123 |
pro20_isp: TARGET = pro_20mhz |
| 124 |
pro20_isp: HFUSE = DD |
| 125 |
pro20_isp: LFUSE = C6 |
| 126 |
pro20_isp: EFUSE = 00 |
| 127 |
pro20_isp: isp |
| 128 |
|
| 129 |
diecimila: TARGET = diecimila |
| 130 |
diecimila: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' |
| 131 |
diecimila: AVR_FREQ = 16000000L |
| 132 |
diecimila: $(PROGRAM)_diecimila.hex |
| 133 |
|
| 134 |
diecimila_isp: diecimila |
| 135 |
diecimila_isp: TARGET = diecimila |
| 136 |
diecimila_isp: HFUSE = DD |
| 137 |
diecimila_isp: LFUSE = FF |
| 138 |
diecimila_isp: EFUSE = 00 |
| 139 |
diecimila_isp: isp |
| 140 |
|
| 141 |
ng: TARGET = ng |
| 142 |
ng: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>1' '-DNUM_LED_FLASHES=3' |
| 143 |
ng: AVR_FREQ = 16000000L |
| 144 |
ng: $(PROGRAM)_ng.hex |
| 145 |
|
| 146 |
ng_isp: ng |
| 147 |
ng_isp: TARGET = ng |
| 148 |
ng_isp: HFUSE = DD |
| 149 |
ng_isp: LFUSE = FF |
| 150 |
ng_isp: EFUSE = 00 |
| 151 |
ng_isp: isp |
| 152 |
|
| 153 |
atmega328: TARGET = atmega328 |
| 154 |
atmega328: MCU_TARGET = atmega328p |
| 155 |
atmega328: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=57600 |
| 156 |
atmega328: AVR_FREQ = 16000000L |
| 157 |
atmega328: LDSECTION = --section-start=.text=0x7800 |
| 158 |
atmega328: $(PROGRAM)_atmega328.hex |
| 159 |
|
| 160 |
atmega328_isp: atmega328 |
| 161 |
atmega328_isp: TARGET = atmega328 |
| 162 |
atmega328_isp: MCU_TARGET = atmega328p |
| 163 |
atmega328_isp: HFUSE = DA |
| 164 |
atmega328_isp: LFUSE = FF |
| 165 |
atmega328_isp: EFUSE = 05 |
| 166 |
atmega328_isp: isp |
| 167 |
|
| 168 |
atmega328_notp: TARGET = atmega328_notp |
| 169 |
atmega328_notp: MCU_TARGET = atmega328 |
| 170 |
atmega328_notp: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=57600 |
| 171 |
atmega328_notp: AVR_FREQ = 16000000L |
| 172 |
atmega328_notp: LDSECTION = --section-start=.text=0x7800 |
| 173 |
atmega328_notp: $(PROGRAM)_atmega328_notp.hex |
| 174 |
|
| 175 |
atmega328_notp_isp: atmega328_notp |
| 176 |
atmega328_notp_isp: TARGET = atmega328 |
| 177 |
atmega328_notp_isp: MCU_TARGET = atmega328 |
| 178 |
atmega328_notp_isp: HFUSE = DA |
| 179 |
atmega328_notp_isp: LFUSE = FF |
| 180 |
atmega328_notp_isp: EFUSE = 05 |
| 181 |
atmega328_notp_isp: isp |
| 182 |
|
| 183 |
atmega328_pro8: TARGET = atmega328_pro_8MHz |
| 184 |
atmega328_pro8: MCU_TARGET = atmega328p |
| 185 |
atmega328_pro8: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=57600 -DDOUBLE_SPEED |
| 186 |
atmega328_pro8: AVR_FREQ = 8000000L |
| 187 |
atmega328_pro8: LDSECTION = --section-start=.text=0x7800 |
| 188 |
atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.hex |
| 189 |
|
| 190 |
atmega328_pro8_isp: atmega328_pro8 |
| 191 |
atmega328_pro8_isp: TARGET = atmega328_pro_8MHz |
| 192 |
atmega328_pro8_isp: MCU_TARGET = atmega328p |
| 193 |
atmega328_pro8_isp: HFUSE = DA |
| 194 |
atmega328_pro8_isp: LFUSE = FF |
| 195 |
atmega328_pro8_isp: EFUSE = 05 |
| 196 |
atmega328_pro8_isp: isp |
| 197 |
|
| 198 |
mega: TARGET = atmega1280 |
| 199 |
mega: MCU_TARGET = atmega1280 |
| 200 |
mega: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=0' -DBAUD_RATE=57600 |
| 201 |
mega: AVR_FREQ = 16000000L |
| 202 |
mega: LDSECTION = --section-start=.text=0x1F000 |
| 203 |
mega: $(PROGRAM)_atmega1280.hex |
| 204 |
|
| 205 |
mega_isp: mega |
| 206 |
mega_isp: TARGET = atmega1280 |
| 207 |
mega_isp: MCU_TARGET = atmega1280 |
| 208 |
mega_isp: HFUSE = DA |
| 209 |
mega_isp: LFUSE = FF |
| 210 |
mega_isp: EFUSE = F5 |
| 211 |
mega_isp: isp |
| 212 |
|
| 213 |
isp: $(TARGET) |
| 214 |
$(ISPFUSES) |
| 215 |
$(ISPFLASH) |
| 216 |
|
| 217 |
isp-stk500: $(PROGRAM)_$(TARGET).hex |
| 218 |
$(STK500-1) |
| 219 |
$(STK500-2) |
| 220 |
|
| 221 |
%.elf: $(OBJ) |
| 222 |
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
| 223 |
|
| 224 |
clean: |
| 225 |
rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex |
| 226 |
|
| 227 |
%.lst: %.elf |
| 228 |
$(OBJDUMP) -h -S $< > $@ |
| 229 |
|
| 230 |
%.hex: %.elf |
| 231 |
$(OBJCOPY) -j .text -j .data -O ihex $< $@ |
| 232 |
|
| 233 |
%.srec: %.elf |
| 234 |
$(OBJCOPY) -j .text -j .data -O srec $< $@ |
| 235 |
|
| 236 |
%.bin: %.elf |
| 237 |
$(OBJCOPY) -j .text -j .data -O binary $< $@ |
| 238 |
|