1 ##############################################################################
3 # NOTE: Can be overridden externally.
6 # Compiler options here.
8 USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -std=gnu99 -DPROTOCOL_CHIBIOS
11 # C specific options here (added to USE_OPT).
16 # include specific config.h?
18 USE_COPT += -include $(CONFIG_H)
21 # C++ specific options here (added to USE_OPT).
23 USE_CPPOPT = -fno-rtti
26 # Enable this if you want the linker to remove unused code and data
27 ifeq ($(USE_LINK_GC),)
31 # Linker extra options here.
36 # Enable this if you want link time optimizations (LTO)
41 # If enabled, this option allows to compile the application in THUMB mode.
46 # Enable this if you want to see the full log while compiling.
47 ifeq ($(USE_VERBOSE_COMPILE),)
48 USE_VERBOSE_COMPILE = no
51 # If enabled, this option makes the build process faster by not compiling
52 # modules not used in the current configuration.
53 ifeq ($(USE_SMART_BUILD),)
58 # Build global options
59 ##############################################################################
61 ##############################################################################
62 # Architecture or project specific options
65 # Stack size to be allocated to the Cortex-M process stack. This stack is
66 # the stack used by the main() thread.
67 ifeq ($(USE_PROCESS_STACKSIZE),)
68 USE_PROCESS_STACKSIZE = 0x200
71 # Stack size to the allocated to the Cortex-M main/exceptions stack. This
72 # stack is used for processing interrupts and exceptions.
73 ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
74 USE_EXCEPTIONS_STACKSIZE = 0x400
78 # Architecture or project specific options
79 ##############################################################################
81 ##############################################################################
82 # Project, sources and paths
85 # Imported source files and paths
86 CHIBIOS ?= $(TMK_DIR)/tool/chibios/ChibiOS
87 CHIBIOS_CONTRIB ?= $(TMK_DIR)/tool/chibios/ChibiOS-Contrib
88 # Startup files. Try a few different locations, for compability with old versions and
89 # for things hardware in the contrib repository
90 STARTUP_MK = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk
91 ifeq ("$(wildcard $(STARTUP_MK))","")
92 STARTUP_MK = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk
93 ifeq ("$(wildcard $(STARTUP_MK))","")
94 STARTUP_MK = $(CHIBIOS_CONTRIB)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk
98 # HAL-OSAL files (optional).
99 include $(CHIBIOS)/os/hal/hal.mk
101 PLATFORM_MK = $(CHIBIOS)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/platform.mk
102 ifeq ("$(wildcard $(PLATFORM_MK))","")
103 PLATFORM_MK = $(CHIBIOS_CONTRIB)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/platform.mk
105 include $(PLATFORM_MK)
108 BOARD_MK = $(TARGET_DIR)/boards/$(BOARD)/board.mk
109 ifeq ("$(wildcard $(BOARD_MK))","")
110 BOARD_MK = $(CHIBIOS)/os/hal/boards/$(BOARD)/board.mk
111 ifeq ("$(wildcard $(BOARD_MK))","")
112 BOARD_MK = $(CHIBIOS_CONTRIB)/os/hal/boards/$(BOARD)/board.mk
116 include $(CHIBIOS)/os/hal/osal/rt/osal.mk
117 # RTOS files (optional).
118 include $(CHIBIOS)/os/rt/rt.mk
119 # Compability with old version
120 PORT_V = $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_v$(ARMV)m.mk
121 ifeq ("$(wildcard $(PORT_V))","")
122 PORT_V = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v$(ARMV)m.mk
125 # Other files (optional).
126 include $(CHIBIOS)/os/hal/lib/streams/streams.mk
128 # Define linker script file here
129 ifneq ("$(wildcard $(TARGET_DIR)/ld/$(MCU_LDSCRIPT).ld)","")
130 LDSCRIPT = $(TARGET_DIR)/ld/$(MCU_LDSCRIPT).ld
132 LDSCRIPT = $(STARTUPLD)/$(MCU_LDSCRIPT).ld
135 # C sources that can be compiled in ARM or THUMB mode depending on the global
137 CSRC = $(STARTUPSRC) \
146 $(TMK_DIR)/protocol/chibios/usb_main.c \
147 $(TMK_DIR)/protocol/chibios/main.c \
150 # C++ sources that can be compiled in ARM or THUMB mode depending on the global
154 # C sources to be compiled in ARM mode regardless of the global setting.
155 # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
156 # option that results in lower performance and larger code size.
159 # C++ sources to be compiled in ARM mode regardless of the global setting.
160 # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
161 # option that results in lower performance and larger code size.
164 # C sources to be compiled in THUMB mode regardless of the global setting.
165 # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
166 # option that results in lower performance and larger code size.
169 # C sources to be compiled in THUMB mode regardless of the global setting.
170 # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
171 # option that results in lower performance and larger code size.
174 # List ASM source files here
176 ASMXSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
178 INCDIR = $(CHIBIOS)/os/license \
179 $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
180 $(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
181 $(STREAMSINC) $(LIBINC) $(CHIBIOS)/os/various \
182 $(TMK_DIR) $(COMMON_DIR) $(TMK_DIR)/protocol/chibios \
183 $(TMK_DIR)/protocol $(TARGET_DIR)
186 # Project, sources and paths
187 ##############################################################################
189 ##############################################################################
194 TRGT = arm-none-eabi-
197 # Enable loading with g++ only if you need C++ runtime support.
198 # NOTE: You can use C++ even without C++ support if you are careful. C++
199 # runtime support makes code size explode.
203 AS = $(TRGT)gcc -x assembler-with-cpp
208 BIN = $(CP) -O binary
210 # ARM-specific options here
213 # THUMB-specific options here
214 TOPT = -mthumb -DTHUMB
216 # Define C warning options here
217 CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes -Wno-missing-field-initializers
219 # Define C++ warning options here
220 CPPWARN = -Wall -Wextra -Wundef
224 ##############################################################################
226 ##############################################################################
227 # Start of user section
230 # List all user C define here, like -D_DEBUG=1
231 ## Select which interfaces to include here!
234 # Define ASM defines here
235 UADEFS += $(OPT_DEFS)
236 # bootloader definitions may be used in the startup .s file
237 ifneq ("$(wildcard $(TARGET_DIR)/bootloader_defs.h)","")
238 UADEFS += -include $(TARGET_DIR)/bootloader_defs.h
239 UDEFS += -include $(TARGET_DIR)/bootloader_defs.h
240 else ifneq ("$(wildcard $(TARGET_DIR)/boards/$(BOARD)/bootloader_defs.h)","")
241 UADEFS += -include $(TARGET_DIR)/boards/$(BOARD)/bootloader_defs.h
242 UDEFS += -include $(TARGET_DIR)/boards/$(BOARD)/bootloader_defs.h
245 # List all user directories here
248 # List the user directory to look for the libraries here
251 # List all user libraries here
255 # End of user defines
256 ##############################################################################
258 RULESPATH = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC
259 ifeq ("$(wildcard $(RULESPATH)/rules.mk)","")
260 RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk
262 include $(RULESPATH)/rules.mk