| 1 |
# Makefile for ATmegaBOOT |
| 2 |
# E.Lins, 18.7.2005 |
| 3 |
|
| 4 |
# Instructions |
| 5 |
# |
| 6 |
# To build the bootloader for the LilyPad: |
| 7 |
# make lily |
| 8 |
|
| 9 |
|
| 10 |
# program name should not be changed... |
| 11 |
PROGRAM = ATmegaBOOT_168 |
| 12 |
|
| 13 |
# enter the target CPU frequency |
| 14 |
AVR_FREQ = 8000000L |
| 15 |
|
| 16 |
# enter the parameters for the avrdude isp tool |
| 17 |
ISPTOOL = stk500v2 |
| 18 |
ISPPORT = usb |
| 19 |
ISPSPEED = -b 115200 |
| 20 |
|
| 21 |
MCU_TARGET = atmega168 |
| 22 |
LDSECTION = --section-start=.text=0x3800 |
| 23 |
|
| 24 |
# the efuse should really be 0xf8; since, however, only the lower |
| 25 |
# three bits of that byte are used on the atmega168, avrdude gets |
| 26 |
# confused if you specify 1's for the higher bits, see: |
| 27 |
# http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/ |
| 28 |
# |
| 29 |
# similarly, the lock bits should be 0xff instead of 0x3f (to |
| 30 |
# unlock the bootloader section) and 0xcf instead of 0x0f (to |
| 31 |
# lock it), but since the high two bits of the lock byte are |
| 32 |
# unused, avrdude would get confused. |
| 33 |
ISPFUSES = avrdude -c $(ISPTOOL) -p m168 -P $(ISPPORT) $(ISPSPEED) -e -u -U lock:w:0x3f:m -U efuse:w:0x00:m -U hfuse:w:0xdd:m -U lfuse:w:0xff:m |
| 34 |
ISPFLASH = avrdude -c $(ISPTOOL) -p m168 -P $(ISPPORT) $(ISPSPEED) -U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x0f:m |
| 35 |
|
| 36 |
|
| 37 |
OBJ = $(PROGRAM).o |
| 38 |
OPTIMIZE = -O2 |
| 39 |
|
| 40 |
DEFS = |
| 41 |
LIBS = |
| 42 |
|
| 43 |
CC = avr-gcc |
| 44 |
|
| 45 |
|
| 46 |
# Override is only needed by avr-lib build system. |
| 47 |
|
| 48 |
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS) |
| 49 |
override LDFLAGS = -Wl,$(LDSECTION) |
| 50 |
#override LDFLAGS = -Wl,-Map,$(PROGRAM).map,$(LDSECTION) |
| 51 |
|
| 52 |
OBJCOPY = avr-objcopy |
| 53 |
OBJDUMP = avr-objdump |
| 54 |
|
| 55 |
all: |
| 56 |
|
| 57 |
lily: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>1' '-DNUM_LED_FLASHES=3' |
| 58 |
lily: $(PROGRAM).hex |
| 59 |
|
| 60 |
$(PROGRAM).hex: $(PROGRAM).elf |
| 61 |
$(OBJCOPY) -j .text -j .data -O ihex $< $@ |
| 62 |
|
| 63 |
$(PROGRAM).elf: $(OBJ) |
| 64 |
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
| 65 |
|
| 66 |
$(OBJ): |
| 67 |
avr-gcc $(CFLAGS) $(LDFLAGS) -c -g -O2 -Wall -mmcu=atmega168 ATmegaBOOT.c -o ATmegaBOOT_168.o |
| 68 |
|
| 69 |
%.lst: %.elf |
| 70 |
$(OBJDUMP) -h -S $< > $@ |
| 71 |
|
| 72 |
%.srec: %.elf |
| 73 |
$(OBJCOPY) -j .text -j .data -O srec $< $@ |
| 74 |
|
| 75 |
%.bin: %.elf |
| 76 |
$(OBJCOPY) -j .text -j .data -O binary $< $@ |
| 77 |
|
| 78 |
clean: |
| 79 |
rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex |
| 80 |
|
| 81 |
install: |
| 82 |
avrdude -p m168 -c stk500v2 -P /dev/cu.USA19H1b1P1.1 -e -u -U lock:w:0x3f:m -U efuse:w:0x00:m -U hfuse:w:0xdd:m -U lfuse:w:0xe2:m |
| 83 |
avrdude -p m168 -c stk500v2 -P /dev/cu.USA19H1b1P1.1 -e -u -U flash:w:ATmegaBOOT_168.hex -U lock:w:0x0f:m |