Updated and Validated
[betaflight.git] / make / mcu / STM32F7.mk
blob8d2b22bbbc2e6524eb992f8b68849a8f04db538d
2 # F7 Make file include
5 ifeq ($(DEBUG_HARDFAULTS),F7)
6 CFLAGS += -DDEBUG_HARDFAULTS
7 endif
9 #CMSIS
10 CMSIS_DIR := $(ROOT)/lib/main/CMSIS
12 #STDPERIPH
13 STDPERIPH_DIR = $(ROOT)/lib/main/STM32F7/Drivers/STM32F7xx_HAL_Driver
14 STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/Src/*.c))
15 EXCLUDES = stm32f7xx_hal_can.c \
16 stm32f7xx_hal_cec.c \
17 stm32f7xx_hal_crc.c \
18 stm32f7xx_hal_crc_ex.c \
19 stm32f7xx_hal_cryp.c \
20 stm32f7xx_hal_cryp_ex.c \
21 stm32f7xx_hal_dcmi.c \
22 stm32f7xx_hal_dcmi_ex.c \
23 stm32f7xx_hal_dfsdm.c \
24 stm32f7xx_hal_dma2d.c \
25 stm32f7xx_hal_dsi.c \
26 stm32f7xx_hal_eth.c \
27 stm32f7xx_hal_hash.c \
28 stm32f7xx_hal_hash_ex.c \
29 stm32f7xx_hal_hcd.c \
30 stm32f7xx_hal_i2s.c \
31 stm32f7xx_hal_irda.c \
32 stm32f7xx_hal_iwdg.c \
33 stm32f7xx_hal_jpeg.c \
34 stm32f7xx_hal_lptim.c \
35 stm32f7xx_hal_ltdc.c \
36 stm32f7xx_hal_ltdc_ex.c \
37 stm32f7xx_hal_mdios.c \
38 stm32f7xx_hal_mmc.c \
39 stm32f7xx_hal_msp_template.c \
40 stm32f7xx_hal_nand.c \
41 stm32f7xx_hal_nor.c \
42 stm32f7xx_hal_qspi.c \
43 stm32f7xx_hal_rng.c \
44 stm32f7xx_hal_sai.c \
45 stm32f7xx_hal_sai_ex.c \
46 stm32f7xx_hal_sd.c \
47 stm32f7xx_hal_sdram.c \
48 stm32f7xx_hal_smartcard.c \
49 stm32f7xx_hal_smartcard_ex.c \
50 stm32f7xx_hal_smbus.c \
51 stm32f7xx_hal_spdifrx.c \
52 stm32f7xx_hal_sram.c \
53 stm32f7xx_hal_timebase_rtc_alarm_template.c \
54 stm32f7xx_hal_timebase_rtc_wakeup_template.c \
55 stm32f7xx_hal_timebase_tim_template.c \
56 stm32f7xx_hal_wwdg.c \
57 stm32f7xx_ll_adc.c \
58 stm32f7xx_ll_crc.c \
59 stm32f7xx_ll_dac.c \
60 stm32f7xx_ll_exti.c \
61 stm32f7xx_ll_fmc.c \
62 stm32f7xx_ll_i2c.c \
63 stm32f7xx_ll_lptim.c \
64 stm32f7xx_ll_pwr.c \
65 stm32f7xx_ll_rng.c \
66 stm32f7xx_ll_rtc.c \
67 stm32f7xx_ll_sdmmc.c \
68 stm32f7xx_ll_usart.c
70 STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC))
72 #USB
73 USBCORE_DIR = $(ROOT)/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Core
74 USBCORE_SRC = $(notdir $(wildcard $(USBCORE_DIR)/Src/*.c))
75 EXCLUDES = usbd_conf_template.c
76 USBCORE_SRC := $(filter-out ${EXCLUDES}, $(USBCORE_SRC))
78 USBCDC_DIR = $(ROOT)/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/CDC
79 USBCDC_SRC = $(notdir $(wildcard $(USBCDC_DIR)/Src/*.c))
80 EXCLUDES = usbd_cdc_if_template.c
81 USBCDC_SRC := $(filter-out ${EXCLUDES}, $(USBCDC_SRC))
83 USBHID_DIR = $(ROOT)/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/HID
84 USBHID_SRC = $(notdir $(wildcard $(USBHID_DIR)/Src/*.c))
86 USBMSC_DIR = $(ROOT)/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC
87 USBMSC_SRC = $(notdir $(wildcard $(USBMSC_DIR)/Src/*.c))
88 EXCLUDES = usbd_msc_storage_template.c
89 USBMSC_SRC := $(filter-out ${EXCLUDES}, $(USBMSC_SRC))
91 VPATH := $(VPATH):$(USBCDC_DIR)/Src:$(USBCORE_DIR)/Src:$(USBHID_DIR)/Src:$(USBMSC_DIR)/Src
93 DEVICE_STDPERIPH_SRC := $(STDPERIPH_SRC) \
94 $(USBCORE_SRC) \
95 $(USBCDC_SRC) \
96 $(USBHID_SRC) \
97 $(USBMSC_SRC)
99 #CMSIS
100 VPATH := $(VPATH):$(CMSIS_DIR)/Include:$(CMSIS_DIR)/Device/ST/STM32F7xx
101 VPATH := $(VPATH):$(STDPERIPH_DIR)/Src
102 CMSIS_SRC :=
103 INCLUDE_DIRS := $(INCLUDE_DIRS) \
104 $(STDPERIPH_DIR)/Inc \
105 $(USBCORE_DIR)/Inc \
106 $(USBCDC_DIR)/Inc \
107 $(USBHID_DIR)/Inc \
108 $(USBMSC_DIR)/Inc \
109 $(CMSIS_DIR)/Core/Include \
110 $(ROOT)/lib/main/STM32F7/Drivers/CMSIS/Device/ST/STM32F7xx/Include \
111 $(ROOT)/src/main/vcp_hal
113 ifneq ($(filter SDCARD_SPI,$(FEATURES)),)
114 INCLUDE_DIRS := $(INCLUDE_DIRS) \
115 $(FATFS_DIR)
116 VPATH := $(VPATH):$(FATFS_DIR)
117 endif
119 ifneq ($(filter SDCARD_SDIO,$(FEATURES)),)
120 INCLUDE_DIRS := $(INCLUDE_DIRS) \
121 $(FATFS_DIR)
122 VPATH := $(VPATH):$(FATFS_DIR)
123 endif
125 #Flags
126 ARCH_FLAGS = -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -fsingle-precision-constant -Wdouble-promotion
128 # Flags that are used in the STM32 libraries
129 DEVICE_FLAGS = -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER
131 ifeq ($(TARGET),$(filter $(TARGET),$(F7X5XI_TARGETS)))
132 DEVICE_FLAGS += -DSTM32F765xx
133 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f765.ld
134 STARTUP_SRC = startup_stm32f765xx.s
135 MCU_FLASH_SIZE := 2048
136 else ifeq ($(TARGET),$(filter $(TARGET),$(F7X5XG_TARGETS)))
137 DEVICE_FLAGS += -DSTM32F745xx
138 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f74x.ld
139 STARTUP_SRC = startup_stm32f745xx.s
140 MCU_FLASH_SIZE := 1024
141 else ifeq ($(TARGET),$(filter $(TARGET),$(F7X6XG_TARGETS)))
142 DEVICE_FLAGS += -DSTM32F746xx
143 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f74x.ld
144 STARTUP_SRC = startup_stm32f746xx.s
145 MCU_FLASH_SIZE := 1024
146 else ifeq ($(TARGET),$(filter $(TARGET),$(F7X2RE_TARGETS)))
147 DEVICE_FLAGS += -DSTM32F722xx
148 ifndef LD_SCRIPT
149 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f722.ld
150 endif
151 STARTUP_SRC = startup_stm32f722xx.s
152 MCU_FLASH_SIZE := 512
153 # Override the OPTIMISE_SPEED compiler setting to save flash space on these 512KB targets.
154 # Performance is only slightly affected but around 50 kB of flash are saved.
155 OPTIMISE_SPEED = -O2
156 else
157 $(error Unknown MCU for F7 target)
158 endif
159 DEVICE_FLAGS += -DHSE_VALUE=$(HSE_VALUE)
161 TARGET_FLAGS = -D$(TARGET)
163 VCP_SRC = \
164 vcp_hal/usbd_desc.c \
165 vcp_hal/usbd_conf_stm32f7xx.c \
166 vcp_hal/usbd_cdc_hid.c \
167 vcp_hal/usbd_cdc_interface.c \
168 drivers/serial_usb_vcp.c \
169 drivers/usb_io.c
171 MCU_COMMON_SRC = \
172 startup/system_stm32f7xx.c \
173 drivers/accgyro/accgyro_mpu.c \
174 drivers/adc_stm32f7xx.c \
175 drivers/audio_stm32f7xx.c \
176 drivers/bus_i2c_hal.c \
177 drivers/bus_i2c_hal_init.c \
178 drivers/bus_i2c_timing.c \
179 drivers/dma_stm32f7xx.c \
180 drivers/light_ws2811strip_hal.c \
181 drivers/transponder_ir_io_hal.c \
182 drivers/bus_spi_ll.c \
183 drivers/persistent.c \
184 drivers/dshot_bitbang.c \
185 drivers/dshot_bitbang_decode.c \
186 drivers/dshot_bitbang_ll.c \
187 drivers/pwm_output_dshot_hal.c \
188 drivers/pwm_output_dshot_shared.c \
189 drivers/timer_hal.c \
190 drivers/timer_stm32f7xx.c \
191 drivers/system_stm32f7xx.c \
192 drivers/serial_uart_hal.c \
193 drivers/serial_uart_stm32f7xx.c
195 MCU_EXCLUDES = \
196 drivers/bus_i2c.c \
197 drivers/timer.c
199 MSC_SRC = \
200 drivers/usb_msc_common.c \
201 drivers/usb_msc_f7xx.c \
202 msc/usbd_storage.c
204 ifneq ($(filter SDCARD_SDIO,$(FEATURES)),)
205 MCU_COMMON_SRC += \
206 drivers/sdio_f7xx.c
207 MSC_SRC += \
208 msc/usbd_storage_sdio.c
209 endif
211 ifneq ($(filter SDCARD_SPI,$(FEATURES)),)
212 MSC_SRC += \
213 msc/usbd_storage_sd_spi.c
214 endif
216 ifneq ($(filter ONBOARDFLASH,$(FEATURES)),)
217 MSC_SRC += \
218 msc/usbd_storage_emfat.c \
219 msc/emfat.c \
220 msc/emfat_file.c
221 endif
223 DSP_LIB := $(ROOT)/lib/main/CMSIS/DSP
224 DEVICE_FLAGS += -DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -D__FPU_PRESENT=1 -DUNALIGNED_SUPPORT_DISABLE -DARM_MATH_CM7