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