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