Rev 304 | Rev 401 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 304 | Rev 395 | ||
---|---|---|---|
1 | #-------------------------------------------------------------------- |
1 | #-------------------------------------------------------------------- |
2 | # MCU name |
2 | # MCU name |
3 | MCU = atmega644 |
3 | MCU = atmega644 |
4 | F_CPU = 20000000 |
4 | F_CPU = 20000000 |
5 | #------------------------------------------------------------------- |
5 | #------------------------------------------------------------------- |
6 | HAUPT_VERSION = 0 |
6 | HAUPT_VERSION = 0 |
7 | NEBEN_VERSION = 65 |
7 | NEBEN_VERSION = 66 |
8 | VERSION_INDEX = 0 |
8 | VERSION_INDEX = 0 |
9 | 9 | ||
10 | VERSION_KOMPATIBEL = 5 # PC-Kompatibilität |
10 | VERSION_KOMPATIBEL = 6 # PC-Kompatibilität |
11 | #------------------------------------------------------------------- |
11 | #------------------------------------------------------------------- |
12 | 12 | ||
13 | ifeq ($(MCU), atmega32) |
13 | ifeq ($(MCU), atmega32) |
14 | # FUSE_SETTINGS= -u -U lfuse:w:0xff:m -U hfuse:w:0xcf:m |
14 | # FUSE_SETTINGS= -u -U lfuse:w:0xff:m -U hfuse:w:0xcf:m |
15 | 15 | ||
16 | HEX_NAME = MEGA32 |
16 | HEX_NAME = MEGA32 |
17 | endif |
17 | endif |
18 | 18 | ||
19 | ifeq ($(MCU), atmega644) |
19 | ifeq ($(MCU), atmega644) |
20 | FUSE_SETTINGS = -u -U lfuse:w:0xff:m -U hfuse:w:0xdf:m |
20 | FUSE_SETTINGS = -u -U lfuse:w:0xff:m -U hfuse:w:0xdf:m |
21 | #FUSE_SETTINGS = -U lfuse:w:0xff:m -U hfuse:w:0xdf:m |
21 | #FUSE_SETTINGS = -U lfuse:w:0xff:m -U hfuse:w:0xdf:m |
22 | 22 | ||
23 | # -u bei neuen Controllern wieder einspielen |
23 | # -u bei neuen Controllern wieder einspielen |
24 | 24 | ||
25 | HEX_NAME = MEGA644 |
25 | HEX_NAME = MEGA644 |
26 | endif |
26 | endif |
27 | 27 | ||
28 | ifeq ($(F_CPU), 16000000) |
28 | ifeq ($(F_CPU), 16000000) |
29 | QUARZ = 16MHZ |
29 | QUARZ = 16MHZ |
30 | endif |
30 | endif |
31 | 31 | ||
32 | ifeq ($(F_CPU), 20000000) |
32 | ifeq ($(F_CPU), 20000000) |
33 | QUARZ = 20MHZ |
33 | QUARZ = 20MHZ |
34 | endif |
34 | endif |
35 | 35 | ||
36 | 36 | ||
37 | # Output format. (can be srec, ihex, binary) |
37 | # Output format. (can be srec, ihex, binary) |
38 | FORMAT = ihex |
38 | FORMAT = ihex |
39 | 39 | ||
40 | # Target file name (without extension). |
40 | # Target file name (without extension). |
41 | 41 | ||
42 | ifeq ($(VERSION_INDEX), 0) |
42 | ifeq ($(VERSION_INDEX), 0) |
43 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(HAUPT_VERSION)_$(NEBEN_VERSION)a |
43 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(HAUPT_VERSION)_$(NEBEN_VERSION)a |
44 | endif |
44 | endif |
45 | ifeq ($(VERSION_INDEX), 1) |
45 | ifeq ($(VERSION_INDEX), 1) |
46 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(HAUPT_VERSION)_$(NEBEN_VERSION)b |
46 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(HAUPT_VERSION)_$(NEBEN_VERSION)b |
47 | endif |
47 | endif |
48 | ifeq ($(VERSION_INDEX), 2) |
48 | ifeq ($(VERSION_INDEX), 2) |
49 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(HAUPT_VERSION)_$(NEBEN_VERSION)c |
49 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(HAUPT_VERSION)_$(NEBEN_VERSION)c |
50 | endif |
50 | endif |
51 | ifeq ($(VERSION_INDEX), 3) |
51 | ifeq ($(VERSION_INDEX), 3) |
52 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(HAUPT_VERSION)_$(NEBEN_VERSION)d |
52 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(HAUPT_VERSION)_$(NEBEN_VERSION)d |
53 | endif |
53 | endif |
54 | ifeq ($(VERSION_INDEX), 4) |
54 | ifeq ($(VERSION_INDEX), 4) |
55 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(HAUPT_VERSION)_$(NEBEN_VERSION)e |
55 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(HAUPT_VERSION)_$(NEBEN_VERSION)e |
56 | endif |
56 | endif |
57 | ifeq ($(VERSION_INDEX), 5) |
57 | ifeq ($(VERSION_INDEX), 5) |
58 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(HAUPT_VERSION)_$(NEBEN_VERSION)f |
58 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(HAUPT_VERSION)_$(NEBEN_VERSION)f |
59 | endif |
59 | endif |
60 | 60 | ||
61 | # Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization. |
61 | # Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization. |
62 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
62 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
63 | OPT = s |
63 | OPT = s |
64 | 64 | ||
65 | ########################################################################################################## |
65 | ########################################################################################################## |
66 | # List C source files here. (C dependencies are automatically generated.) |
66 | # List C source files here. (C dependencies are automatically generated.) |
67 | SRC = main.c uart.c printf_P.c timer0.c analog.c menu.c |
67 | SRC = main.c uart.c printf_P.c timer0.c analog.c menu.c |
68 | SRC += twimaster.c rc.c fc.c GPS.c spi.c |
68 | SRC += twimaster.c rc.c fc.c GPS.c |
- | 69 | #spi.c |
|
69 | 70 | ||
70 | ########################################################################################################## |
71 | ########################################################################################################## |
71 | 72 | ||
72 | 73 | ||
73 | # List Assembler source files here. |
74 | # List Assembler source files here. |
74 | # Make them always end in a capital .S. Files ending in a lowercase .s |
75 | # Make them always end in a capital .S. Files ending in a lowercase .s |
75 | # will not be considered source files but generated files (assembler |
76 | # will not be considered source files but generated files (assembler |
76 | # output from the compiler), and will be deleted upon "make clean"! |
77 | # output from the compiler), and will be deleted upon "make clean"! |
77 | # Even though the DOS/Win* filesystem matches both .s and .S the same, |
78 | # Even though the DOS/Win* filesystem matches both .s and .S the same, |
78 | # it will preserve the spelling of the filenames, and gcc itself does |
79 | # it will preserve the spelling of the filenames, and gcc itself does |
79 | # care about how the name is spelled on its command-line. |
80 | # care about how the name is spelled on its command-line. |
80 | ASRC = |
81 | ASRC = |
81 | 82 | ||
82 | 83 | ||
83 | 84 | ||
84 | # List any extra directories to look for include files here. |
85 | # List any extra directories to look for include files here. |
85 | # Each directory must be seperated by a space. |
86 | # Each directory must be seperated by a space. |
86 | EXTRAINCDIRS = |
87 | EXTRAINCDIRS = |
87 | 88 | ||
88 | 89 | ||
89 | # Optional compiler flags. |
90 | # Optional compiler flags. |
90 | # -g: generate debugging information (for GDB, or for COFF conversion) |
91 | # -g: generate debugging information (for GDB, or for COFF conversion) |
91 | # -O*: optimization level |
92 | # -O*: optimization level |
92 | # -f...: tuning, see gcc manual and avr-libc documentation |
93 | # -f...: tuning, see gcc manual and avr-libc documentation |
93 | # -Wall...: warning level |
94 | # -Wall...: warning level |
94 | # -Wa,...: tell GCC to pass this to the assembler. |
95 | # -Wa,...: tell GCC to pass this to the assembler. |
95 | # -ahlms: create assembler listing |
96 | # -ahlms: create assembler listing |
96 | CFLAGS = -O$(OPT) \ |
97 | CFLAGS = -O$(OPT) \ |
97 | -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \ |
98 | -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \ |
98 | -Wall -Wstrict-prototypes \ |
99 | -Wall -Wstrict-prototypes \ |
99 | -Wa,-adhlns=$(<:.c=.lst) \ |
100 | -Wa,-adhlns=$(<:.c=.lst) \ |
100 | $(patsubst %,-I%,$(EXTRAINCDIRS)) |
101 | $(patsubst %,-I%,$(EXTRAINCDIRS)) |
101 | 102 | ||
102 | 103 | ||
103 | # Set a "language standard" compiler flag. |
104 | # Set a "language standard" compiler flag. |
104 | # Unremark just one line below to set the language standard to use. |
105 | # Unremark just one line below to set the language standard to use. |
105 | # gnu99 = C99 + GNU extensions. See GCC manual for more information. |
106 | # gnu99 = C99 + GNU extensions. See GCC manual for more information. |
106 | #CFLAGS += -std=c89 |
107 | #CFLAGS += -std=c89 |
107 | #CFLAGS += -std=gnu89 |
108 | #CFLAGS += -std=gnu89 |
108 | #CFLAGS += -std=c99 |
109 | #CFLAGS += -std=c99 |
109 | CFLAGS += -std=gnu99 |
110 | CFLAGS += -std=gnu99 |
110 | 111 | ||
111 | CFLAGS += -DVERSION_HAUPTVERSION=$(HAUPT_VERSION) -DVERSION_NEBENVERSION=$(NEBEN_VERSION) -DVERSION_KOMPATIBEL=$(VERSION_KOMPATIBEL) -DVERSION_INDEX=$(VERSION_INDEX) |
112 | CFLAGS += -DVERSION_HAUPTVERSION=$(HAUPT_VERSION) -DVERSION_NEBENVERSION=$(NEBEN_VERSION) -DVERSION_KOMPATIBEL=$(VERSION_KOMPATIBEL) -DVERSION_INDEX=$(VERSION_INDEX) |
112 | 113 | ||
113 | 114 | ||
114 | # Optional assembler flags. |
115 | # Optional assembler flags. |
115 | # -Wa,...: tell GCC to pass this to the assembler. |
116 | # -Wa,...: tell GCC to pass this to the assembler. |
116 | # -ahlms: create listing |
117 | # -ahlms: create listing |
117 | # -gstabs: have the assembler create line number information; note that |
118 | # -gstabs: have the assembler create line number information; note that |
118 | # for use in COFF files, additional information about filenames |
119 | # for use in COFF files, additional information about filenames |
119 | # and function names needs to be present in the assembler source |
120 | # and function names needs to be present in the assembler source |
120 | # files -- see avr-libc docs [FIXME: not yet described there] |
121 | # files -- see avr-libc docs [FIXME: not yet described there] |
121 | ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs |
122 | ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs |
122 | 123 | ||
123 | 124 | ||
124 | 125 | ||
125 | # Optional linker flags. |
126 | # Optional linker flags. |
126 | # -Wl,...: tell GCC to pass this to linker. |
127 | # -Wl,...: tell GCC to pass this to linker. |
127 | # -Map: create map file |
128 | # -Map: create map file |
128 | # --cref: add cross reference to map file |
129 | # --cref: add cross reference to map file |
129 | LDFLAGS = -Wl,-Map=$(TARGET).map,--cref |
130 | LDFLAGS = -Wl,-Map=$(TARGET).map,--cref |
130 | 131 | ||
131 | # Additional libraries |
132 | # Additional libraries |
132 | 133 | ||
133 | # Minimalistic printf version |
134 | # Minimalistic printf version |
134 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_min |
135 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_min |
135 | 136 | ||
136 | # Floating point printf version (requires -lm below) |
137 | # Floating point printf version (requires -lm below) |
137 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt |
138 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt |
138 | 139 | ||
139 | # -lm = math library |
140 | # -lm = math library |
140 | LDFLAGS += -lm |
141 | LDFLAGS += -lm |
141 | 142 | ||
142 | 143 | ||
143 | ##LDFLAGS += -T./linkerfile/avr5.x |
144 | ##LDFLAGS += -T./linkerfile/avr5.x |
144 | 145 | ||
145 | 146 | ||
146 | 147 | ||
147 | # Programming support using avrdude. Settings and variables. |
148 | # Programming support using avrdude. Settings and variables. |
148 | 149 | ||
149 | # Programming hardware: alf avr910 avrisp bascom bsd |
150 | # Programming hardware: alf avr910 avrisp bascom bsd |
150 | # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 |
151 | # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 |
151 | # |
152 | # |
152 | # Type: avrdude -c ? |
153 | # Type: avrdude -c ? |
153 | # to get a full listing. |
154 | # to get a full listing. |
154 | # |
155 | # |
155 | #AVRDUDE_PROGRAMMER = stk200 |
156 | #AVRDUDE_PROGRAMMER = stk200 |
156 | AVRDUDE_PROGRAMMER = dt006 |
157 | AVRDUDE_PROGRAMMER = dt006 |
157 | #AVRDUDE_PROGRAMMER = ponyser |
158 | #AVRDUDE_PROGRAMMER = ponyser |
158 | #falls Ponyser ausgewählt wird, muss sich unsere avrdude-Configdatei im Bin-Verzeichnis des Compilers befinden |
159 | #falls Ponyser ausgewählt wird, muss sich unsere avrdude-Configdatei im Bin-Verzeichnis des Compilers befinden |
159 | 160 | ||
160 | 161 | ||
161 | #AVRDUDE_PORT = com1 # programmer connected to serial device |
162 | #AVRDUDE_PORT = com1 # programmer connected to serial device |
162 | AVRDUDE_PORT = lpt1 # programmer connected to parallel port |
163 | AVRDUDE_PORT = lpt1 # programmer connected to parallel port |
163 | 164 | ||
164 | #AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex |
165 | #AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex |
165 | AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex $(FUSE_SETTINGS) |
166 | AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex $(FUSE_SETTINGS) |
166 | #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep |
167 | #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep |
167 | 168 | ||
168 | AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) |
169 | AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) |
169 | 170 | ||
170 | # Uncomment the following if you want avrdude's erase cycle counter. |
171 | # Uncomment the following if you want avrdude's erase cycle counter. |
171 | # Note that this counter needs to be initialized first using -Yn, |
172 | # Note that this counter needs to be initialized first using -Yn, |
172 | # see avrdude manual. |
173 | # see avrdude manual. |
173 | #AVRDUDE_ERASE += -y |
174 | #AVRDUDE_ERASE += -y |
174 | 175 | ||
175 | # Uncomment the following if you do /not/ wish a verification to be |
176 | # Uncomment the following if you do /not/ wish a verification to be |
176 | # performed after programming the device. |
177 | # performed after programming the device. |
177 | AVRDUDE_FLAGS += -V |
178 | AVRDUDE_FLAGS += -V |
178 | 179 | ||
179 | # Increase verbosity level. Please use this when submitting bug |
180 | # Increase verbosity level. Please use this when submitting bug |
180 | # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> |
181 | # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> |
181 | # to submit bug reports. |
182 | # to submit bug reports. |
182 | #AVRDUDE_FLAGS += -v -v |
183 | #AVRDUDE_FLAGS += -v -v |
183 | 184 | ||
184 | # --------------------------------------------------------------------------- |
185 | # --------------------------------------------------------------------------- |
185 | # Define directories, if needed. |
186 | # Define directories, if needed. |
186 | DIRAVR = c:/winavr |
187 | DIRAVR = c:/winavr |
187 | DIRAVRBIN = $(DIRAVR)/bin |
188 | DIRAVRBIN = $(DIRAVR)/bin |
188 | DIRAVRUTILS = $(DIRAVR)/utils/bin |
189 | DIRAVRUTILS = $(DIRAVR)/utils/bin |
189 | DIRINC = . |
190 | DIRINC = . |
190 | DIRLIB = $(DIRAVR)/avr/lib |
191 | DIRLIB = $(DIRAVR)/avr/lib |
191 | 192 | ||
192 | 193 | ||
193 | # Define programs and commands. |
194 | # Define programs and commands. |
194 | SHELL = sh |
195 | SHELL = sh |
195 | 196 | ||
196 | CC = avr-gcc |
197 | CC = avr-gcc |
197 | 198 | ||
198 | OBJCOPY = avr-objcopy |
199 | OBJCOPY = avr-objcopy |
199 | OBJDUMP = avr-objdump |
200 | OBJDUMP = avr-objdump |
200 | SIZE = avr-size |
201 | SIZE = avr-size |
201 | 202 | ||
202 | # Programming support using avrdude. |
203 | # Programming support using avrdude. |
203 | AVRDUDE = avrdude |
204 | AVRDUDE = avrdude |
204 | 205 | ||
205 | REMOVE = rm -f |
206 | REMOVE = rm -f |
206 | COPY = cp |
207 | COPY = cp |
207 | 208 | ||
208 | HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex |
209 | HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex |
209 | ELFSIZE = $(SIZE) -A $(TARGET).elf |
210 | ELFSIZE = $(SIZE) -A $(TARGET).elf |
210 | 211 | ||
211 | # Define Messages |
212 | # Define Messages |
212 | # English |
213 | # English |
213 | MSG_ERRORS_NONE = Errors: none |
214 | MSG_ERRORS_NONE = Errors: none |
214 | MSG_BEGIN = -------- begin -------- |
215 | MSG_BEGIN = -------- begin -------- |
215 | MSG_END = -------- end -------- |
216 | MSG_END = -------- end -------- |
216 | MSG_SIZE_BEFORE = Size before: |
217 | MSG_SIZE_BEFORE = Size before: |
217 | MSG_SIZE_AFTER = Size after: |
218 | MSG_SIZE_AFTER = Size after: |
218 | MSG_COFF = Converting to AVR COFF: |
219 | MSG_COFF = Converting to AVR COFF: |
219 | MSG_EXTENDED_COFF = Converting to AVR Extended COFF: |
220 | MSG_EXTENDED_COFF = Converting to AVR Extended COFF: |
220 | MSG_FLASH = Creating load file for Flash: |
221 | MSG_FLASH = Creating load file for Flash: |
221 | MSG_EEPROM = Creating load file for EEPROM: |
222 | MSG_EEPROM = Creating load file for EEPROM: |
222 | MSG_EXTENDED_LISTING = Creating Extended Listing: |
223 | MSG_EXTENDED_LISTING = Creating Extended Listing: |
223 | MSG_SYMBOL_TABLE = Creating Symbol Table: |
224 | MSG_SYMBOL_TABLE = Creating Symbol Table: |
224 | MSG_LINKING = Linking: |
225 | MSG_LINKING = Linking: |
225 | MSG_COMPILING = Compiling: |
226 | MSG_COMPILING = Compiling: |
226 | MSG_ASSEMBLING = Assembling: |
227 | MSG_ASSEMBLING = Assembling: |
227 | MSG_CLEANING = Cleaning project: |
228 | MSG_CLEANING = Cleaning project: |
228 | 229 | ||
229 | 230 | ||
230 | # Define all object files. |
231 | # Define all object files. |
231 | OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) |
232 | OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) |
232 | 233 | ||
233 | # Define all listing files. |
234 | # Define all listing files. |
234 | LST = $(ASRC:.S=.lst) $(SRC:.c=.lst) |
235 | LST = $(ASRC:.S=.lst) $(SRC:.c=.lst) |
235 | 236 | ||
236 | # Combine all necessary flags and optional flags. |
237 | # Combine all necessary flags and optional flags. |
237 | # Add target processor to flags. |
238 | # Add target processor to flags. |
238 | #ALL_CFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -I. $(CFLAGS) |
239 | #ALL_CFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -I. $(CFLAGS) |
239 | ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) |
240 | ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) |
240 | ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) |
241 | ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) |
241 | 242 | ||
242 | 243 | ||
243 | # Default target. |
244 | # Default target. |
244 | all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \ |
245 | all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \ |
245 | $(TARGET).lss $(TARGET).sym sizeafter finished end |
246 | $(TARGET).lss $(TARGET).sym sizeafter finished end |
246 | 247 | ||
247 | 248 | ||
248 | # Eye candy. |
249 | # Eye candy. |
249 | # AVR Studio 3.x does not check make's exit code but relies on |
250 | # AVR Studio 3.x does not check make's exit code but relies on |
250 | # the following magic strings to be generated by the compile job. |
251 | # the following magic strings to be generated by the compile job. |
251 | begin: |
252 | begin: |
252 | @echo |
253 | @echo |
253 | @echo $(MSG_BEGIN) |
254 | @echo $(MSG_BEGIN) |
254 | 255 | ||
255 | finished: |
256 | finished: |
256 | @echo $(MSG_ERRORS_NONE) |
257 | @echo $(MSG_ERRORS_NONE) |
257 | 258 | ||
258 | end: |
259 | end: |
259 | @echo $(MSG_END) |
260 | @echo $(MSG_END) |
260 | @echo |
261 | @echo |
261 | 262 | ||
262 | 263 | ||
263 | # Display size of file. |
264 | # Display size of file. |
264 | sizebefore: |
265 | sizebefore: |
265 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi |
266 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi |
266 | 267 | ||
267 | sizeafter: |
268 | sizeafter: |
268 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi |
269 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi |
269 | 270 | ||
270 | 271 | ||
271 | 272 | ||
272 | # Display compiler version information. |
273 | # Display compiler version information. |
273 | gccversion : |
274 | gccversion : |
274 | @$(CC) --version |
275 | @$(CC) --version |
275 | 276 | ||
276 | 277 | ||
277 | # Convert ELF to COFF for use in debugging / simulating in |
278 | # Convert ELF to COFF for use in debugging / simulating in |
278 | # AVR Studio or VMLAB. |
279 | # AVR Studio or VMLAB. |
279 | COFFCONVERT=$(OBJCOPY) --debugging \ |
280 | COFFCONVERT=$(OBJCOPY) --debugging \ |
280 | --change-section-address .data-0x800000 \ |
281 | --change-section-address .data-0x800000 \ |
281 | --change-section-address .bss-0x800000 \ |
282 | --change-section-address .bss-0x800000 \ |
282 | --change-section-address .noinit-0x800000 \ |
283 | --change-section-address .noinit-0x800000 \ |
283 | --change-section-address .eeprom-0x810000 |
284 | --change-section-address .eeprom-0x810000 |
284 | 285 | ||
285 | 286 | ||
286 | coff: $(TARGET).elf |
287 | coff: $(TARGET).elf |
287 | @echo |
288 | @echo |
288 | @echo $(MSG_COFF) $(TARGET).cof |
289 | @echo $(MSG_COFF) $(TARGET).cof |
289 | $(COFFCONVERT) -O coff-avr $< $(TARGET).cof |
290 | $(COFFCONVERT) -O coff-avr $< $(TARGET).cof |
290 | 291 | ||
291 | 292 | ||
292 | extcoff: $(TARGET).elf |
293 | extcoff: $(TARGET).elf |
293 | @echo |
294 | @echo |
294 | @echo $(MSG_EXTENDED_COFF) $(TARGET).cof |
295 | @echo $(MSG_EXTENDED_COFF) $(TARGET).cof |
295 | $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof |
296 | $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof |
296 | 297 | ||
297 | 298 | ||
298 | 299 | ||
299 | 300 | ||
300 | # Program the device. |
301 | # Program the device. |
301 | program: $(TARGET).hex $(TARGET).eep |
302 | program: $(TARGET).hex $(TARGET).eep |
302 | $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) |
303 | $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) |
303 | 304 | ||
304 | 305 | ||
305 | 306 | ||
306 | 307 | ||
307 | # Create final output files (.hex, .eep) from ELF output file. |
308 | # Create final output files (.hex, .eep) from ELF output file. |
308 | %.hex: %.elf |
309 | %.hex: %.elf |
309 | @echo |
310 | @echo |
310 | @echo $(MSG_FLASH) $@ |
311 | @echo $(MSG_FLASH) $@ |
311 | $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ |
312 | $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ |
312 | 313 | ||
313 | %.eep: %.elf |
314 | %.eep: %.elf |
314 | @echo |
315 | @echo |
315 | @echo $(MSG_EEPROM) $@ |
316 | @echo $(MSG_EEPROM) $@ |
316 | -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ |
317 | -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ |
317 | --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ |
318 | --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ |
318 | 319 | ||
319 | # Create extended listing file from ELF output file. |
320 | # Create extended listing file from ELF output file. |
320 | %.lss: %.elf |
321 | %.lss: %.elf |
321 | @echo |
322 | @echo |
322 | @echo $(MSG_EXTENDED_LISTING) $@ |
323 | @echo $(MSG_EXTENDED_LISTING) $@ |
323 | $(OBJDUMP) -h -S $< > $@ |
324 | $(OBJDUMP) -h -S $< > $@ |
324 | 325 | ||
325 | # Create a symbol table from ELF output file. |
326 | # Create a symbol table from ELF output file. |
326 | %.sym: %.elf |
327 | %.sym: %.elf |
327 | @echo |
328 | @echo |
328 | @echo $(MSG_SYMBOL_TABLE) $@ |
329 | @echo $(MSG_SYMBOL_TABLE) $@ |
329 | avr-nm -n $< > $@ |
330 | avr-nm -n $< > $@ |
330 | 331 | ||
331 | 332 | ||
332 | 333 | ||
333 | # Link: create ELF output file from object files. |
334 | # Link: create ELF output file from object files. |
334 | .SECONDARY : $(TARGET).elf |
335 | .SECONDARY : $(TARGET).elf |
335 | .PRECIOUS : $(OBJ) |
336 | .PRECIOUS : $(OBJ) |
336 | %.elf: $(OBJ) |
337 | %.elf: $(OBJ) |
337 | @echo |
338 | @echo |
338 | @echo $(MSG_LINKING) $@ |
339 | @echo $(MSG_LINKING) $@ |
339 | $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) |
340 | $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) |
340 | 341 | ||
341 | 342 | ||
342 | # Compile: create object files from C source files. |
343 | # Compile: create object files from C source files. |
343 | %.o : %.c |
344 | %.o : %.c |
344 | @echo |
345 | @echo |
345 | @echo $(MSG_COMPILING) $< |
346 | @echo $(MSG_COMPILING) $< |
346 | $(CC) -c $(ALL_CFLAGS) $< -o $@ |
347 | $(CC) -c $(ALL_CFLAGS) $< -o $@ |
347 | 348 | ||
348 | 349 | ||
349 | # Compile: create assembler files from C source files. |
350 | # Compile: create assembler files from C source files. |
350 | %.s : %.c |
351 | %.s : %.c |
351 | $(CC) -S $(ALL_CFLAGS) $< -o $@ |
352 | $(CC) -S $(ALL_CFLAGS) $< -o $@ |
352 | 353 | ||
353 | 354 | ||
354 | # Assemble: create object files from assembler source files. |
355 | # Assemble: create object files from assembler source files. |
355 | %.o : %.S |
356 | %.o : %.S |
356 | @echo |
357 | @echo |
357 | @echo $(MSG_ASSEMBLING) $< |
358 | @echo $(MSG_ASSEMBLING) $< |
358 | $(CC) -c $(ALL_ASFLAGS) $< -o $@ |
359 | $(CC) -c $(ALL_ASFLAGS) $< -o $@ |
359 | 360 | ||
360 | 361 | ||
361 | 362 | ||
362 | 363 | ||
363 | 364 | ||
364 | 365 | ||
365 | # Target: clean project. |
366 | # Target: clean project. |
366 | clean: begin clean_list finished end |
367 | clean: begin clean_list finished end |
367 | 368 | ||
368 | clean_list : |
369 | clean_list : |
369 | @echo |
370 | @echo |
370 | @echo $(MSG_CLEANING) |
371 | @echo $(MSG_CLEANING) |
371 | # $(REMOVE) $(TARGET).hex |
372 | # $(REMOVE) $(TARGET).hex |
372 | $(REMOVE) $(TARGET).eep |
373 | $(REMOVE) $(TARGET).eep |
373 | $(REMOVE) $(TARGET).obj |
374 | $(REMOVE) $(TARGET).obj |
374 | $(REMOVE) $(TARGET).cof |
375 | $(REMOVE) $(TARGET).cof |
375 | $(REMOVE) $(TARGET).elf |
376 | $(REMOVE) $(TARGET).elf |
376 | $(REMOVE) $(TARGET).map |
377 | $(REMOVE) $(TARGET).map |
377 | $(REMOVE) $(TARGET).obj |
378 | $(REMOVE) $(TARGET).obj |
378 | $(REMOVE) $(TARGET).a90 |
379 | $(REMOVE) $(TARGET).a90 |
379 | $(REMOVE) $(TARGET).sym |
380 | $(REMOVE) $(TARGET).sym |
380 | $(REMOVE) $(TARGET).lnk |
381 | $(REMOVE) $(TARGET).lnk |
381 | $(REMOVE) $(TARGET).lss |
382 | $(REMOVE) $(TARGET).lss |
382 | $(REMOVE) $(OBJ) |
383 | $(REMOVE) $(OBJ) |
383 | $(REMOVE) $(LST) |
384 | $(REMOVE) $(LST) |
384 | $(REMOVE) $(SRC:.c=.s) |
385 | $(REMOVE) $(SRC:.c=.s) |
385 | $(REMOVE) $(SRC:.c=.d) |
386 | $(REMOVE) $(SRC:.c=.d) |
386 | 387 | ||
387 | 388 | ||
388 | # Automatically generate C source code dependencies. |
389 | # Automatically generate C source code dependencies. |
389 | # (Code originally taken from the GNU make user manual and modified |
390 | # (Code originally taken from the GNU make user manual and modified |
390 | # (See README.txt Credits).) |
391 | # (See README.txt Credits).) |
391 | # |
392 | # |
392 | # Note that this will work with sh (bash) and sed that is shipped with WinAVR |
393 | # Note that this will work with sh (bash) and sed that is shipped with WinAVR |
393 | # (see the SHELL variable defined above). |
394 | # (see the SHELL variable defined above). |
394 | # This may not work with other shells or other seds. |
395 | # This may not work with other shells or other seds. |
395 | # |
396 | # |
396 | %.d: %.c |
397 | %.d: %.c |
397 | set -e; $(CC) -MM $(ALL_CFLAGS) $< \ |
398 | set -e; $(CC) -MM $(ALL_CFLAGS) $< \ |
398 | | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \ |
399 | | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \ |
399 | [ -s $@ ] || rm -f $@ |
400 | [ -s $@ ] || rm -f $@ |
400 | 401 | ||
401 | 402 | ||
402 | # Remove the '-' if you want to see the dependency files generated. |
403 | # Remove the '-' if you want to see the dependency files generated. |
403 | -include $(SRC:.c=.d) |
404 | -include $(SRC:.c=.d) |
404 | 405 | ||
405 | 406 | ||
406 | 407 | ||
407 | # Listing of phony targets. |
408 | # Listing of phony targets. |
408 | .PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \ |
409 | .PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \ |
409 | clean clean_list program |
410 | clean clean_list program |
410 | 411 |