| 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 = -O2 |
| 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 |
atmega328_bt: TARGET = atmega328_bt |
| 70 |
atmega328_bt: MCU_TARGET = atmega328p |
| 71 |
atmega328_bt: AVR_FREQ = 16000000L |
| 72 |
atmega328_bt: LDSECTION = --section-start=.text=0x7000 |
| 73 |
atmega328_bt: $(PROGRAM)_atmega328_bt.hex |
| 74 |
|
| 75 |
atmega328_bt_isp: atmega328_bt |
| 76 |
atmega328_bt_isp: TARGET = atmega328_bt |
| 77 |
atmega328_bt_isp: MCU_TARGET = atmega328p |
| 78 |
atmega328_bt_isp: HFUSE = D8 |
| 79 |
atmega328_bt_isp: LFUSE = FF |
| 80 |
atmega328_bt_isp: EFUSE = 05 |
| 81 |
atmega328_bt_isp: isp |
| 82 |
|
| 83 |
isp: $(TARGET) |
| 84 |
$(ISPFUSES) |
| 85 |
$(ISPFLASH) |
| 86 |
|
| 87 |
isp-stk500: $(PROGRAM)_$(TARGET).hex |
| 88 |
$(STK500-1) |
| 89 |
$(STK500-2) |
| 90 |
|
| 91 |
%.elf: $(OBJ) |
| 92 |
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
| 93 |
|
| 94 |
clean: |
| 95 |
rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex |
| 96 |
|
| 97 |
%.lst: %.elf |
| 98 |
$(OBJDUMP) -h -S $< > $@ |
| 99 |
|
| 100 |
%.hex: %.elf |
| 101 |
$(OBJCOPY) -j .text -j .data -O ihex $< $@ |
| 102 |
|
| 103 |
%.srec: %.elf |
| 104 |
$(OBJCOPY) -j .text -j .data -O srec $< $@ |
| 105 |
|
| 106 |
%.bin: %.elf |
| 107 |
$(OBJCOPY) -j .text -j .data -O binary $< $@ |
| 108 |
|