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