2016-07-01 17:04:53 +03:00
# Hey Emacs, this is a -*- makefile -*-
##############################################################################
# Architecture or project specific options
#
# Stack size to be allocated to the Cortex-M process stack. This stack is
# the stack used by the main() thread.
ifeq ( $( USE_PROCESS_STACKSIZE ) ,)
2018-02-08 14:39:40 -05:00
USE_PROCESS_STACKSIZE = 0x800
2016-07-01 17:04:53 +03:00
endif
# Stack size to the allocated to the Cortex-M main/exceptions stack. This
# stack is used for processing interrupts and exceptions.
ifeq ( $( USE_EXCEPTIONS_STACKSIZE ) ,)
USE_EXCEPTIONS_STACKSIZE = 0x400
endif
#
# Architecture or project specific options
##############################################################################
##############################################################################
# Project, sources and paths
#
# Imported source files and paths
2020-03-22 09:48:17 +00:00
OPT_OS = chibios
2016-07-01 17:04:53 +03:00
CHIBIOS = $( TOP_DIR) /lib/chibios
CHIBIOS_CONTRIB = $( TOP_DIR) /lib/chibios-contrib
2021-10-18 07:23:20 +02:00
#
# Startup, Port and Platform support selection
##############################################################################
ifeq ( $( strip $( MCU )) , risc-v)
# RISC-V Support
# As of 7.4.2021 there is only one supported RISC-V platform in Chibios-Contrib,
# therefore all required settings are hard-coded
STARTUP_MK = $( CHIBIOS_CONTRIB) /os/common/startup/RISCV-ECLIC/compilers/GCC/mk/startup_$( MCU_STARTUP) .mk
PORT_V = $( CHIBIOS_CONTRIB) /os/common/ports/RISCV-ECLIC/compilers/GCC/mk/port.mk
RULESPATH = $( CHIBIOS_CONTRIB) /os/common/startup/RISCV-ECLIC/compilers/GCC
PLATFORM_MK = $( CHIBIOS_CONTRIB) /os/hal/ports/GD/GD32VF103/platform.mk
else
# ARM Support
2021-11-03 08:26:40 +11:00
CHIBIOS_PORT ?=
ifeq ( " $( CHIBIOS_PORT) " ,"" )
CHIBIOS_PORT = ARMv$( ARMV) -M
endif
2021-10-18 07:23:20 +02:00
# Startup files. Try a few different locations, for compability with old versions and
# for things hardware in the contrib repository
STARTUP_MK = $( CHIBIOS) /os/common/ports/ARMCMx/compilers/GCC/mk/startup_$( MCU_STARTUP) .mk
ifeq ( " $( wildcard $( STARTUP_MK)) " ,"" )
STARTUP_MK = $( CHIBIOS) /os/common/startup/ARMCMx/compilers/GCC/mk/startup_$( MCU_STARTUP) .mk
ifeq ( " $( wildcard $( STARTUP_MK)) " ,"" )
STARTUP_MK = $( CHIBIOS_CONTRIB) /os/common/startup/ARMCMx/compilers/GCC/mk/startup_$( MCU_STARTUP) .mk
endif
endif
2021-11-03 08:26:40 +11:00
# Port files. Try a few different locations, for compability with old versions and
# for things hardware in the contrib repository
PORT_V = $( CHIBIOS) /os/common/ports/$( CHIBIOS_PORT) /compilers/GCC/mk/port.mk
2021-10-18 07:23:20 +02:00
ifeq ( " $( wildcard $( PORT_V)) " ,"" )
2021-11-03 08:26:40 +11:00
PORT_V = $( CHIBIOS) /os/rt/ports/ARMCMx/compilers/GCC/mk/port_v$( ARMV) m.mk
ifeq ( " $( wildcard $( PORT_V)) " ,"" )
PORT_V = $( CHIBIOS) /os/common/ports/ARMCMx/compilers/GCC/mk/port_v$( ARMV) m.mk
endif
2021-10-18 07:23:20 +02:00
endif
2021-11-03 08:26:40 +11:00
# Rules location. Try a few different locations, for compability with old versions and
# for things hardware in the contrib repository
RULESPATH = $( CHIBIOS) /os/common/ports/$( CHIBIOS_PORT) /compilers/GCC
2021-10-18 07:23:20 +02:00
ifeq ( " $( wildcard $( RULESPATH) /rules.mk) " ,"" )
2021-11-03 08:26:40 +11:00
RULESPATH = $( CHIBIOS) /os/common/ports/ARMCMx/compilers/GCC
ifeq ( " $( wildcard $( RULESPATH) /rules.mk) " ,"" )
RULESPATH = $( CHIBIOS) /os/common/startup/ARMCMx/compilers/GCC
endif
2021-10-18 07:23:20 +02:00
endif
2016-07-01 17:04:53 +03:00
endif
2019-02-09 00:12:43 +08:00
ifeq ( "$(PLATFORM_NAME)" , "" )
2021-10-18 07:23:20 +02:00
PLATFORM_NAME = platform
2019-02-09 00:12:43 +08:00
endif
2016-07-01 17:04:53 +03:00
ifeq ( "$(wildcard $(PLATFORM_MK))" , "" )
2021-10-18 07:23:20 +02:00
PLATFORM_MK = $( CHIBIOS) /os/hal/ports/$( MCU_FAMILY) /$( MCU_SERIES) /$( PLATFORM_NAME) .mk
ifeq ( " $( wildcard $( PLATFORM_MK)) " ,"" )
PLATFORM_MK = $( CHIBIOS_CONTRIB) /os/hal/ports/$( MCU_FAMILY) /$( MCU_SERIES) /$( PLATFORM_NAME) .mk
endif
2016-07-01 17:04:53 +03:00
endif
2021-10-18 07:23:20 +02:00
include $( STARTUP_MK )
include $( PORT_V )
2016-07-01 17:04:53 +03:00
include $( PLATFORM_MK )
2021-10-18 07:23:20 +02:00
#
# Board support selection.
##############################################################################
2020-06-06 18:52:19 +10:00
BOARD_MK :=
ifneq ( "$(wildcard $(KEYBOARD_PATH_5)/boards/$(BOARD)/board.mk)" , "" )
BOARD_PATH = $( KEYBOARD_PATH_5)
BOARD_MK += $( KEYBOARD_PATH_5) /boards/$( BOARD) /board.mk
else ifneq ( "$(wildcard $(KEYBOARD_PATH_4)/boards/$(BOARD)/board.mk)" , "" )
BOARD_PATH = $( KEYBOARD_PATH_4)
BOARD_MK += $( KEYBOARD_PATH_4) /boards/$( BOARD) /board.mk
else ifneq ( "$(wildcard $(KEYBOARD_PATH_3)/boards/$(BOARD)/board.mk)" , "" )
BOARD_PATH = $( KEYBOARD_PATH_3)
BOARD_MK += $( KEYBOARD_PATH_3) /boards/$( BOARD) /board.mk
else ifneq ( "$(wildcard $(KEYBOARD_PATH_2)/boards/$(BOARD)/board.mk)" , "" )
BOARD_PATH = $( KEYBOARD_PATH_2)
BOARD_MK += $( KEYBOARD_PATH_2) /boards/$( BOARD) /board.mk
else ifneq ( "$(wildcard $(KEYBOARD_PATH_1)/boards/$(BOARD)/board.mk)" , "" )
BOARD_PATH = $( KEYBOARD_PATH_1)
BOARD_MK += $( KEYBOARD_PATH_1) /boards/$( BOARD) /board.mk
2021-08-18 00:04:15 +01:00
else ifneq ( "$(wildcard $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/board/board.mk)" , "" )
BOARD_PATH = $( TOP_DIR) /platforms/chibios/boards/$( BOARD)
BOARD_MK += $( TOP_DIR) /platforms/chibios/boards/$( BOARD) /board/board.mk
2020-06-06 18:52:19 +10:00
KEYBOARD_PATHS += $( BOARD_PATH) /configs
2020-12-03 13:04:28 +11:00
ifneq ( " $( wildcard $( BOARD_PATH) /rules.mk) " ,"" )
include $( BOARD_PATH) /rules.mk
endif
2020-06-06 18:52:19 +10:00
endif
ifeq ( "$(wildcard $(BOARD_MK))" , "" )
2021-10-18 07:23:20 +02:00
BOARD_MK = $( CHIBIOS) /os/hal/boards/$( BOARD) /board.mk
ifeq ( " $( wildcard $( BOARD_MK)) " ,"" )
BOARD_MK = $( CHIBIOS_CONTRIB) /os/hal/boards/$( BOARD) /board.mk
endif
2020-06-06 18:52:19 +10:00
endif
2021-10-18 07:23:20 +02:00
include $( BOARD_MK )
#
# Bootloader selection.
##############################################################################
# Set bootloader address if supplied.
2020-03-22 09:48:17 +00:00
ifdef STM32_BOOTLOADER_ADDRESS
OPT_DEFS += -DSTM32_BOOTLOADER_ADDRESS= $( STM32_BOOTLOADER_ADDRESS)
endif
2021-11-27 06:28:18 +08:00
ifdef WB32_BOOTLOADER_ADDRESS
OPT_DEFS += -DWB32_BOOTLOADER_ADDRESS= $( WB32_BOOTLOADER_ADDRESS)
endif
2020-06-06 18:52:19 +10:00
# Work out if we need to set up the include for the bootloader definitions
2020-03-22 09:48:17 +00:00
ifneq ( "$(wildcard $(KEYBOARD_PATH_5)/bootloader_defs.h)" , "" )
OPT_DEFS += -include $( KEYBOARD_PATH_5) /bootloader_defs.h
else ifneq ( "$(wildcard $(KEYBOARD_PATH_5)/boards/$(BOARD)/bootloader_defs.h)" , "" )
OPT_DEFS += -include $( KEYBOARD_PATH_5) /boards/$( BOARD) /bootloader_defs.h
else ifneq ( "$(wildcard $(KEYBOARD_PATH_4)/bootloader_defs.h)" , "" )
OPT_DEFS += -include $( KEYBOARD_PATH_4) /bootloader_defs.h
else ifneq ( "$(wildcard $(KEYBOARD_PATH_4)/boards/$(BOARD)/bootloader_defs.h)" , "" )
OPT_DEFS += -include $( KEYBOARD_PATH_4) /boards/$( BOARD) /bootloader_defs.h
else ifneq ( "$(wildcard $(KEYBOARD_PATH_3)/bootloader_defs.h)" , "" )
OPT_DEFS += -include $( KEYBOARD_PATH_3) /bootloader_defs.h
else ifneq ( "$(wildcard $(KEYBOARD_PATH_3)/boards/$(BOARD)/bootloader_defs.h)" , "" )
OPT_DEFS += -include $( KEYBOARD_PATH_3) /boards/$( BOARD) /bootloader_defs.h
else ifneq ( "$(wildcard $(KEYBOARD_PATH_2)/bootloader_defs.h)" , "" )
OPT_DEFS += -include $( KEYBOARD_PATH_2) /bootloader_defs.h
else ifneq ( "$(wildcard $(KEYBOARD_PATH_2)/boards/$(BOARD)/bootloader_defs.h)" , "" )
OPT_DEFS += -include $( KEYBOARD_PATH_2) /boards/$( BOARD) /bootloader_defs.h
else ifneq ( "$(wildcard $(KEYBOARD_PATH_1)/bootloader_defs.h)" , "" )
OPT_DEFS += -include $( KEYBOARD_PATH_1) /bootloader_defs.h
else ifneq ( "$(wildcard $(KEYBOARD_PATH_1)/boards/$(BOARD)/bootloader_defs.h)" , "" )
OPT_DEFS += -include $( KEYBOARD_PATH_1) /boards/$( BOARD) /bootloader_defs.h
2020-06-06 18:52:19 +10:00
else ifneq ( "$(wildcard $(BOARD_PATH)/configs/bootloader_defs.h)" , "" )
OPT_DEFS += -include $( BOARD_PATH) /configs/bootloader_defs.h
2020-03-22 09:48:17 +00:00
endif
2016-07-01 17:04:53 +03:00
2021-10-18 07:23:20 +02:00
#
# ChibiOS config selection.
##############################################################################
2020-06-06 18:52:19 +10:00
# Work out the config file directories
ifneq ( "$(wildcard $(KEYBOARD_PATH_5)/chconf.h)" , "" )
CHCONFDIR = $( KEYBOARD_PATH_5)
else ifneq ( "$(wildcard $(KEYBOARD_PATH_4)/chconf.h)" , "" )
CHCONFDIR = $( KEYBOARD_PATH_4)
else ifneq ( "$(wildcard $(KEYBOARD_PATH_3)/chconf.h)" , "" )
CHCONFDIR = $( KEYBOARD_PATH_3)
else ifneq ( "$(wildcard $(KEYBOARD_PATH_2)/chconf.h)" , "" )
CHCONFDIR = $( KEYBOARD_PATH_2)
else ifneq ( "$(wildcard $(KEYBOARD_PATH_1)/chconf.h)" , "" )
CHCONFDIR = $( KEYBOARD_PATH_1)
2021-08-18 00:04:15 +01:00
else ifneq ( "$(wildcard $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/configs/chconf.h)" , "" )
CHCONFDIR = $( TOP_DIR) /platforms/chibios/boards/$( BOARD) /configs
else ifneq ( "$(wildcard $(TOP_DIR)/platforms/boards/chibios/common/configs/chconf.h)" , "" )
CHCONFDIR = $( TOP_DIR) /platforms/chibios/boards/common/configs
2017-10-14 11:32:19 -10:00
endif
2021-10-18 07:23:20 +02:00
#
# HAL config selection.
##############################################################################
2020-06-06 18:52:19 +10:00
ifneq ( "$(wildcard $(KEYBOARD_PATH_5)/halconf.h)" , "" )
HALCONFDIR = $( KEYBOARD_PATH_5)
else ifneq ( "$(wildcard $(KEYBOARD_PATH_4)/halconf.h)" , "" )
HALCONFDIR = $( KEYBOARD_PATH_4)
else ifneq ( "$(wildcard $(KEYBOARD_PATH_3)/halconf.h)" , "" )
HALCONFDIR = $( KEYBOARD_PATH_3)
else ifneq ( "$(wildcard $(KEYBOARD_PATH_2)/halconf.h)" , "" )
HALCONFDIR = $( KEYBOARD_PATH_2)
else ifneq ( "$(wildcard $(KEYBOARD_PATH_1)/halconf.h)" , "" )
HALCONFDIR = $( KEYBOARD_PATH_1)
2021-08-18 00:04:15 +01:00
else ifneq ( "$(wildcard $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/configs/halconf.h)" , "" )
HALCONFDIR = $( TOP_DIR) /platforms/chibios/boards/$( BOARD) /configs
else ifneq ( "$(wildcard $(TOP_DIR)/platforms/chibios/boards/common/configs/halconf.h)" , "" )
HALCONFDIR = $( TOP_DIR) /platforms/chibios/boards/common/configs
2016-07-01 17:04:53 +03:00
endif
2017-10-14 11:32:19 -10:00
2021-10-18 07:23:20 +02:00
#
# Linker script selection.
##############################################################################
2020-06-06 18:52:19 +10:00
2017-10-14 11:32:19 -10:00
ifneq ( "$(wildcard $(KEYBOARD_PATH_5)/ld/$(MCU_LDSCRIPT).ld)" , "" )
LDSCRIPT = $( KEYBOARD_PATH_5) /ld/$( MCU_LDSCRIPT) .ld
else ifneq ( "$(wildcard $(KEYBOARD_PATH_4)/ld/$(MCU_LDSCRIPT).ld)" , "" )
LDSCRIPT = $( KEYBOARD_PATH_4) /ld/$( MCU_LDSCRIPT) .ld
else ifneq ( "$(wildcard $(KEYBOARD_PATH_3)/ld/$(MCU_LDSCRIPT).ld)" , "" )
LDSCRIPT = $( KEYBOARD_PATH_3) /ld/$( MCU_LDSCRIPT) .ld
else ifneq ( "$(wildcard $(KEYBOARD_PATH_2)/ld/$(MCU_LDSCRIPT).ld)" , "" )
LDSCRIPT = $( KEYBOARD_PATH_2) /ld/$( MCU_LDSCRIPT) .ld
else ifneq ( "$(wildcard $(KEYBOARD_PATH_1)/ld/$(MCU_LDSCRIPT).ld)" , "" )
LDSCRIPT = $( KEYBOARD_PATH_1) /ld/$( MCU_LDSCRIPT) .ld
2021-08-18 00:04:15 +01:00
else ifneq ( "$(wildcard $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/ld/$(MCU_LDSCRIPT).ld)" , "" )
LDFLAGS += -L$( TOP_DIR) /platforms/chibios/boards/$( BOARD) /ld
LDSCRIPT = $( TOP_DIR) /platforms/chibios/boards/$( BOARD) /ld/$( MCU_LDSCRIPT) .ld
else ifneq ( "$(wildcard $(TOP_DIR)/platforms/chibios/boards/common/ld/$(MCU_LDSCRIPT).ld)" , "" )
LDSCRIPT = $( TOP_DIR) /platforms/chibios/boards/common/ld/$( MCU_LDSCRIPT) .ld
2020-02-29 12:00:00 -08:00
else ifneq ( "$(wildcard $(STARTUPLD_CONTRIB)/$(MCU_LDSCRIPT).ld)" , "" )
LDSCRIPT = $( STARTUPLD_CONTRIB) /$( MCU_LDSCRIPT) .ld
2020-03-01 11:50:49 +11:00
USE_CHIBIOS_CONTRIB = yes
2016-07-01 17:04:53 +03:00
else
2017-10-14 11:32:19 -10:00
LDSCRIPT = $( STARTUPLD) /$( MCU_LDSCRIPT) .ld
2016-07-01 17:04:53 +03:00
endif
2021-10-18 07:23:20 +02:00
#
# Include ChibiOS makefiles.
##############################################################################
# HAL-OSAL files (optional).
include $( CHIBIOS ) /os/hal/hal.mk
-include $( CHIBIOS ) /os/hal/osal/rt/osal.mk # ChibiOS <= 19.x
-include $( CHIBIOS ) /os/hal/osal/rt-nil/osal.mk # ChibiOS >= 20.x
# RTOS files (optional).
include $( CHIBIOS ) /os/rt/rt.mk
# Other files (optional).
include $( CHIBIOS ) /os/hal/lib/streams/streams.mk
2021-10-20 21:04:23 +01:00
PLATFORM_SRC = \
$( STARTUPSRC) \
2021-10-18 07:23:20 +02:00
$( KERNSRC) \
$( PORTSRC) \
$( OSALSRC) \
$( HALSRC) \
$( PLATFORMSRC) \
$( BOARDSRC) \
$( STREAMSSRC) \
$( CHIBIOS) /os/various/syscalls.c \
$( PLATFORM_COMMON_DIR) /syscall-fallbacks.c \
$( PLATFORM_COMMON_DIR) /wait.c
2020-02-29 12:00:00 -08:00
# Ensure the ASM files are not subjected to LTO -- it'll strip out interrupt handlers otherwise.
2020-12-23 08:44:49 +08:00
QUANTUM_LIB_SRC += $( STARTUPASM) $( PORTASM) $( OSALASM) $( PLATFORMASM)
2016-07-01 17:04:53 +03:00
2021-10-20 21:04:23 +01:00
PLATFORM_SRC := $( patsubst $( TOP_DIR) /%,%,$( PLATFORM_SRC))
2018-01-21 10:55:40 +02:00
2020-02-29 12:00:00 -08:00
EXTRAINCDIRS += $( CHIBIOS) /os/license $( CHIBIOS) /os/oslib/include \
2021-08-18 00:04:15 +01:00
$( TOP_DIR) /platforms/chibios/boards/$( BOARD) /configs \
$( TOP_DIR) /platforms/chibios/boards/common/configs \
2020-11-28 12:02:18 -08:00
$( HALCONFDIR) $( CHCONFDIR) \
2016-07-01 17:04:53 +03:00
$( STARTUPINC) $( KERNINC) $( PORTINC) $( OSALINC) \
2020-03-01 11:50:49 +11:00
$( HALINC) $( PLATFORMINC) $( BOARDINC) $( TESTINC) \
2018-07-16 11:48:31 -04:00
$( STREAMSINC) $( CHIBIOS) /os/various $( COMMON_VPATH)
2016-07-01 17:04:53 +03:00
2020-03-01 11:50:49 +11:00
#
# ChibiOS-Contrib
##############################################################################
# Work out if we're using ChibiOS-Contrib by checking if halconf_community.h exists
ifneq ( "$(wildcard $(KEYBOARD_PATH_5)/halconf_community.h)" , "" )
USE_CHIBIOS_CONTRIB = yes
else ifneq ( "$(wildcard $(KEYBOARD_PATH_4)/halconf_community.h)" , "" )
USE_CHIBIOS_CONTRIB = yes
else ifneq ( "$(wildcard $(KEYBOARD_PATH_3)/halconf_community.h)" , "" )
USE_CHIBIOS_CONTRIB = yes
else ifneq ( "$(wildcard $(KEYBOARD_PATH_2)/halconf_community.h)" , "" )
USE_CHIBIOS_CONTRIB = yes
else ifneq ( "$(wildcard $(KEYBOARD_PATH_1)/halconf_community.h)" , "" )
USE_CHIBIOS_CONTRIB = yes
2021-08-18 00:04:15 +01:00
else ifneq ( "$(wildcard $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/configs/halconf_community.h)" , "" )
2020-06-06 18:52:19 +10:00
USE_CHIBIOS_CONTRIB = yes
2020-03-01 11:50:49 +11:00
endif
ifeq ( $( strip $( USE_CHIBIOS_CONTRIB )) ,yes)
2021-10-18 07:23:20 +02:00
include $( CHIBIOS_CONTRIB ) /os/hal/hal.mk
2021-10-20 21:04:23 +01:00
PLATFORM_SRC += $( PLATFORMSRC_CONTRIB) $( HALSRC_CONTRIB)
2021-10-18 07:23:20 +02:00
EXTRAINCDIRS += $( PLATFORMINC_CONTRIB) $( HALINC_CONTRIB) $( CHIBIOS_CONTRIB) /os/various
2020-03-01 11:50:49 +11:00
endif
2016-07-01 17:04:53 +03:00
#
# Project, sources and paths
##############################################################################
2020-06-06 18:52:19 +10:00
##############################################################################
# Injected configs
#
ifneq ( "$(wildcard $(BOARD_PATH)/configs/config.h)" , "" )
CONFIG_H += $( BOARD_PATH) /configs/config.h
endif
ifneq ( "$(wildcard $(BOARD_PATH)/configs/post_config.h)" , "" )
POST_CONFIG_H += $( BOARD_PATH) /configs/post_config.h
endif
2016-07-01 17:04:53 +03:00
##############################################################################
2021-10-18 07:23:20 +02:00
# Compiler and Linker configuration
2016-07-01 17:04:53 +03:00
#
2021-10-18 07:23:20 +02:00
# Use defined stack sizes of the main thread in linker scripts
2021-11-20 21:04:16 +01:00
SHARED_LDSYMBOLS = -Wl,--defsym= __process_stack_size__ = $( USE_PROCESS_STACKSIZE) ,--defsym= __main_stack_size__ = $( USE_EXCEPTIONS_STACKSIZE)
2016-07-01 17:04:53 +03:00
2021-10-18 07:23:20 +02:00
# Shared Compiler flags for all toolchains
SHARED_CFLAGS = -fomit-frame-pointer \
-ffunction-sections \
-fdata-sections \
-fno-common \
-fshort-wchar
2016-07-01 17:04:53 +03:00
2021-10-18 07:23:20 +02:00
# Shared Linker flags for all toolchains
SHARED_LDFLAGS = -T $( LDSCRIPT) \
-Wl,--gc-sections \
-nostartfiles
2020-05-20 16:28:39 +01:00
2021-10-18 07:23:20 +02:00
ifeq ( $( strip $( MCU )) , risc-v)
# RISC-V toolchain specific configuration
# Find suitable GCC compiler
ifeq ( $( strip $( TOOLCHAIN)) ,)
ifneq ( $( shell which riscv32-unknown-elf-gcc 2>/dev/null) ,)
TOOLCHAIN = riscv32-unknown-elf-
else
ifneq ( $( shell which riscv64-unknown-elf-gcc 2>/dev/null) ,)
TOOLCHAIN = riscv64-unknown-elf-
else
2022-02-05 12:51:23 +11:00
$( call CATASTROPHIC_ERROR,Missing toolchain,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!)
2021-10-18 07:23:20 +02:00
endif
endif
endif
2021-10-19 08:29:27 +11:00
2021-11-20 21:04:16 +01:00
# Default to compiling with picolibc for RISC-V targets if available, which
# is available by default on distributions based on Debian 11+.
2021-10-18 07:23:20 +02:00
ifeq ( $( shell $( TOOLCHAIN) gcc --specs= picolibc.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$ ?) ,0)
2021-11-20 21:04:16 +01:00
# Toolchain specific Compiler flags Note that we still link with our own
# linker script by providing it via the -T flag in SHARED_LDFLAGS.
2021-10-18 07:23:20 +02:00
TOOLCHAIN_CFLAGS = --specs= picolibc.specs
2021-10-19 08:29:27 +11:00
2021-11-20 21:04:16 +01:00
# picolibc internally uses __heap_start and __heap_end instead of the
# defacto chibios linker script standard __heap_base__ and __heap_end__
# therefore we introduce these symbols as an alias.
TOOLCHAIN_LDSYMBOLS = -Wl,--defsym= __heap_start = __heap_base__,--defsym= __heap_end = __heap_end__
2021-10-18 07:23:20 +02:00
# Tell QMK that we are compiling with picolibc.
OPT_DEFS += -DUSE_PICOLIBC
endif
2021-10-19 08:29:27 +11:00
2021-10-18 07:23:20 +02:00
# MCU architecture flags
MCUFLAGS = -march= $( MCU_ARCH) \
-mabi= $( MCU_ABI) \
-mcmodel= $( MCU_CMODEL) \
-mstrict-align
2020-05-20 16:28:39 +01:00
else
2021-10-18 07:23:20 +02:00
# ARM toolchain specific configuration
TOOLCHAIN ?= arm-none-eabi-
# Toolchain specific Linker flags
TOOLCHAIN_LDFLAGS = -Wl,--no-wchar-size-warning \
--specs= nano.specs
# MCU architecture flags
MCUFLAGS = -mcpu= $( MCU) \
-mthumb -DTHUMB_PRESENT \
-mno-thumb-interwork -DTHUMB_NO_INTERWORKING \
-mno-unaligned-access
# Some ARM cores like the M4 and M7 have floating point units which can be enabled
USE_FPU ?= no
ifneq ( $( USE_FPU) ,no)
OPT_DEFS += -DCORTEX_USE_FPU= TRUE
# Default is single precision floats
USE_FPU_OPT ?= -mfloat-abi= hard \
-mfpu= fpv4-sp-d16 \
-fsingle-precision-constant
MCUFLAGS += $( USE_FPU_OPT)
else
OPT_DEFS += -DCORTEX_USE_FPU= FALSE
endif
2020-05-20 16:28:39 +01:00
endif
2021-10-18 07:23:20 +02:00
# Assembler flags
ASFLAGS += $( SHARED_ASFLAGS) $( TOOLCHAIN_ASFLAGS)
2016-07-01 17:04:53 +03:00
2021-10-18 07:23:20 +02:00
# C Compiler flags
CFLAGS += $( SHARED_CFLAGS) $( TOOLCHAIN_CFLAGS)
2016-07-01 17:04:53 +03:00
2021-10-18 07:23:20 +02:00
# C++ Compiler flags
CXXFLAGS += $( CFLAGS) $( SHARED_CXXFLAGS) $( TOOLCHAIN_CXXFLAGS) -fno-rtti
2016-07-01 17:04:53 +03:00
2021-10-18 07:23:20 +02:00
# Linker flags
2021-11-20 21:04:16 +01:00
LDFLAGS += $( SHARED_LDFLAGS) $( SHARED_LDSYMBOLS) $( TOOLCHAIN_LDFLAGS) $( TOOLCHAIN_LDSYMBOLS) $( MCUFLAGS)
2016-07-01 17:04:53 +03:00
2021-10-18 07:23:20 +02:00
# Tell QMK that we are hosting it on ChibiOS.
2016-07-01 17:04:53 +03:00
OPT_DEFS += -DPROTOCOL_CHIBIOS
2021-10-19 08:29:27 +11:00
# Workaround to stop ChibiOS from complaining about new GCC -- it's been fixed for 7/8/9 already
OPT_DEFS += -DPORT_IGNORE_GCC_VERSION_CHECK= 1
2021-10-18 07:23:20 +02:00
# Construct GCC toolchain
CC = $( CC_PREFIX) $( TOOLCHAIN) gcc
OBJCOPY = $( TOOLCHAIN) objcopy
OBJDUMP = $( TOOLCHAIN) objdump
SIZE = $( TOOLCHAIN) size
AR = $( TOOLCHAIN) ar
NM = $( TOOLCHAIN) nm
HEX = $( OBJCOPY) -O $( FORMAT)
EEP =
BIN = $( OBJCOPY) -O binary
##############################################################################
# Make targets
#
2016-07-01 17:04:53 +03:00
DEBUG = gdb
# List any extra directories to look for libraries here.
2016-07-05 19:28:17 +03:00
EXTRALIBDIRS = $( RULESPATH) /ld
2017-08-27 12:11:59 -04:00
bin : $( BUILD_DIR ) /$( TARGET ) .bin sizeafter
2019-08-20 15:39:24 -07:00
$( COPY) $( BUILD_DIR) /$( TARGET) .bin $( TARGET) .bin;