root / branches / autonomous_recharging / code / projects / bay_bootloader / Makefile @ 956
History | View | Annotate | Download (5.47 KB)
1 | 650 | abuchan | # Makefile for ATmegaBOOT |
---|---|---|---|
2 | # E.Lins, 18.7.2005 |
||
3 | |||
4 | # version // year month day |
||
5 | BUILD = 080322 |
||
6 | |||
7 | # program name should not be changed... |
||
8 | PROGRAM = bayboardBOOT |
||
9 | |||
10 | # enter the product name for which you want to build the bootloader/monitor |
||
11 | #PRODUCT = CRUMB8 |
||
12 | #PRODUCT = CRUMB128 |
||
13 | #PRODUCT = CRUMB168 |
||
14 | #PRODUCT = PROBOMEGA128 |
||
15 | #PRODUCT = SAVVY128 |
||
16 | #PRODUCT = AVRELLUM2 |
||
17 | #PRODUCT = FWRBOARD |
||
18 | #PRODUCT = DRAGONFLY_128 |
||
19 | PRODUCT = BAYBOARD |
||
20 | |||
21 | # enter the target CPU frequency |
||
22 | #AVR_FREQ = F3686400 |
||
23 | #AVR_FREQ = F7372800 |
||
24 | AVR_FREQ = F8000000 |
||
25 | #AVR_FREQ = F14745600 |
||
26 | #AVR_FREQ = F16000000 |
||
27 | #AVR_FREQ = F20000000 |
||
28 | |||
29 | # enter the parameters for the UISP isp tool |
||
30 | # for an stk500 at com1 |
||
31 | ISPTOOL = avrisp |
||
32 | ISPPORT = usb |
||
33 | ISPSPEED = -b 115200 |
||
34 | # or an stk200 at lpt1 |
||
35 | #ISPTOOL = stk200 |
||
36 | #ISPPORT = lpt1 |
||
37 | #ISPSPEED = |
||
38 | |||
39 | |||
40 | ############################################################ |
||
41 | # You should not have to change anything below here. |
||
42 | ############################################################ |
||
43 | |||
44 | ifeq ($(PRODUCT),CRUMB8) |
||
45 | MCU_TARGET = atmega8 |
||
46 | LDSECTION = --section-start=.text=0x1800 |
||
47 | ISPFUSES = avrdude -c $(ISPTOOL) -p m8 -P $(ISPPORT) $(ISPSPEED) -u -U hfuse:w:0xc8:m -U lfuse:w:0xdf:m |
||
48 | ISPFLASH = avrdude -c $(ISPTOOL) -p m8 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM)_$(PRODUCT)_$(BUILD).hex |
||
49 | endif |
||
50 | |||
51 | ifeq ($(PRODUCT),FWRBOARD) |
||
52 | MCU_TARGET = atmega168 |
||
53 | LDSECTION = --section-start=.text=0x3800 |
||
54 | ISPFUSES = ./avrdude -c $(ISPTOOL) -p m168 -P $(ISPPORT) $(ISPSPEED) -u -U efuse:w:0xf8:m -U hfuse:w:0xdf:m -U lfuse:w:0xef:m |
||
55 | ISPFLASH = ./avrdude -c $(ISPTOOL) -p m168 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM).hex |
||
56 | endif |
||
57 | |||
58 | ifeq ($(PRODUCT),CRUMB168) |
||
59 | MCU_TARGET = atmega168 |
||
60 | LDSECTION = --section-start=.text=0x3800 |
||
61 | ISPFUSES = avrdude -c $(ISPTOOL) -p m168 -P $(ISPPORT) $(ISPSPEED) -u -U efuse:w:0xf8:m -U hfuse:w:0xd7:m -U lfuse:w:0xaf:m |
||
62 | ISPFLASH = avrdude -c $(ISPTOOL) -p m168 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM)_$(PRODUCT)_$(BUILD).hex |
||
63 | endif |
||
64 | |||
65 | ifeq ($(PRODUCT),AVRELLUM2) |
||
66 | MCU_TARGET = atmega128 |
||
67 | LDSECTION = --section-start=.text=0x1E000 |
||
68 | ISPFUSES = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -u -U efuse:w:0xff:m -U hfuse:w:0xc8:m -U lfuse:w:0xdf:m |
||
69 | ISPFLASH = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM)_$(PRODUCT)_$(BUILD).hex |
||
70 | endif |
||
71 | |||
72 | ifeq ($(PRODUCT),DRAGONFLY_v3) |
||
73 | MCU_TARGET = atmega1281 |
||
74 | LDSECTION = --section-start=.text=0x1E000 |
||
75 | ISPFUSES = avrdude -c $(ISPTOOL) -p m1281 -P $(ISPPORT) $(ISPSPEED) -u -U efuse:w:0xff:m -U hfuse:w:0xc8:m -U lfuse:w:0xdf:m |
||
76 | ISPFLASH = avrdude -c $(ISPTOOL) -p m1281 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM)_$(PRODUCT)_$(BUILD).hex |
||
77 | endif |
||
78 | |||
79 | ifeq ($(PRODUCT),DRAGONFLY_128) |
||
80 | MCU_TARGET = atmega128 |
||
81 | LDSECTION = --section-start=.text=0x1E000 |
||
82 | ISPFUSES = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -u -U efuse:w:0xff:m -U hfuse:w:0xc8:m -U lfuse:w:0xdf:m |
||
83 | ISPFLASH = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM)_$(PRODUCT)_$(BUILD).hex |
||
84 | endif |
||
85 | |||
86 | ifeq ($(PRODUCT),CRUMB128) |
||
87 | MCU_TARGET = atmega128 |
||
88 | LDSECTION = --section-start=.text=0x1E000 |
||
89 | ISPFUSES = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -u -U efuse:w:0xff:m -U hfuse:w:0xc8:m -U lfuse:w:0xdf:m |
||
90 | ISPFLASH = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM)_$(PRODUCT)_$(BUILD).hex |
||
91 | endif |
||
92 | |||
93 | ifeq ($(PRODUCT),PROBOMEGA128) |
||
94 | MCU_TARGET = atmega128 |
||
95 | LDSECTION = --section-start=.text=0x1E000 |
||
96 | ISPFUSES = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -u -U efuse:w:0xff:m -U hfuse:w:0xc8:m -U lfuse:w:0xdf:m |
||
97 | ISPFLASH = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM)_$(PRODUCT)_$(BUILD).hex |
||
98 | endif |
||
99 | |||
100 | ifeq ($(PRODUCT),SAVVY128) |
||
101 | MCU_TARGET = atmega128 |
||
102 | LDSECTION = --section-start=.text=0x1E000 |
||
103 | ISPFUSES = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -u -U efuse:w:0xff:m -U hfuse:w:0xd8:m -U lfuse:w:0xe4:m |
||
104 | ISPFLASH = avrdude -c $(ISPTOOL) -p m128 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM)_$(PRODUCT)_$(BUILD).hex |
||
105 | endif |
||
106 | |||
107 | ifeq ($(PRODUCT),BAYBOARD) |
||
108 | MCU_TARGET = atmega164p |
||
109 | LDSECTION = --section-start=.text=0x3800 |
||
110 | ISPFUSES = avrdude -c $(ISPTOOL) -p m164 -P $(ISPPORT) $(ISPSPEED) -u -U efuse:w:0xff:m -U hfuse:w:0x98:m -U lfuse:w:0xff:m |
||
111 | ISPFLASH = avrdude -c $(ISPTOOL) -p m164 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM)_$(PRODUCT)_$(BUILD).hex |
||
112 | endif |
||
113 | |||
114 | OBJ = $(PROGRAM).o |
||
115 | OPTIMIZE = -O2 |
||
116 | |||
117 | DEFS = |
||
118 | LIBS = |
||
119 | |||
120 | CC = avr-gcc |
||
121 | |||
122 | |||
123 | # Override is only needed by avr-lib build system. |
||
124 | |||
125 | override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -D$(PRODUCT) -D$(AVR_FREQ) $(DEFS) |
||
126 | override LDFLAGS = -Wl,-Map,$(PROGRAM).map,$(LDSECTION) |
||
127 | |||
128 | OBJCOPY = avr-objcopy |
||
129 | OBJDUMP = avr-objdump |
||
130 | |||
131 | all: $(PROGRAM).elf lst text |
||
132 | |||
133 | isp: $(PROGRAM).hex |
||
134 | $(ISPFUSES) |
||
135 | $(ISPFLASH) |
||
136 | |||
137 | $(PROGRAM).elf: $(OBJ) |
||
138 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
||
139 | |||
140 | clean: |
||
141 | rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep |
||
142 | rm -rf $(PROGRAM).hex $(PROGRAM).srec $(PROGRAM).bin |
||
143 | |||
144 | lst: $(PROGRAM).lst |
||
145 | |||
146 | %.lst: %.elf |
||
147 | $(OBJDUMP) -h -S $< > $@ |
||
148 | |||
149 | # Rules for building the .text rom images |
||
150 | |||
151 | text: hex bin srec |
||
152 | |||
153 | hex: $(PROGRAM).hex |
||
154 | bin: $(PROGRAM).bin |
||
155 | srec: $(PROGRAM).srec |
||
156 | |||
157 | %.hex: %.elf |
||
158 | $(OBJCOPY) -j .text -j .data -O ihex $< $@ |
||
159 | cp $@ $(PROGRAM)_$(PRODUCT)_$(AVR_FREQ)_$(BUILD).hex |
||
160 | |||
161 | %.srec: %.elf |
||
162 | $(OBJCOPY) -j .text -j .data -O srec $< $@ |
||
163 | cp $@ $(PROGRAM)_$(PRODUCT)_$(AVR_FREQ)_$(BUILD).srec |
||
164 | |||
165 | %.bin: %.elf |
||
166 | $(OBJCOPY) -j .text -j .data -O binary $< $@ |
||
167 | cp $@ $(PROGRAM)_$(PRODUCT)_$(AVR_FREQ)_$(BUILD).bin |