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