diff --git a/cpu/stm32/Makefile.include b/cpu/stm32/Makefile.include index 78c6704ef9..b1532d538e 100644 --- a/cpu/stm32/Makefile.include +++ b/cpu/stm32/Makefile.include @@ -43,24 +43,45 @@ ifneq (,$(CCMRAM_LEN)) LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_ccmram_length=$(CCMRAM_LEN) endif -ifneq (,$(filter STM32F030x4,$(CPU_LINE))) - VECTORS_O ?= $(BINDIR)/stm32_vectors/$(CPU_LINE).o -else - VECTORS_O ?= $(BINDIR)/stm32_vectors/gen_$(CPU_LINE).o - VECTORS_FILE = $(RIOTCPU)/stm32/vectors/gen_$(CPU_LINE).c - BUILDDEPS += $(VECTORS_FILE) +VECTORS_O ?= $(BINDIR)/stm32_vectors/$(CPU_LINE).o +VECTORS_FILE = $(RIOTCPU)/stm32/vectors/$(CPU_LINE).c +BUILDDEPS += $(VECTORS_FILE) - # Add this define to skip the inclusion of the system_stm32xxxx.h header files - # which are only used for STM32 system includes and not of interest for RIOT. - CFLAGS += -D__SYSTEM_STM32$(call uppercase,$(CPU_FAM))XX_H +# CPU_LINE must be exported only when building the vectors object file since +# the source filename to be built is built from the CPU_LINE content. +$(call target-export-variables,$(VECTORS_O),CPU_LINE) - STM32CMSIS_INCLUDE_DIR = $(RIOTBASE)/cpu/stm32/include/vendor/cmsis/$(CPU_FAM)/Include +# Add this define to skip the inclusion of the system_stm32xxxx.h header files +# which are only used for STM32 system includes and not of interest for RIOT. +CFLAGS += -D__SYSTEM_STM32$(call uppercase,$(CPU_FAM))XX_H - INCLUDES += -I$(STM32CMSIS_INCLUDE_DIR) +STM32CMSIS_INCLUDE_DIR = $(RIOTCPU)/stm32/include/vendor/cmsis/$(CPU_FAM)/Include +STM32FAM_INCLUDE_FILE = $(STM32CMSIS_INCLUDE_DIR)/stm32$(CPU_FAM)xx.h +INCLUDES += -I$(STM32CMSIS_INCLUDE_DIR) -$(VECTORS_FILE): - $(Q)make -C $(RIOTPKG)/stm32cmsis - $(Q)$(RIOTTOOLS)/stm32_gen_vectors/stm32_gen_vectors.py $(CPU_LINE) +# Fetch all CMSIS headers using the package mechanism. This rule is called all +# the time to ensure it's correctly updated when versions in the packages are +# updated. +$(STM32FAM_INCLUDE_FILE): FORCE + $(Q)make -C $(RIOTCPU)/stm32/include/vendor + +# The vectors source file requires the family headers to be fetched before since +# it's generated from the CMSIS content +$(VECTORS_FILE): $(STM32FAM_INCLUDE_FILE) + $(Q)$(RIOTBASE)/cpu/stm32/dist/irqs/gen_vectors.py $(CPU_LINE) + +ifneq (STM32F030x4,$(CPU_LINE)) + # IRQs of STM32F030x4 family are not available in the CMSIS package so they + # are hardcoded in RIOTs codebase. + # For other lines, the IRQs are automatically generated once from the whole + # list of CMSIS headers available in a given family + STM32IRQS_INCLUDE_FILE = $(RIOTCPU)/stm32/include/irqs/$(CPU_FAM)/irqs.h + BUILDDEPS += $(STM32IRQS_INCLUDE_FILE) + +# The IRQ header for a given family requires the family headers to be fetched +# before since it's generated from all CMSIS content of that family +$(STM32IRQS_INCLUDE_FILE): $(STM32FAM_INCLUDE_FILE) + $(Q)$(RIOTBASE)/cpu/stm32/dist/irqs/gen_irqs.py $(CPU_FAM) endif include $(RIOTMAKE)/arch/cortexm.inc.mk diff --git a/cpu/stm32/vectors/Makefile b/cpu/stm32/vectors/Makefile index 8fc28efa43..8e8d88660f 100644 --- a/cpu/stm32/vectors/Makefile +++ b/cpu/stm32/vectors/Makefile @@ -2,13 +2,9 @@ MODULE = stm32_vectors NO_AUTO_SRC = 1 -ifneq (,$(filter STM32F030x4,$(CPU_LINE))) - SRC_FILE = $(CPU_LINE).c -else - SRC_FILE = gen_$(CPU_LINE).c -endif +SRC_FILE = $(CPU_LINE).c +SRCS = $(SRC_FILE) -SRCS += $(SRC_FILE) # (file triggers compiler bug. see #5775) SRC_NOLTO += $(SRC_FILE)