Fix gcc required subversion
[betaflight.git] / make / mcu / STM32F4.mk
blob65c81c45ba21584aa96228af4a90d0f4bb4b1dde
2 # F4 Make file include
5 #CMSIS
6 ifeq ($(PERIPH_DRIVER), HAL)
7 CMSIS_DIR := $(ROOT)/lib/main/STM32F4/Drivers/CMSIS
8 STDPERIPH_DIR = $(ROOT)/lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver
9 STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/Src/*.c))
10 EXCLUDES =
11 else
12 CMSIS_DIR := $(ROOT)/lib/main/CMSIS
13 STDPERIPH_DIR = $(ROOT)/lib/main/STM32F4/Drivers/STM32F4xx_StdPeriph_Driver
14 STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/src/*.c))
15 EXCLUDES = stm32f4xx_crc.c \
16 stm32f4xx_can.c \
17 stm32f4xx_fmc.c \
18 stm32f4xx_sai.c \
19 stm32f4xx_cec.c \
20 stm32f4xx_dsi.c \
21 stm32f4xx_flash_ramfunc.c \
22 stm32f4xx_fmpi2c.c \
23 stm32f4xx_lptim.c \
24 stm32f4xx_qspi.c \
25 stm32f4xx_spdifrx.c \
26 stm32f4xx_cryp.c \
27 stm32f4xx_cryp_aes.c \
28 stm32f4xx_hash_md5.c \
29 stm32f4xx_cryp_des.c \
30 stm32f4xx_hash.c \
31 stm32f4xx_dbgmcu.c \
32 stm32f4xx_cryp_tdes.c \
33 stm32f4xx_hash_sha1.c
34 endif
36 ifeq ($(TARGET),$(filter $(TARGET), $(F411_TARGETS)))
37 EXCLUDES += stm32f4xx_fsmc.c
38 MCU_FLASH_SIZE := 512
39 else ifeq ($(TARGET),$(filter $(TARGET), $(F446_TARGETS)))
40 EXCLUDES += stm32f4xx_fsmc.c
41 MCU_FLASH_SIZE := 512
42 else
43 MCU_FLASH_SIZE := 1024
44 endif
46 STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC))
48 ifeq ($(PERIPH_DRIVER), HAL)
49 #USB
50 USBCORE_DIR = $(ROOT)/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Core
51 USBCORE_SRC = $(notdir $(wildcard $(USBCORE_DIR)/Src/*.c))
52 EXCLUDES = usbd_conf_template.c
53 USBCORE_SRC := $(filter-out ${EXCLUDES}, $(USBCORE_SRC))
55 USBCDC_DIR = $(ROOT)/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Class/CDC
56 USBCDC_SRC = $(notdir $(wildcard $(USBCDC_DIR)/Src/*.c))
57 EXCLUDES = usbd_cdc_if_template.c
58 USBCDC_SRC := $(filter-out ${EXCLUDES}, $(USBCDC_SRC))
60 VPATH := $(VPATH):$(USBCDC_DIR)/Src:$(USBCORE_DIR)/Src
62 DEVICE_STDPERIPH_SRC := $(STDPERIPH_SRC) \
63 $(USBCORE_SRC) \
64 $(USBCDC_SRC)
65 else
66 USBCORE_DIR = $(ROOT)/lib/main/STM32_USB_Device_Library/Core
67 USBCORE_SRC = $(notdir $(wildcard $(USBCORE_DIR)/src/*.c))
68 USBOTG_DIR = $(ROOT)/lib/main/STM32_USB_OTG_Driver
69 USBOTG_SRC = $(notdir $(wildcard $(USBOTG_DIR)/src/*.c))
70 EXCLUDES = usb_bsp_template.c \
71 usb_conf_template.c \
72 usb_hcd_int.c \
73 usb_hcd.c \
74 usb_otg.c
76 USBOTG_SRC := $(filter-out ${EXCLUDES}, $(USBOTG_SRC))
77 USBCDC_DIR = $(ROOT)/lib/main/STM32_USB_Device_Library/Class/cdc
78 USBCDC_SRC = $(notdir $(wildcard $(USBCDC_DIR)/src/*.c))
79 EXCLUDES = usbd_cdc_if_template.c
80 USBCDC_SRC := $(filter-out ${EXCLUDES}, $(USBCDC_SRC))
81 USBMSC_DIR = $(ROOT)/lib/main/STM32_USB_Device_Library/Class/msc
82 USBMSC_SRC = $(notdir $(wildcard $(USBMSC_DIR)/src/*.c))
83 EXCLUDES = usbd_storage_template.c
84 USBMSC_SRC := $(filter-out ${EXCLUDES}, $(USBMSC_SRC))
85 USBHID_DIR = $(ROOT)/lib/main/STM32_USB_Device_Library/Class/hid
86 USBHID_SRC = $(notdir $(wildcard $(USBHID_DIR)/src/*.c))
87 USBWRAPPER_DIR = $(ROOT)/lib/main/STM32_USB_Device_Library/Class/hid_cdc_wrapper
88 USBWRAPPER_SRC = $(notdir $(wildcard $(USBWRAPPER_DIR)/src/*.c))
89 VPATH := $(VPATH):$(USBOTG_DIR)/src:$(USBCORE_DIR)/src:$(USBCDC_DIR)/src:$(USBMSC_DIR)/src:$(USBHID_DIR)/src:$(USBWRAPPER_DIR)/src
91 DEVICE_STDPERIPH_SRC := $(STDPERIPH_SRC) \
92 $(USBOTG_SRC) \
93 $(USBCORE_SRC) \
94 $(USBCDC_SRC) \
95 $(USBHID_SRC) \
96 $(USBWRAPPER_SRC) \
97 $(USBMSC_SRC)
98 endif
100 #CMSIS
101 VPATH := $(VPATH):$(CMSIS_DIR)/Core/Include:$(ROOT)/lib/main/STM32F4/Drivers/CMSIS/Device/ST/STM32F4xx
103 ifeq ($(PERIPH_DRIVER), HAL)
104 CMSIS_SRC :=
105 INCLUDE_DIRS := $(INCLUDE_DIRS) \
106 $(STDPERIPH_DIR)/Inc \
107 $(USBCORE_DIR)/Inc \
108 $(USBCDC_DIR)/Inc \
109 $(CMSIS_DIR)/Include \
110 $(CMSIS_DIR)/Device/ST/STM32F4xx/Include \
111 $(ROOT)/src/main/vcp_hal
112 else
113 CMSIS_SRC := $(notdir $(wildcard $(CMSIS_DIR)/CoreSupport/*.c \
114 $(ROOT)/lib/main/STM32F4/Drivers/CMSIS/Device/ST/STM32F4xx/*.c))
115 INCLUDE_DIRS := $(INCLUDE_DIRS) \
116 $(STDPERIPH_DIR)/inc \
117 $(USBOTG_DIR)/inc \
118 $(USBCORE_DIR)/inc \
119 $(USBCDC_DIR)/inc \
120 $(USBHID_DIR)/inc \
121 $(USBWRAPPER_DIR)/inc \
122 $(USBMSC_DIR)/inc \
123 $(CMSIS_DIR)/Core/Include \
124 $(ROOT)/lib/main/STM32F4/Drivers/CMSIS/Device/ST/STM32F4xx \
125 $(ROOT)/src/main/vcpf4
126 endif
128 ifneq ($(filter SDCARD_SPI,$(FEATURES)),)
129 INCLUDE_DIRS := $(INCLUDE_DIRS) \
130 $(FATFS_DIR)
131 VPATH := $(VPATH):$(FATFS_DIR)
132 endif
134 ifneq ($(filter SDCARD_SDIO,$(FEATURES)),)
135 INCLUDE_DIRS := $(INCLUDE_DIRS) \
136 $(FATFS_DIR)
137 VPATH := $(VPATH):$(FATFS_DIR)
138 endif
140 #Flags
141 ARCH_FLAGS = -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant
143 ifeq ($(TARGET),$(filter $(TARGET),$(F411_TARGETS)))
144 DEVICE_FLAGS = -DSTM32F411xE -finline-limit=20
145 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f411.ld
146 STARTUP_SRC = startup_stm32f411xe.s
147 else ifeq ($(TARGET),$(filter $(TARGET),$(F405_TARGETS)))
148 DEVICE_FLAGS = -DSTM32F40_41xxx -DSTM32F405xx
149 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f405.ld
150 STARTUP_SRC = startup_stm32f40xx.s
151 else ifeq ($(TARGET),$(filter $(TARGET),$(F446_TARGETS)))
152 DEVICE_FLAGS = -DSTM32F446xx
153 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f446.ld
154 STARTUP_SRC = startup_stm32f446xx.s
155 else
156 $(error Unknown MCU for F4 target)
157 endif
158 DEVICE_FLAGS += -DHSE_VALUE=$(HSE_VALUE)
160 MCU_COMMON_SRC = \
161 startup/system_stm32f4xx.c \
162 drivers/accgyro/accgyro_mpu.c \
163 drivers/adc_stm32f4xx.c \
164 drivers/bus_i2c_stm32f4xx.c \
165 drivers/bus_spi_stdperiph.c \
166 drivers/dma_stm32f4xx.c \
167 drivers/dshot_bitbang.c \
168 drivers/dshot_bitbang_decode.c \
169 drivers/dshot_bitbang_stdperiph.c \
170 drivers/inverter.c \
171 drivers/light_ws2811strip_stdperiph.c \
172 drivers/transponder_ir_io_stdperiph.c \
173 drivers/pwm_output_dshot.c \
174 drivers/pwm_output_dshot_shared.c \
175 drivers/serial_uart_stdperiph.c \
176 drivers/serial_uart_stm32f4xx.c \
177 drivers/system_stm32f4xx.c \
178 drivers/timer_stm32f4xx.c \
179 drivers/persistent.c
181 ifeq ($(PERIPH_DRIVER), HAL)
182 VCP_SRC = \
183 vcp_hal/usbd_desc.c \
184 vcp_hal/usbd_conf.c \
185 vcp_hal/usbd_cdc_interface.c \
186 drivers/serial_usb_vcp.c \
187 drivers/usb_io.c
188 else
189 VCP_SRC = \
190 vcpf4/stm32f4xx_it.c \
191 vcpf4/usb_bsp.c \
192 vcpf4/usbd_desc.c \
193 vcpf4/usbd_usr.c \
194 vcpf4/usbd_cdc_vcp.c \
195 drivers/serial_usb_vcp.c \
196 drivers/usb_io.c
197 endif
199 MSC_SRC = \
200 drivers/usb_msc_common.c \
201 drivers/usb_msc_f4xx.c \
202 msc/usbd_msc_desc.c \
203 msc/usbd_storage.c
205 ifneq ($(filter SDCARD_SPI,$(FEATURES)),)
206 MSC_SRC += \
207 msc/usbd_storage_sd_spi.c
208 endif
210 ifneq ($(filter SDCARD_SDIO,$(FEATURES)),)
211 MSC_SRC += \
212 msc/usbd_storage_sdio.c
213 MCU_COMMON_SRC += \
214 drivers/sdio_f4xx.c
215 endif
217 ifneq ($(filter ONBOARDFLASH,$(FEATURES)),)
218 MSC_SRC += \
219 msc/usbd_storage_emfat.c \
220 msc/emfat.c \
221 msc/emfat_file.c
222 endif
224 DSP_LIB := $(ROOT)/lib/main/CMSIS/DSP
225 DEVICE_FLAGS += -DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -D__FPU_PRESENT=1 -DUNALIGNED_SUPPORT_DISABLE -DARM_MATH_CM4