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