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