diff options
Diffstat (limited to 'tmk_core/chibios.mk')
| -rw-r--r-- | tmk_core/chibios.mk | 436 |
1 files changed, 0 insertions, 436 deletions
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk deleted file mode 100644 index 6b298732c..000000000 --- a/tmk_core/chibios.mk +++ /dev/null | |||
| @@ -1,436 +0,0 @@ | |||
| 1 | # Hey Emacs, this is a -*- makefile -*- | ||
| 2 | ############################################################################## | ||
| 3 | # Architecture or project specific options | ||
| 4 | # | ||
| 5 | |||
| 6 | # Stack size to be allocated to the Cortex-M process stack. This stack is | ||
| 7 | # the stack used by the main() thread. | ||
| 8 | ifeq ($(USE_PROCESS_STACKSIZE),) | ||
| 9 | USE_PROCESS_STACKSIZE = 0x800 | ||
| 10 | endif | ||
| 11 | |||
| 12 | # Stack size to the allocated to the Cortex-M main/exceptions stack. This | ||
| 13 | # stack is used for processing interrupts and exceptions. | ||
| 14 | ifeq ($(USE_EXCEPTIONS_STACKSIZE),) | ||
| 15 | USE_EXCEPTIONS_STACKSIZE = 0x400 | ||
| 16 | endif | ||
| 17 | |||
| 18 | # | ||
| 19 | # Architecture or project specific options | ||
| 20 | ############################################################################## | ||
| 21 | |||
| 22 | ############################################################################## | ||
| 23 | # Project, sources and paths | ||
| 24 | # | ||
| 25 | |||
| 26 | # Imported source files and paths | ||
| 27 | OPT_OS = chibios | ||
| 28 | CHIBIOS = $(TOP_DIR)/lib/chibios | ||
| 29 | CHIBIOS_CONTRIB = $(TOP_DIR)/lib/chibios-contrib | ||
| 30 | |||
| 31 | # | ||
| 32 | # Startup, Port and Platform support selection | ||
| 33 | ############################################################################## | ||
| 34 | |||
| 35 | ifeq ($(strip $(MCU)), risc-v) | ||
| 36 | # RISC-V Support | ||
| 37 | # As of 7.4.2021 there is only one supported RISC-V platform in Chibios-Contrib, | ||
| 38 | # therefore all required settings are hard-coded | ||
| 39 | STARTUP_MK = $(CHIBIOS_CONTRIB)/os/common/startup/RISCV-ECLIC/compilers/GCC/mk/startup_$(MCU_STARTUP).mk | ||
| 40 | PORT_V = $(CHIBIOS_CONTRIB)/os/common/ports/RISCV-ECLIC/compilers/GCC/mk/port.mk | ||
| 41 | RULESPATH = $(CHIBIOS_CONTRIB)/os/common/startup/RISCV-ECLIC/compilers/GCC | ||
| 42 | PLATFORM_MK = $(CHIBIOS_CONTRIB)/os/hal/ports/GD/GD32VF103/platform.mk | ||
| 43 | else | ||
| 44 | # ARM Support | ||
| 45 | CHIBIOS_PORT ?= | ||
| 46 | ifeq ("$(CHIBIOS_PORT)","") | ||
| 47 | CHIBIOS_PORT = ARMv$(ARMV)-M | ||
| 48 | endif | ||
| 49 | |||
| 50 | # Startup files. Try a few different locations, for compability with old versions and | ||
| 51 | # for things hardware in the contrib repository | ||
| 52 | STARTUP_MK = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk | ||
| 53 | ifeq ("$(wildcard $(STARTUP_MK))","") | ||
| 54 | STARTUP_MK = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk | ||
| 55 | ifeq ("$(wildcard $(STARTUP_MK))","") | ||
| 56 | STARTUP_MK = $(CHIBIOS_CONTRIB)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk | ||
| 57 | endif | ||
| 58 | endif | ||
| 59 | |||
| 60 | # Port files. Try a few different locations, for compability with old versions and | ||
| 61 | # for things hardware in the contrib repository | ||
| 62 | PORT_V = $(CHIBIOS)/os/common/ports/$(CHIBIOS_PORT)/compilers/GCC/mk/port.mk | ||
| 63 | ifeq ("$(wildcard $(PORT_V))","") | ||
| 64 | PORT_V = $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_v$(ARMV)m.mk | ||
| 65 | ifeq ("$(wildcard $(PORT_V))","") | ||
| 66 | PORT_V = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v$(ARMV)m.mk | ||
| 67 | endif | ||
| 68 | endif | ||
| 69 | |||
| 70 | # Rules location. Try a few different locations, for compability with old versions and | ||
| 71 | # for things hardware in the contrib repository | ||
| 72 | RULESPATH = $(CHIBIOS)/os/common/ports/$(CHIBIOS_PORT)/compilers/GCC | ||
| 73 | ifeq ("$(wildcard $(RULESPATH)/rules.mk)","") | ||
| 74 | RULESPATH = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC | ||
| 75 | ifeq ("$(wildcard $(RULESPATH)/rules.mk)","") | ||
| 76 | RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC | ||
| 77 | endif | ||
| 78 | endif | ||
| 79 | endif | ||
| 80 | |||
| 81 | ifeq ("$(PLATFORM_NAME)","") | ||
| 82 | PLATFORM_NAME = platform | ||
| 83 | endif | ||
| 84 | |||
| 85 | ifeq ("$(wildcard $(PLATFORM_MK))","") | ||
| 86 | PLATFORM_MK = $(CHIBIOS)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/$(PLATFORM_NAME).mk | ||
| 87 | ifeq ("$(wildcard $(PLATFORM_MK))","") | ||
| 88 | PLATFORM_MK = $(CHIBIOS_CONTRIB)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/$(PLATFORM_NAME).mk | ||
| 89 | endif | ||
| 90 | endif | ||
| 91 | |||
| 92 | include $(STARTUP_MK) | ||
| 93 | include $(PORT_V) | ||
| 94 | include $(PLATFORM_MK) | ||
| 95 | |||
| 96 | # | ||
| 97 | # Board support selection. | ||
| 98 | ############################################################################## | ||
| 99 | |||
| 100 | BOARD_MK := | ||
| 101 | |||
| 102 | ifneq ("$(wildcard $(KEYBOARD_PATH_5)/boards/$(BOARD)/board.mk)","") | ||
| 103 | BOARD_PATH = $(KEYBOARD_PATH_5) | ||
| 104 | BOARD_MK += $(KEYBOARD_PATH_5)/boards/$(BOARD)/board.mk | ||
| 105 | else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/boards/$(BOARD)/board.mk)","") | ||
| 106 | BOARD_PATH = $(KEYBOARD_PATH_4) | ||
| 107 | BOARD_MK += $(KEYBOARD_PATH_4)/boards/$(BOARD)/board.mk | ||
| 108 | else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/boards/$(BOARD)/board.mk)","") | ||
| 109 | BOARD_PATH = $(KEYBOARD_PATH_3) | ||
| 110 | BOARD_MK += $(KEYBOARD_PATH_3)/boards/$(BOARD)/board.mk | ||
| 111 | else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/boards/$(BOARD)/board.mk)","") | ||
| 112 | BOARD_PATH = $(KEYBOARD_PATH_2) | ||
| 113 | BOARD_MK += $(KEYBOARD_PATH_2)/boards/$(BOARD)/board.mk | ||
| 114 | else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/boards/$(BOARD)/board.mk)","") | ||
| 115 | BOARD_PATH = $(KEYBOARD_PATH_1) | ||
| 116 | BOARD_MK += $(KEYBOARD_PATH_1)/boards/$(BOARD)/board.mk | ||
| 117 | else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/board/board.mk)","") | ||
| 118 | BOARD_PATH = $(TOP_DIR)/platforms/chibios/boards/$(BOARD) | ||
| 119 | BOARD_MK += $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/board/board.mk | ||
| 120 | KEYBOARD_PATHS += $(BOARD_PATH)/configs | ||
| 121 | ifneq ("$(wildcard $(BOARD_PATH)/rules.mk)","") | ||
| 122 | include $(BOARD_PATH)/rules.mk | ||
| 123 | endif | ||
| 124 | endif | ||
| 125 | |||
| 126 | ifeq ("$(wildcard $(BOARD_MK))","") | ||
| 127 | BOARD_MK = $(CHIBIOS)/os/hal/boards/$(BOARD)/board.mk | ||
| 128 | ifeq ("$(wildcard $(BOARD_MK))","") | ||
| 129 | BOARD_MK = $(CHIBIOS_CONTRIB)/os/hal/boards/$(BOARD)/board.mk | ||
| 130 | endif | ||
| 131 | endif | ||
| 132 | |||
| 133 | include $(BOARD_MK) | ||
| 134 | |||
| 135 | # | ||
| 136 | # Bootloader selection. | ||
| 137 | ############################################################################## | ||
| 138 | |||
| 139 | # Set bootloader address if supplied. | ||
| 140 | ifdef STM32_BOOTLOADER_ADDRESS | ||
| 141 | OPT_DEFS += -DSTM32_BOOTLOADER_ADDRESS=$(STM32_BOOTLOADER_ADDRESS) | ||
| 142 | endif | ||
| 143 | |||
| 144 | # Work out if we need to set up the include for the bootloader definitions | ||
| 145 | ifneq ("$(wildcard $(KEYBOARD_PATH_5)/bootloader_defs.h)","") | ||
| 146 | OPT_DEFS += -include $(KEYBOARD_PATH_5)/bootloader_defs.h | ||
| 147 | else ifneq ("$(wildcard $(KEYBOARD_PATH_5)/boards/$(BOARD)/bootloader_defs.h)","") | ||
| 148 | OPT_DEFS += -include $(KEYBOARD_PATH_5)/boards/$(BOARD)/bootloader_defs.h | ||
| 149 | else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/bootloader_defs.h)","") | ||
| 150 | OPT_DEFS += -include $(KEYBOARD_PATH_4)/bootloader_defs.h | ||
| 151 | else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/boards/$(BOARD)/bootloader_defs.h)","") | ||
| 152 | OPT_DEFS += -include $(KEYBOARD_PATH_4)/boards/$(BOARD)/bootloader_defs.h | ||
| 153 | else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/bootloader_defs.h)","") | ||
| 154 | OPT_DEFS += -include $(KEYBOARD_PATH_3)/bootloader_defs.h | ||
| 155 | else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/boards/$(BOARD)/bootloader_defs.h)","") | ||
| 156 | OPT_DEFS += -include $(KEYBOARD_PATH_3)/boards/$(BOARD)/bootloader_defs.h | ||
| 157 | else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/bootloader_defs.h)","") | ||
| 158 | OPT_DEFS += -include $(KEYBOARD_PATH_2)/bootloader_defs.h | ||
| 159 | else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/boards/$(BOARD)/bootloader_defs.h)","") | ||
| 160 | OPT_DEFS += -include $(KEYBOARD_PATH_2)/boards/$(BOARD)/bootloader_defs.h | ||
| 161 | else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/bootloader_defs.h)","") | ||
| 162 | OPT_DEFS += -include $(KEYBOARD_PATH_1)/bootloader_defs.h | ||
| 163 | else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/boards/$(BOARD)/bootloader_defs.h)","") | ||
| 164 | OPT_DEFS += -include $(KEYBOARD_PATH_1)/boards/$(BOARD)/bootloader_defs.h | ||
| 165 | else ifneq ("$(wildcard $(BOARD_PATH)/configs/bootloader_defs.h)","") | ||
| 166 | OPT_DEFS += -include $(BOARD_PATH)/configs/bootloader_defs.h | ||
| 167 | endif | ||
| 168 | |||
| 169 | # | ||
| 170 | # ChibiOS config selection. | ||
| 171 | ############################################################################## | ||
| 172 | |||
| 173 | # Work out the config file directories | ||
| 174 | ifneq ("$(wildcard $(KEYBOARD_PATH_5)/chconf.h)","") | ||
| 175 | CHCONFDIR = $(KEYBOARD_PATH_5) | ||
| 176 | else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/chconf.h)","") | ||
| 177 | CHCONFDIR = $(KEYBOARD_PATH_4) | ||
| 178 | else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/chconf.h)","") | ||
| 179 | CHCONFDIR = $(KEYBOARD_PATH_3) | ||
| 180 | else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/chconf.h)","") | ||
| 181 | CHCONFDIR = $(KEYBOARD_PATH_2) | ||
| 182 | else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/chconf.h)","") | ||
| 183 | CHCONFDIR = $(KEYBOARD_PATH_1) | ||
| 184 | else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/configs/chconf.h)","") | ||
| 185 | CHCONFDIR = $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/configs | ||
| 186 | else ifneq ("$(wildcard $(TOP_DIR)/platforms/boards/chibios/common/configs/chconf.h)","") | ||
| 187 | CHCONFDIR = $(TOP_DIR)/platforms/chibios/boards/common/configs | ||
| 188 | endif | ||
| 189 | |||
| 190 | # | ||
| 191 | # HAL config selection. | ||
| 192 | ############################################################################## | ||
| 193 | |||
| 194 | ifneq ("$(wildcard $(KEYBOARD_PATH_5)/halconf.h)","") | ||
| 195 | HALCONFDIR = $(KEYBOARD_PATH_5) | ||
| 196 | else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/halconf.h)","") | ||
| 197 | HALCONFDIR = $(KEYBOARD_PATH_4) | ||
| 198 | else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/halconf.h)","") | ||
| 199 | HALCONFDIR = $(KEYBOARD_PATH_3) | ||
| 200 | else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/halconf.h)","") | ||
| 201 | HALCONFDIR = $(KEYBOARD_PATH_2) | ||
| 202 | else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/halconf.h)","") | ||
| 203 | HALCONFDIR = $(KEYBOARD_PATH_1) | ||
| 204 | else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/configs/halconf.h)","") | ||
| 205 | HALCONFDIR = $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/configs | ||
| 206 | else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/boards/common/configs/halconf.h)","") | ||
| 207 | HALCONFDIR = $(TOP_DIR)/platforms/chibios/boards/common/configs | ||
| 208 | endif | ||
| 209 | |||
| 210 | # | ||
| 211 | # Linker script selection. | ||
| 212 | ############################################################################## | ||
| 213 | |||
| 214 | ifneq ("$(wildcard $(KEYBOARD_PATH_5)/ld/$(MCU_LDSCRIPT).ld)","") | ||
| 215 | LDSCRIPT = $(KEYBOARD_PATH_5)/ld/$(MCU_LDSCRIPT).ld | ||
| 216 | else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/ld/$(MCU_LDSCRIPT).ld)","") | ||
| 217 | LDSCRIPT = $(KEYBOARD_PATH_4)/ld/$(MCU_LDSCRIPT).ld | ||
| 218 | else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/ld/$(MCU_LDSCRIPT).ld)","") | ||
| 219 | LDSCRIPT = $(KEYBOARD_PATH_3)/ld/$(MCU_LDSCRIPT).ld | ||
| 220 | else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/ld/$(MCU_LDSCRIPT).ld)","") | ||
| 221 | LDSCRIPT = $(KEYBOARD_PATH_2)/ld/$(MCU_LDSCRIPT).ld | ||
| 222 | else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/ld/$(MCU_LDSCRIPT).ld)","") | ||
| 223 | LDSCRIPT = $(KEYBOARD_PATH_1)/ld/$(MCU_LDSCRIPT).ld | ||
| 224 | else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/ld/$(MCU_LDSCRIPT).ld)","") | ||
| 225 | LDFLAGS += -L$(TOP_DIR)/platforms/chibios/boards/$(BOARD)/ld | ||
| 226 | LDSCRIPT = $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/ld/$(MCU_LDSCRIPT).ld | ||
| 227 | else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/boards/common/ld/$(MCU_LDSCRIPT).ld)","") | ||
| 228 | LDSCRIPT = $(TOP_DIR)/platforms/chibios/boards/common/ld/$(MCU_LDSCRIPT).ld | ||
| 229 | else ifneq ("$(wildcard $(STARTUPLD_CONTRIB)/$(MCU_LDSCRIPT).ld)","") | ||
| 230 | LDSCRIPT = $(STARTUPLD_CONTRIB)/$(MCU_LDSCRIPT).ld | ||
| 231 | USE_CHIBIOS_CONTRIB = yes | ||
| 232 | else | ||
| 233 | LDSCRIPT = $(STARTUPLD)/$(MCU_LDSCRIPT).ld | ||
| 234 | endif | ||
| 235 | |||
| 236 | # | ||
| 237 | # Include ChibiOS makefiles. | ||
| 238 | ############################################################################## | ||
| 239 | |||
| 240 | # HAL-OSAL files (optional). | ||
| 241 | include $(CHIBIOS)/os/hal/hal.mk | ||
| 242 | -include $(CHIBIOS)/os/hal/osal/rt/osal.mk # ChibiOS <= 19.x | ||
| 243 | -include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk # ChibiOS >= 20.x | ||
| 244 | # RTOS files (optional). | ||
| 245 | include $(CHIBIOS)/os/rt/rt.mk | ||
| 246 | # Other files (optional). | ||
| 247 | include $(CHIBIOS)/os/hal/lib/streams/streams.mk | ||
| 248 | |||
| 249 | PLATFORM_SRC = \ | ||
| 250 | $(STARTUPSRC) \ | ||
| 251 | $(KERNSRC) \ | ||
| 252 | $(PORTSRC) \ | ||
| 253 | $(OSALSRC) \ | ||
| 254 | $(HALSRC) \ | ||
| 255 | $(PLATFORMSRC) \ | ||
| 256 | $(BOARDSRC) \ | ||
| 257 | $(STREAMSSRC) \ | ||
| 258 | $(CHIBIOS)/os/various/syscalls.c \ | ||
| 259 | $(PLATFORM_COMMON_DIR)/syscall-fallbacks.c \ | ||
| 260 | $(PLATFORM_COMMON_DIR)/wait.c | ||
| 261 | |||
| 262 | # Ensure the ASM files are not subjected to LTO -- it'll strip out interrupt handlers otherwise. | ||
| 263 | QUANTUM_LIB_SRC += $(STARTUPASM) $(PORTASM) $(OSALASM) $(PLATFORMASM) | ||
| 264 | |||
| 265 | PLATFORM_SRC := $(patsubst $(TOP_DIR)/%,%,$(PLATFORM_SRC)) | ||
| 266 | |||
| 267 | EXTRAINCDIRS += $(CHIBIOS)/os/license $(CHIBIOS)/os/oslib/include \ | ||
| 268 | $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/configs \ | ||
| 269 | $(TOP_DIR)/platforms/chibios/boards/common/configs \ | ||
| 270 | $(HALCONFDIR) $(CHCONFDIR) \ | ||
| 271 | $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \ | ||
| 272 | $(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \ | ||
| 273 | $(STREAMSINC) $(CHIBIOS)/os/various $(COMMON_VPATH) | ||
| 274 | |||
| 275 | # | ||
| 276 | # ChibiOS-Contrib | ||
| 277 | ############################################################################## | ||
| 278 | |||
| 279 | # Work out if we're using ChibiOS-Contrib by checking if halconf_community.h exists | ||
| 280 | ifneq ("$(wildcard $(KEYBOARD_PATH_5)/halconf_community.h)","") | ||
| 281 | USE_CHIBIOS_CONTRIB = yes | ||
| 282 | else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/halconf_community.h)","") | ||
| 283 | USE_CHIBIOS_CONTRIB = yes | ||
| 284 | else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/halconf_community.h)","") | ||
| 285 | USE_CHIBIOS_CONTRIB = yes | ||
| 286 | else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/halconf_community.h)","") | ||
| 287 | USE_CHIBIOS_CONTRIB = yes | ||
| 288 | else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/halconf_community.h)","") | ||
| 289 | USE_CHIBIOS_CONTRIB = yes | ||
| 290 | else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/configs/halconf_community.h)","") | ||
| 291 | USE_CHIBIOS_CONTRIB = yes | ||
| 292 | endif | ||
| 293 | |||
| 294 | ifeq ($(strip $(USE_CHIBIOS_CONTRIB)),yes) | ||
| 295 | include $(CHIBIOS_CONTRIB)/os/hal/hal.mk | ||
| 296 | PLATFORM_SRC += $(PLATFORMSRC_CONTRIB) $(HALSRC_CONTRIB) | ||
| 297 | EXTRAINCDIRS += $(PLATFORMINC_CONTRIB) $(HALINC_CONTRIB) $(CHIBIOS_CONTRIB)/os/various | ||
| 298 | endif | ||
| 299 | |||
| 300 | # | ||
| 301 | # Project, sources and paths | ||
| 302 | ############################################################################## | ||
| 303 | |||
| 304 | ############################################################################## | ||
| 305 | # Injected configs | ||
| 306 | # | ||
| 307 | ifneq ("$(wildcard $(BOARD_PATH)/configs/config.h)","") | ||
| 308 | CONFIG_H += $(BOARD_PATH)/configs/config.h | ||
| 309 | endif | ||
| 310 | ifneq ("$(wildcard $(BOARD_PATH)/configs/post_config.h)","") | ||
| 311 | POST_CONFIG_H += $(BOARD_PATH)/configs/post_config.h | ||
| 312 | endif | ||
| 313 | |||
| 314 | ############################################################################## | ||
| 315 | # Compiler and Linker configuration | ||
| 316 | # | ||
| 317 | |||
| 318 | # Use defined stack sizes of the main thread in linker scripts | ||
| 319 | LDSYMBOLS =--defsym=__process_stack_size__=$(USE_PROCESS_STACKSIZE),--defsym=__main_stack_size__=$(USE_EXCEPTIONS_STACKSIZE) | ||
| 320 | |||
| 321 | # Shared Compiler flags for all toolchains | ||
| 322 | SHARED_CFLAGS = -fomit-frame-pointer \ | ||
| 323 | -ffunction-sections \ | ||
| 324 | -fdata-sections \ | ||
| 325 | -fno-common \ | ||
| 326 | -fshort-wchar | ||
| 327 | |||
| 328 | # Shared Linker flags for all toolchains | ||
| 329 | SHARED_LDFLAGS = -T $(LDSCRIPT) \ | ||
| 330 | -Wl,$(LDSYMBOLS) \ | ||
| 331 | -Wl,--gc-sections \ | ||
| 332 | -nostartfiles | ||
| 333 | |||
| 334 | ifeq ($(strip $(MCU)), risc-v) | ||
| 335 | # RISC-V toolchain specific configuration | ||
| 336 | # Find suitable GCC compiler | ||
| 337 | ifeq ($(strip $(TOOLCHAIN)),) | ||
| 338 | ifneq ($(shell which riscv32-unknown-elf-gcc 2>/dev/null),) | ||
| 339 | TOOLCHAIN = riscv32-unknown-elf- | ||
| 340 | else | ||
| 341 | ifneq ($(shell which riscv64-unknown-elf-gcc 2>/dev/null),) | ||
| 342 | TOOLCHAIN = riscv64-unknown-elf- | ||
| 343 | else | ||
| 344 | $(error "No RISC-V toolchain found. Can't find riscv32-unknown-elf-gcc or riscv64-unknown-elf-gcc found in your systems PATH variable. Please install a valid toolchain and make it accessible!") | ||
| 345 | endif | ||
| 346 | endif | ||
| 347 | endif | ||
| 348 | |||
| 349 | # Default to compiling with picolibc for RISC-V targets if available, | ||
| 350 | # which is available by default on current (bullseye) debian based systems. | ||
| 351 | ifeq ($(shell $(TOOLCHAIN)gcc --specs=picolibc.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0) | ||
| 352 | # Toolchain specific Compiler flags | ||
| 353 | # Note that we still link with our own linker script | ||
| 354 | # by providing it via the -T flag above. | ||
| 355 | TOOLCHAIN_CFLAGS = --specs=picolibc.specs | ||
| 356 | |||
| 357 | # Tell QMK that we are compiling with picolibc. | ||
| 358 | OPT_DEFS += -DUSE_PICOLIBC | ||
| 359 | endif | ||
| 360 | |||
| 361 | # MCU architecture flags | ||
| 362 | MCUFLAGS = -march=$(MCU_ARCH) \ | ||
| 363 | -mabi=$(MCU_ABI) \ | ||
| 364 | -mcmodel=$(MCU_CMODEL) \ | ||
| 365 | -mstrict-align | ||
| 366 | else | ||
| 367 | # ARM toolchain specific configuration | ||
| 368 | TOOLCHAIN ?= arm-none-eabi- | ||
| 369 | |||
| 370 | # Toolchain specific Linker flags | ||
| 371 | TOOLCHAIN_LDFLAGS = -Wl,--no-wchar-size-warning \ | ||
| 372 | --specs=nano.specs | ||
| 373 | |||
| 374 | # MCU architecture flags | ||
| 375 | MCUFLAGS = -mcpu=$(MCU) \ | ||
| 376 | -mthumb -DTHUMB_PRESENT \ | ||
| 377 | -mno-thumb-interwork -DTHUMB_NO_INTERWORKING \ | ||
| 378 | -mno-unaligned-access | ||
| 379 | |||
| 380 | # Some ARM cores like the M4 and M7 have floating point units which can be enabled | ||
| 381 | USE_FPU ?= no | ||
| 382 | |||
| 383 | ifneq ($(USE_FPU),no) | ||
| 384 | OPT_DEFS += -DCORTEX_USE_FPU=TRUE | ||
| 385 | |||
| 386 | # Default is single precision floats | ||
| 387 | USE_FPU_OPT ?= -mfloat-abi=hard \ | ||
| 388 | -mfpu=fpv4-sp-d16 \ | ||
| 389 | -fsingle-precision-constant | ||
| 390 | |||
| 391 | MCUFLAGS += $(USE_FPU_OPT) | ||
| 392 | else | ||
| 393 | OPT_DEFS += -DCORTEX_USE_FPU=FALSE | ||
| 394 | endif | ||
| 395 | endif | ||
| 396 | |||
| 397 | # Assembler flags | ||
| 398 | ASFLAGS += $(SHARED_ASFLAGS) $(TOOLCHAIN_ASFLAGS) | ||
| 399 | |||
| 400 | # C Compiler flags | ||
| 401 | CFLAGS += $(SHARED_CFLAGS) $(TOOLCHAIN_CFLAGS) | ||
| 402 | |||
| 403 | # C++ Compiler flags | ||
| 404 | CXXFLAGS += $(CFLAGS) $(SHARED_CXXFLAGS) $(TOOLCHAIN_CXXFLAGS) -fno-rtti | ||
| 405 | |||
| 406 | # Linker flags | ||
| 407 | LDFLAGS += $(SHARED_LDFLAGS) $(TOOLCHAIN_LDFLAGS) $(MCUFLAGS) | ||
| 408 | |||
| 409 | # Tell QMK that we are hosting it on ChibiOS. | ||
| 410 | OPT_DEFS += -DPROTOCOL_CHIBIOS | ||
| 411 | |||
| 412 | # Workaround to stop ChibiOS from complaining about new GCC -- it's been fixed for 7/8/9 already | ||
| 413 | OPT_DEFS += -DPORT_IGNORE_GCC_VERSION_CHECK=1 | ||
| 414 | |||
| 415 | # Construct GCC toolchain | ||
| 416 | CC = $(CC_PREFIX) $(TOOLCHAIN)gcc | ||
| 417 | OBJCOPY = $(TOOLCHAIN)objcopy | ||
| 418 | OBJDUMP = $(TOOLCHAIN)objdump | ||
| 419 | SIZE = $(TOOLCHAIN)size | ||
| 420 | AR = $(TOOLCHAIN)ar | ||
| 421 | NM = $(TOOLCHAIN)nm | ||
| 422 | HEX = $(OBJCOPY) -O $(FORMAT) | ||
| 423 | EEP = | ||
| 424 | BIN = $(OBJCOPY) -O binary | ||
| 425 | |||
| 426 | ############################################################################## | ||
| 427 | # Make targets | ||
| 428 | # | ||
| 429 | |||
| 430 | DEBUG = gdb | ||
| 431 | |||
| 432 | # List any extra directories to look for libraries here. | ||
| 433 | EXTRALIBDIRS = $(RULESPATH)/ld | ||
| 434 | |||
| 435 | bin: $(BUILD_DIR)/$(TARGET).bin sizeafter | ||
| 436 | $(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin; | ||
