diff options
Diffstat (limited to 'lib/chibios/demos/AVR/RT-PRO-MICRO/Makefile')
-rw-r--r-- | lib/chibios/demos/AVR/RT-PRO-MICRO/Makefile | 315 |
1 files changed, 315 insertions, 0 deletions
diff --git a/lib/chibios/demos/AVR/RT-PRO-MICRO/Makefile b/lib/chibios/demos/AVR/RT-PRO-MICRO/Makefile new file mode 100644 index 000000000..4f6d238ca --- /dev/null +++ b/lib/chibios/demos/AVR/RT-PRO-MICRO/Makefile | |||
@@ -0,0 +1,315 @@ | |||
1 | |||
2 | ############################################################################## | ||
3 | # | ||
4 | # @file Makefile. | ||
5 | # | ||
6 | # @brief AVR Make file, it can be use to build, and program an application to | ||
7 | # an AVR MCU like atmega328p, atmega2560 and so on. | ||
8 | # | ||
9 | # @author Theodore Ateba, [email protected] | ||
10 | # | ||
11 | ############################################################################## | ||
12 | |||
13 | ############################################################################## | ||
14 | # Building and programming global options. | ||
15 | # NOTE: Can be overridden externally. | ||
16 | # | ||
17 | |||
18 | # Compiler options here. | ||
19 | ifeq ($(USE_OPT),) | ||
20 | USE_OPT = -O2 | ||
21 | endif | ||
22 | |||
23 | # C specific options here (added to USE_OPT). | ||
24 | ifeq ($(USE_COPT),) | ||
25 | USE_COPT = | ||
26 | endif | ||
27 | |||
28 | # C++ specific options here (added to USE_OPT). | ||
29 | ifeq ($(USE_CPPOPT),) | ||
30 | USE_CPPOPT = | ||
31 | endif | ||
32 | |||
33 | # Enable this if you want to see the full log while compiling. | ||
34 | ifeq ($(USE_VERBOSE_COMPILE),) | ||
35 | USE_VERBOSE_COMPILE = no | ||
36 | endif | ||
37 | |||
38 | # If enabled, this option makes the build process faster by not compiling | ||
39 | # modules not used in the current configuration. | ||
40 | ifeq ($(USE_SMART_BUILD),) | ||
41 | USE_SMART_BUILD = yes | ||
42 | endif | ||
43 | |||
44 | # If enable, this option arase the counter cycle after device programming. | ||
45 | ifeq ($(USE_AVRDUDE_ERASE_COUNTER),) | ||
46 | USE_AVRDUDE_ERASE_COUNTER = no | ||
47 | endif | ||
48 | |||
49 | # If enable, this option perform a verification after device programming. | ||
50 | ifeq ($(USE_AVRDUDE_NO_VERIFY),) | ||
51 | USE_AVRDUDE_NO_VERIFY = no | ||
52 | endif | ||
53 | |||
54 | # If enabled, this option increase the programming verbosity level. | ||
55 | ifeq ($(USE_VERBOSE_PROGRAMMATION),) | ||
56 | USE_VERBOSE_PROGRAMMATION = no | ||
57 | endif | ||
58 | |||
59 | # Enable this if you want to use AVRDUDE programmer. | ||
60 | ifeq ($(USE_AVRDUDE_PROGRAMMER),) | ||
61 | USE_AVRDUDE_PROGRAMMER = yes | ||
62 | endif | ||
63 | |||
64 | # Enable this if you want to use DFU programmer. | ||
65 | ifeq ($(USE_DFU_PROGRAMMER),) | ||
66 | USE_DFU_PROGRAMMER = no | ||
67 | endif | ||
68 | |||
69 | # Enable this if you want to use MICRONUCLEUS programmer. | ||
70 | ifeq ($(USE_MICRONUCLEUS_PROGRAMMER),) | ||
71 | USE_MICRONUCLEUS_PROGRAMMER = no | ||
72 | endif | ||
73 | |||
74 | # | ||
75 | # Building and programming global options. | ||
76 | ############################################################################## | ||
77 | |||
78 | ############################################################################## | ||
79 | # Project, sources and paths. | ||
80 | # | ||
81 | |||
82 | # Define project name here. | ||
83 | PROJECT = ch | ||
84 | |||
85 | # Imported source files and paths | ||
86 | CHIBIOS := ../../.. | ||
87 | CONFDIR := ./cfg | ||
88 | BUILDDIR := ./build | ||
89 | DEPDIR := ./.dep | ||
90 | |||
91 | # Licensing files. | ||
92 | include $(CHIBIOS)/os/license/license.mk | ||
93 | |||
94 | # HAL-OSAL files (optional). | ||
95 | include $(CHIBIOS)/os/hal/hal.mk | ||
96 | include $(CHIBIOS)/os/hal/boards/SPARKFUN_PRO_MICRO/board.mk | ||
97 | include $(CHIBIOS)/os/hal/ports/AVR/MEGA/ATMEGAxx/platform.mk | ||
98 | include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk | ||
99 | |||
100 | # RTOS files (optional). | ||
101 | include $(CHIBIOS)/os/rt/rt.mk | ||
102 | include $(CHIBIOS)/os/common/ports/AVR/compilers/GCC/mk/port.mk | ||
103 | |||
104 | # List C source files here. (C dependencies are automatically generated.) | ||
105 | CSRC = $(ALLCSRC) \ | ||
106 | usbcfg.c \ | ||
107 | main.c | ||
108 | |||
109 | # List C++ sources file here. | ||
110 | CPPSRC = $(ALLCPPSRC) | ||
111 | |||
112 | # Header files here. | ||
113 | INCDIR = $(CONFDIR) $(ALLINC) | ||
114 | |||
115 | # | ||
116 | # Project, sources and paths. | ||
117 | ############################################################################## | ||
118 | |||
119 | ############################################################################## | ||
120 | # Compiler settings. | ||
121 | # | ||
122 | |||
123 | # Micro-Controller Unit. | ||
124 | MCU = atmega32u4 | ||
125 | |||
126 | # MCU frequency (Hz). | ||
127 | F_CPU = 16000000 | ||
128 | |||
129 | # Output format. (can be srec, ihex, binary) | ||
130 | FORMAT = ihex | ||
131 | |||
132 | # C and C++ Compiler name. | ||
133 | TRGT = avr- | ||
134 | CC = $(TRGT)gcc | ||
135 | CPPC = $(TRGT)g++ | ||
136 | |||
137 | # Enable loading with g++ only if you need C++ runtime support. | ||
138 | # NOTE: You can use C++ even without C++ support if you are careful. C++ | ||
139 | # runtime support makes code size explode. | ||
140 | LD = $(TRGT)gcc | ||
141 | CP = $(TRGT)objcopy | ||
142 | AR = $(TRGT)ar rcs | ||
143 | OD = $(TRGT)objdump | ||
144 | NM = $(TRGT)nm | ||
145 | SZ = $(TRGT)size | ||
146 | HEX = $(CP) -O ihex | ||
147 | BIN = $(CP) -O binary | ||
148 | |||
149 | # Size of the elf binary file. | ||
150 | ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf | ||
151 | |||
152 | # MCU specific options here. | ||
153 | MOPT = | ||
154 | |||
155 | # Define C warning options here. | ||
156 | CWARN = -Wall -Wstrict-prototypes | ||
157 | |||
158 | # Define C++ warning options here. | ||
159 | CPPWARN = | ||
160 | |||
161 | # | ||
162 | # Compiler settings. | ||
163 | ############################################################################## | ||
164 | |||
165 | ############################################################################## | ||
166 | # Start of user section. | ||
167 | # | ||
168 | |||
169 | # List all user C define here, like -D_DEBUG=1. | ||
170 | UDEFS = | ||
171 | |||
172 | # Define ASM defines here. | ||
173 | UADEFS = | ||
174 | |||
175 | # List all user directories here. | ||
176 | UINCDIR = | ||
177 | |||
178 | # List the user directory to look for the libraries here. | ||
179 | ULIBDIR = | ||
180 | |||
181 | # List all user libraries here. | ||
182 | ULIBS = | ||
183 | |||
184 | # | ||
185 | # End of user defines. | ||
186 | ############################################################################## | ||
187 | |||
188 | ############################################################################## | ||
189 | # Start of programming Options. | ||
190 | # | ||
191 | |||
192 | # List of available AVR programmer. | ||
193 | AVRDUDE_PROGRAMMER = avrdude | ||
194 | AVRDUDE_PROGRAMMER_ID = wiring | ||
195 | DFU_PROGRAMMER = dfu-programmer | ||
196 | MICRONUCLEUS = micronucleus | ||
197 | |||
198 | # Set the AVR programmer according to the selection.. | ||
199 | ifeq ($(USE_AVRDUDE_PROGRAMMER),yes) | ||
200 | AVR_PROGRAMMER = $(AVRDUDE_PROGRAMMER) | ||
201 | else ifeq ($(USE_DFU_PROGRAMMER),yes) | ||
202 | AVR_PROGRAMMER = $(DFU_PROGRAMMER) | ||
203 | else ifeq ($(USE_MICRONUCLEUS_PROGRAMMER),yes) | ||
204 | AVR_PROGRAMMER = $(MICRONUCLEUS_PROGRAMMER) | ||
205 | else | ||
206 | $(error ERROR: Please you need to configure the AVR programmer!) | ||
207 | endif | ||
208 | |||
209 | # AVR serial port. | ||
210 | AVRDUDE_PORT = /dev/ttyUSB0 | ||
211 | |||
212 | AVRDUDE_WRITE_FLASH = -D -U flash:w:$(BUILDDIR)/$(PROJECT).hex | ||
213 | |||
214 | # Check if the counter cycle erase must be performed after device programming. | ||
215 | ifeq ($(USE_AVRDUDE_ERASE_COUNTER),yes) | ||
216 | AVRDUDE_ERASE_COUNTER = -y | ||
217 | endif | ||
218 | |||
219 | # Check if a verification must be performed after device programming. | ||
220 | ifeq ($(USE_AVRDUDE_NO_VERIFY),no) | ||
221 | AVRDUDE_NO_VERIFY = -V | ||
222 | endif | ||
223 | |||
224 | # Check verbosity level activation. | ||
225 | ifeq ($(USE_VERBOSE_PROGRAMMATION),yes) | ||
226 | AVRDUDE_VERBOSE = -v -v | ||
227 | endif | ||
228 | |||
229 | # AVR programmer flags for AVRDUDE programmer. | ||
230 | ifeq ($(AVR_PROGRAMMER),$(AVRDUDE_PROGRAMMER)) | ||
231 | AVRDUDE_FLAGS = -p $(MCU) | ||
232 | AVRDUDE_FLAGS += -P $(AVRDUDE_PORT) | ||
233 | AVRDUDE_FLAGS += -b 115200 | ||
234 | AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER_ID) | ||
235 | AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) | ||
236 | AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) | ||
237 | AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) | ||
238 | endif | ||
239 | |||
240 | # AVR programmer flags for DFU programmer. | ||
241 | ifeq ($(AVR_PROGRAMMER),$(DFU_PROGRAMMER)) | ||
242 | DFU_WRITE_FLASH = flash --force | ||
243 | DFU_ERASE_FLASH = erase | ||
244 | DFU_RESET=reset | ||
245 | endif | ||
246 | |||
247 | # AVR programmer flags for MICRONUCLEUS programmer. | ||
248 | ifeq ($(AVR_PROGRAMMER),$(MICRONUCLEUS_PROGRAMMER)) | ||
249 | MICRONUCLEUS_TIMEOUT_ARG = --timeout 60 | ||
250 | MICRONUCLEUS_RUN_ARG = --run | ||
251 | MICRONUCLEUS_TYPE_ARG = --type raw | ||
252 | MICRONUCLEUS_DUMP_PROGRESS = --dump-progress | ||
253 | MICRONUCLEUS_FLAGS=$(MICRONUCLEUS_TYPE_ARG) | ||
254 | MICRONUCLEUS_FLAGS+=$(MICRONUCLEUS_TIMEOUT_ARG) | ||
255 | MICRONUCLEUS_FLAGS+=$(MICRONUCLEUS_RUN_ARG) | ||
256 | endif | ||
257 | |||
258 | # | ||
259 | # End of Programming Options. | ||
260 | ############################################################################## | ||
261 | |||
262 | ############################################################################## | ||
263 | # Include file. | ||
264 | # | ||
265 | |||
266 | RULESPATH = $(CHIBIOS)/os/common/ports/AVR/compilers/GCC | ||
267 | include $(RULESPATH)/rules.mk | ||
268 | |||
269 | # | ||
270 | # End of include file. | ||
271 | ############################################################################## | ||
272 | |||
273 | ############################################################################## | ||
274 | # Programming rules | ||
275 | # | ||
276 | |||
277 | # AVRDUDE programming rules. | ||
278 | ifeq ($(AVR_PROGRAMMER),$(AVRDUDE_PROGRAMMER)) | ||
279 | program: $(BUILDDIR)/$(PROJECT).hex | ||
280 | @echo | ||
281 | @echo Programming $(MCU) device. | ||
282 | $(AVR_PROGRAMMER) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $< | ||
283 | @echo Done. | ||
284 | endif | ||
285 | |||
286 | # DFU programming rules. | ||
287 | ifeq ($(AVR_PROGRAMMER),$(DFU_PROGRAMMER)) | ||
288 | program: $(BUILDDIR)/$(PROJECT).hex | ||
289 | @echo | ||
290 | @echo Programming $(MCU) device. | ||
291 | $(AVR_PROGRAMMER) $(MCU) $(DFU_WRITE_FLASH) $< | ||
292 | $(AVR_PROGRAMMER) $(MCU) $(DFU_RESET) | ||
293 | @echo Done. | ||
294 | |||
295 | erase: | ||
296 | @echo | ||
297 | @echo Erasing $(MCU) device. | ||
298 | $(AVR_PROGRAMMER) $(MCU) $(DFU_ERASE_FLASH) | ||
299 | @echo Done. | ||
300 | endif | ||
301 | |||
302 | # MICRONUCLEUS programming rules. | ||
303 | ifeq ($(AVR_PROGRAMMER),$(MICRONUCLEUS_PROGRAMMER)) | ||
304 | program: $(BUILDDIR)/$(PROJECT).bin | ||
305 | @echo | ||
306 | @echo Programming $(MCU) device. | ||
307 | $(AVR_PROGRAMMER) $(MICRONUCLEUS_FLAGS) $< | ||
308 | @echo Done. | ||
309 | endif | ||
310 | |||
311 | # | ||
312 | # End of programming rules. | ||
313 | ############################################################################## | ||
314 | |||
315 | # EOF | ||