2019-06-11 14:50:03 +02:00
|
|
|
ifeq (,$(CPU_MODEL))
|
|
|
|
$(error CPU_MODEL must have been defined by the board/cpu Makefile.features)
|
|
|
|
endif
|
|
|
|
|
2016-01-15 18:21:29 +01:00
|
|
|
# Target triple for the build. Use arm-none-eabi if you are unsure.
|
2020-09-08 22:28:41 +02:00
|
|
|
TARGET_ARCH_CORTEXM ?= arm-none-eabi
|
|
|
|
TARGET_ARCH ?= $(TARGET_ARCH_CORTEXM)
|
2016-01-15 18:21:29 +01:00
|
|
|
|
|
|
|
# define build specific options
|
2019-08-27 16:06:41 +02:00
|
|
|
CFLAGS_CPU = -mcpu=$(MCPU) -mlittle-endian -mthumb $(CFLAGS_FPU)
|
2018-05-11 23:07:25 +02:00
|
|
|
|
2016-01-15 18:21:29 +01:00
|
|
|
ifneq (llvm,$(TOOLCHAIN))
|
2019-12-30 18:52:04 +01:00
|
|
|
# Clang (observed with v3.7) does not understand -mno-thumb-interwork, only add if
|
|
|
|
# not building with LLVM
|
|
|
|
CFLAGS += -mno-thumb-interwork
|
|
|
|
|
|
|
|
# work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85606
|
2020-06-10 13:11:32 +02:00
|
|
|
ifeq (armv6m,$(CPU_ARCH))
|
2019-12-30 18:52:04 +01:00
|
|
|
CFLAGS_CPU += -march=armv6s-m
|
|
|
|
endif
|
2018-05-11 23:07:25 +02:00
|
|
|
endif
|
|
|
|
|
2022-04-03 01:54:31 +02:00
|
|
|
CFLAGS_LINK = -ffunction-sections -fdata-sections -fshort-enums
|
2019-08-27 16:06:41 +02:00
|
|
|
CFLAGS_DBG ?= -ggdb -g3
|
|
|
|
CFLAGS_OPT ?= -Os
|
2016-01-15 18:21:29 +01:00
|
|
|
|
2019-08-27 16:06:41 +02:00
|
|
|
CFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT)
|
2016-01-15 18:21:29 +01:00
|
|
|
|
2022-11-11 23:11:07 +01:00
|
|
|
ASFLAGS += $(CFLAGS_CPU)
|
2019-12-30 18:52:04 +01:00
|
|
|
LINKFLAGS += -L$(RIOTCPU)/$(CPU)/ldscripts -L$(RIOTCPU)/cortexm_common/ldscripts
|
|
|
|
LINKER_SCRIPT ?= $(CPU_MODEL).ld
|
|
|
|
LINKFLAGS += -T$(LINKER_SCRIPT) -Wl,--fatal-warnings
|
2016-09-29 22:49:32 +02:00
|
|
|
|
2019-12-30 18:52:04 +01:00
|
|
|
LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) -static -lgcc -nostartfiles
|
|
|
|
LINKFLAGS += -Wl,--gc-sections
|
2016-01-15 18:21:29 +01:00
|
|
|
|
2018-11-15 17:04:17 +01:00
|
|
|
# extract version inside the first parentheses
|
|
|
|
ARM_GCC_VERSION = $(shell $(TARGET_ARCH)-gcc --version | sed -n '1 s/[^(]*(\([^\)]*\)).*/\1/p')
|
|
|
|
|
|
|
|
# Ubuntu bionic gcc-arm-none-eabi compiler is not supported
|
|
|
|
# Both when using gnu and llvm toolchains
|
|
|
|
#
|
|
|
|
# /usr/bin/arm-none-eabi-gcc --version | head -n 1
|
|
|
|
# arm-none-eabi-gcc (15:6.3.1+svn253039-1build1) 6.3.1 20170620
|
|
|
|
#
|
|
|
|
ARM_GCC_UNSUPPORTED += 15:6.3.1% # ubuntu bionic, ignore 'svn' build part
|
|
|
|
|
|
|
|
# Should not raise an error on the host system version when building in docker
|
|
|
|
ifneq (1,$(BUILD_IN_DOCKER))
|
|
|
|
ifneq (,$(filter $(ARM_GCC_UNSUPPORTED),$(ARM_GCC_VERSION)))
|
|
|
|
$(warning $(TARGET_ARCH)-gcc version not supported)
|
|
|
|
$(warning $(shell $(TARGET_ARCH)-gcc --version | head -n 1))
|
|
|
|
$(warning The currently recommanded version is the one installed in the riotdocker image)
|
|
|
|
$(warning https://github.com/RIOT-OS/riotdocker/blob/master/Dockerfile)
|
|
|
|
ifeq (1,$(WERROR))
|
|
|
|
$(error This check can be ignored by building with 'WERROR=0')
|
|
|
|
endif # WERROR
|
|
|
|
endif # ARM_GCC_UNSUPPORTED
|
|
|
|
endif # BUILD_IN_DOCKER
|
|
|
|
|
2019-08-29 17:40:25 +02:00
|
|
|
CFLAGS += -DCPU_MODEL_$(call uppercase_and_underscore,$(CPU_MODEL))
|
2020-06-10 13:11:32 +02:00
|
|
|
CFLAGS += -DCPU_CORE_$(call uppercase_and_underscore,$(CPU_CORE))
|
2015-05-18 18:47:17 +02:00
|
|
|
|
2020-09-21 13:55:45 +02:00
|
|
|
# Add soft or hard FPU CFLAGS depending on the module
|
|
|
|
ifneq (,$(filter cortexm_fpu,$(USEMODULE)))
|
2022-05-05 21:14:53 +02:00
|
|
|
ifneq (,$(filter $(CPU_CORE),cortex-m33 cortex-m7))
|
2020-09-21 13:55:45 +02:00
|
|
|
CFLAGS_FPU ?= -mfloat-abi=hard -mfpu=fpv5-sp-d16
|
2019-12-30 18:52:04 +01:00
|
|
|
else
|
2020-09-21 13:55:45 +02:00
|
|
|
CFLAGS_FPU ?= -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
2019-12-30 18:52:04 +01:00
|
|
|
endif
|
2020-06-25 10:17:10 +02:00
|
|
|
else
|
|
|
|
CFLAGS_FPU ?= -mfloat-abi=soft
|
|
|
|
endif
|
2019-12-30 18:52:04 +01:00
|
|
|
|
2020-06-10 13:11:32 +02:00
|
|
|
ifeq ($(CPU_CORE),cortex-m4f)
|
2019-12-30 18:52:04 +01:00
|
|
|
MCPU = cortex-m4
|
2017-02-20 18:21:13 +01:00
|
|
|
else
|
2020-06-10 13:11:32 +02:00
|
|
|
MCPU ?= $(CPU_CORE)
|
2017-02-20 18:21:13 +01:00
|
|
|
endif
|
2015-04-22 12:56:28 +02:00
|
|
|
|
2015-05-30 10:02:46 +02:00
|
|
|
# CMSIS DSP needs to know about the CPU core
|
|
|
|
ifneq (,$(filter cmsis-dsp,$(USEPKG)))
|
2019-12-30 18:52:04 +01:00
|
|
|
# definition needed to use cmsis-dsp headers
|
2020-06-10 13:11:32 +02:00
|
|
|
ifeq ($(CPU_CORE),cortex-m0)
|
2019-12-30 18:52:04 +01:00
|
|
|
CFLAGS += -DARM_MATH_CM0
|
2020-06-10 13:11:32 +02:00
|
|
|
else ifeq ($(CPU_CORE),cortex-m0plus)
|
2019-12-30 18:52:04 +01:00
|
|
|
CFLAGS += -DARM_MATH_CM0PLUS
|
2020-06-22 00:23:21 +02:00
|
|
|
else ifeq ($(CPU_CORE),cortex-m23)
|
|
|
|
CFLAGS += -DARM_MATH_CM23
|
2020-06-10 13:11:32 +02:00
|
|
|
else ifeq ($(CPU_CORE),cortex-m3)
|
2019-12-30 18:52:04 +01:00
|
|
|
CFLAGS += -DARM_MATH_CM3
|
2020-06-22 00:23:21 +02:00
|
|
|
else ifeq ($(CPU_CORE),cortex-m33)
|
|
|
|
CFLAGS += -DARM_MATH_CM33
|
2020-06-10 13:11:32 +02:00
|
|
|
else ifeq ($(CPU_CORE),cortex-m4)
|
2019-12-30 18:52:04 +01:00
|
|
|
CFLAGS += -DARM_MATH_CM4
|
2020-06-10 13:11:32 +02:00
|
|
|
else ifeq ($(CPU_CORE),cortex-m4f)
|
2019-12-30 18:52:04 +01:00
|
|
|
CFLAGS += -DARM_MATH_CM4
|
2020-06-10 13:11:32 +02:00
|
|
|
else ifeq ($(CPU_CORE),cortex-m7)
|
2019-12-30 18:52:04 +01:00
|
|
|
CFLAGS += -DARM_MATH_CM7
|
|
|
|
endif
|
2015-05-30 10:02:46 +02:00
|
|
|
endif
|
|
|
|
|
2015-04-22 12:56:28 +02:00
|
|
|
# CPU depends on the cortex-m common module, so include it:
|
2015-05-18 18:47:17 +02:00
|
|
|
include $(RIOTCPU)/cortexm_common/Makefile.include
|
2015-04-22 12:56:28 +02:00
|
|
|
|
|
|
|
# Avoid overriding the default rule:
|
|
|
|
all:
|
|
|
|
|
|
|
|
# Rule to generate assembly listings from ELF files:
|
|
|
|
%.lst: %.elf
|
|
|
|
$(OBJDUMP) $(OBJDUMPFLAGS) $< > $@
|