Skip to content

Commit

Permalink
cpu/cortexm: Add 'cortexm_fpu' as a DEFAULT_MODULE if possible
Browse files Browse the repository at this point in the history
This adds cortexm_fpu to the DEFAULT_MODULE list when the feature
cortexm_fpu is provided by the architecture. It also moves the
dependency resolution of this module to the architecture-specific
Makefile.dep file.
  • Loading branch information
leandrolanzieri committed Apr 1, 2020
1 parent 64552a3 commit ea2f963
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
6 changes: 6 additions & 0 deletions cpu/cortexm_common/Makefile.dep
Expand Up @@ -12,3 +12,9 @@ USEMODULE += newlib_nano

# Export the peripheral drivers to be linked into the final binary:
USEMODULE += periph

# Use Hardware FPU by default if present
FEATURES_OPTIONAL += cortexm_fpu
ifneq (,$(filter cortexm_fpu,$(FEATURES_USED)))
DEFAULT_MODULE += cortexm_fpu
endif
5 changes: 5 additions & 0 deletions cpu/cortexm_common/Makefile.features
Expand Up @@ -5,3 +5,8 @@ FEATURES_PROVIDED += periph_pm
FEATURES_PROVIDED += cpp
FEATURES_PROVIDED += cpu_check_address
FEATURES_PROVIDED += ssp

# cortex-m4f and cortex-m7 provide FPU support
ifneq (,$(filter $(CPU_ARCH),cortex-m4f cortex-m7))
FEATURES_PROVIDED += cortexm_fpu
endif
24 changes: 9 additions & 15 deletions makefiles/arch/cortexm.inc.mk
Expand Up @@ -60,24 +60,18 @@ endif # BUILD_IN_DOCKER
CFLAGS += -DCPU_MODEL_$(call uppercase_and_underscore,$(CPU_MODEL))
CFLAGS += -DCPU_ARCH_$(call uppercase_and_underscore,$(CPU_ARCH))

# set the compiler specific CPU and FPU options
ifneq (,$(filter $(CPU_ARCH),cortex-m4f cortex-m7))
ifneq (,$(filter cortexm_fpu,$(DISABLE_MODULE)))
CFLAGS_FPU ?= -mfloat-abi=soft
# Add corresponding FPU CFLAGS
# clang assumes there is an FPU, no CFLAGS necessary
ifneq (llvm, $(TOOLCHAIN))
ifeq ($(CPU_ARCH),cortex-m7)
_CORTEX_HW_FPU_CFLAGS = -mfloat-abi=hard -mfpu=fpv5-sp-d16
else
USEMODULE += cortexm_fpu
# clang assumes there is an FPU
ifneq (llvm,$(TOOLCHAIN))
ifeq ($(CPU_ARCH),cortex-m7)
CFLAGS_FPU ?= -mfloat-abi=hard -mfpu=fpv5-sp-d16
else
CFLAGS_FPU ?= -mfloat-abi=hard -mfpu=fpv4-sp-d16
endif
endif
_CORTEX_HW_FPU_CFLAGS = -mfloat-abi=hard -mfpu=fpv4-sp-d16
endif
else
CFLAGS_FPU ?= -mfloat-abi=soft
endif
# Add soft or hard FPU CFLAGS depending on the module
# NOTE: This can be turned into normal conditional syntax once #9913 is fixed
CFLAGS_FPU ?= $(if $(filter cortexm_fpu,$(USEMODULE)),$(_CORTEX_HW_FPU_CFLAGS),-mfloat-abi=soft)

ifeq ($(CPU_ARCH),cortex-m4f)
MCPU = cortex-m4
Expand Down

0 comments on commit ea2f963

Please sign in to comment.