Refactor debugType (#13866)
[betaflight.git] / mk / mcu / STM32H5.mk
blobb2ca3d1c9281bfdfb01f41f8f16b3690a770a136
2 # H5 Make file include
5 ifeq ($(DEBUG_HARDFAULTS),H5)
6 CFLAGS += -DDEBUG_HARDFAULTS
7 endif
9 #CMSIS
10 CMSIS_DIR := $(ROOT)/lib/main/CMSIS
12 #STDPERIPH
13 STDPERIPH_DIR = $(ROOT)/lib/main/STM32H5/Drivers/STM32H5xx_HAL_Driver
14 STDPERIPH_SRC = \
15 stm32h5xx_hal_adc.c \
16 stm32h5xx_hal_adc_ex.c \
17 stm32h5xx_hal.c \
18 stm32h5xx_hal_cordic.c \
19 stm32h5xx_hal_cortex.c \
20 stm32h5xx_hal_dac.c \
21 stm32h5xx_hal_dac_ex.c \
22 stm32h5xx_hal_dcache.c \
23 stm32h5xx_hal_dma.c \
24 stm32h5xx_hal_dma_ex.c \
25 stm32h5xx_hal_dts.c \
26 stm32h5xx_hal_exti.c \
27 stm32h5xx_hal_flash.c \
28 stm32h5xx_hal_flash_ex.c \
29 stm32h5xx_hal_fmac.c \
30 stm32h5xx_hal_gpio.c \
31 stm32h5xx_hal_gtzc.c \
32 stm32h5xx_hal_i2c.c \
33 stm32h5xx_hal_i2c_ex.c \
34 stm32h5xx_hal_i3c.c \
35 stm32h5xx_hal_icache.c \
36 stm32h5xx_hal_otfdec.c \
37 stm32h5xx_hal_pcd.c \
38 stm32h5xx_hal_pcd_ex.c \
39 stm32h5xx_hal_pka.c \
40 stm32h5xx_hal_pssi.c \
41 stm32h5xx_hal_pwr.c \
42 stm32h5xx_hal_pwr_ex.c \
43 stm32h5xx_hal_ramcfg.c \
44 stm32h5xx_hal_rcc.c \
45 stm32h5xx_hal_rcc_ex.c \
46 stm32h5xx_hal_rng_ex.c \
47 stm32h5xx_hal_rtc_ex.c \
48 stm32h5xx_hal_sd.c \
49 stm32h5xx_hal_smbus_ex.c \
50 stm32h5xx_hal_spi_ex.c \
51 stm32h5xx_hal_tim.c \
52 stm32h5xx_hal_tim_ex.c \
53 stm32h5xx_hal_uart.c \
54 stm32h5xx_hal_uart_ex.c \
55 stm32h5xx_hal_xspi.c \
56 stm32h5xx_ll_cordic.c \
57 stm32h5xx_ll_crs.c \
58 stm32h5xx_ll_dlyb.c \
59 stm32h5xx_ll_dma.c \
60 stm32h5xx_ll_fmac.c \
61 stm32h5xx_ll_i3c.c \
62 stm32h5xx_ll_icache.c \
63 stm32h5xx_ll_pka.c \
64 stm32h5xx_ll_sdmmc.c \
65 stm32h5xx_ll_spi.c \
66 stm32h5xx_ll_tim.c \
67 stm32h5xx_ll_ucpd.c \
68 stm32h5xx_ll_usb.c \
69 stm32h5xx_util_i3c.c
71 #USB ##TODO - need to work through the USB drivers, new directory: USBX
72 #USBCORE_DIR = $(ROOT)/lib/main/STM32H5/Middlewares/ST/usbx/Common
73 #USBCORE_SRC = $(notdir $(wildcard $(USBCORE_DIR)/Src/*.c))
74 #EXCLUDES =
75 #USBCORE_SRC := $(filter-out ${EXCLUDES}, $(USBCORE_SRC))
77 #VPATH := $(VPATH):$(USBCDC_DIR)/Src:$(USBCORE_DIR)/Src:$(USBHID_DIR)/Src:$(USBMSC_DIR)/Src:$(STDPERIPH_DIR)/src
79 DEVICE_STDPERIPH_SRC := $(STDPERIPH_SRC) \
80 $(USBCORE_SRC) \
81 $(USBCDC_SRC) \
82 $(USBHID_SRC) \
83 $(USBMSC_SRC)
85 #CMSIS
86 VPATH := $(VPATH):$(CMSIS_DIR)/Include:$(CMSIS_DIR)/Device/ST/STM32H5xx
87 VPATH := $(VPATH):$(STDPERIPH_DIR)/Src
88 CMSIS_SRC :=
89 INCLUDE_DIRS := $(INCLUDE_DIRS) \
90 $(SRC_DIR)/startup/stm32 \
91 $(STDPERIPH_DIR)/Inc \
92 $(USBCORE_DIR)/Inc \
93 $(USBCDC_DIR)/Inc \
94 $(USBHID_DIR)/Inc \
95 $(USBMSC_DIR)/Inc \
96 $(CMSIS_DIR)/Core/Include \
97 $(ROOT)/lib/main/STM32H5/Drivers/CMSIS/Device/ST/STM32H5xx/Include \
98 $(SRC_DIR)/drivers/mcu/stm32 \
99 $(SRC_DIR)/drivers/mcu/stm32/vcp_hal
101 #Flags
102 ARCH_FLAGS = -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -fsingle-precision-constant
104 # Flags that are used in the STM32 libraries
105 DEVICE_FLAGS = -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER
108 # H563xx : 2M FLASH, 640KB SRAM
110 ifeq ($(TARGET_MCU),STM32H563xx)
111 DEVICE_FLAGS += -DSTM32H563xx
112 DEFAULT_LD_SCRIPT = $(LINKER_DIR)/stm32_flash_h563_2m.ld
113 STARTUP_SRC = stm32/startup_stm32h563xx.s
114 MCU_FLASH_SIZE := 2048
115 DEVICE_FLAGS += -DMAX_MPU_REGIONS=16
117 # end H563xx
120 ifneq ($(DEBUG),GDB)
121 OPTIMISE_DEFAULT := -Os
122 OPTIMISE_SPEED := -Os
123 OPTIMISE_SIZE := -Os
125 LTO_FLAGS := $(OPTIMISATION_BASE) $(OPTIMISE_DEFAULT)
126 endif
128 else
129 $(error Unknown MCU for STM32H5 target)
130 endif
132 ifeq ($(LD_SCRIPT),)
133 LD_SCRIPT = $(DEFAULT_LD_SCRIPT)
134 endif
136 ifneq ($(FIRMWARE_SIZE),)
137 DEVICE_FLAGS += -DFIRMWARE_SIZE=$(FIRMWARE_SIZE)
138 endif
140 DEVICE_FLAGS += -DHSE_VALUE=$(HSE_VALUE) -DHSE_STARTUP_TIMEOUT=1000 -DSTM32
142 VCP_SRC =
143 #VCP_SRC = \
144 drivers/mcu/stm32/vcp_hal/usbd_desc.c \
145 drivers/mcu/stm32/vcp_hal/usbd_conf_stm32h5xx.c \
146 drivers/mcu/stm32/vcp_hal/usbd_cdc_hid.c \
147 drivers/mcu/stm32/vcp_hal/usbd_cdc_interface.c \
148 drivers/mcu/stm32/serial_usb_vcp.c \
149 drivers/usb_io.c
151 MCU_COMMON_SRC = \
152 drivers/bus_i2c_timing.c \
153 drivers/bus_quadspi.c \
154 drivers/dshot_bitbang_decode.c \
155 drivers/pwm_output_dshot_shared.c \
156 drivers/mcu/stm32/bus_i2c_hal_init.c \
157 drivers/mcu/stm32/bus_i2c_hal.c \
158 drivers/mcu/stm32/bus_spi_ll.c \
159 drivers/mcu/stm32/bus_quadspi_hal.c \
160 drivers/mcu/stm32/debug.c \
161 drivers/mcu/stm32/dma_reqmap_mcu.c \
162 drivers/mcu/stm32/dshot_bitbang_ll.c \
163 drivers/mcu/stm32/dshot_bitbang.c \
164 drivers/mcu/stm32/exti.c \
165 drivers/mcu/stm32/io_stm32.c \
166 drivers/mcu/stm32/light_ws2811strip_hal.c \
167 drivers/mcu/stm32/persistent.c \
168 drivers/mcu/stm32/pwm_output.c \
169 drivers/mcu/stm32/pwm_output_dshot_hal.c \
170 drivers/mcu/stm32/rcc_stm32.c \
171 drivers/mcu/stm32/serial_uart_hal.c \
172 drivers/mcu/stm32/timer_hal.c \
173 drivers/mcu/stm32/transponder_ir_io_hal.c \
174 drivers/mcu/stm32/camera_control.c \
175 drivers/mcu/stm32/system_stm32h5xx.c \
176 startup/stm32/system_stm32h5xx.c
178 # drivers/mcu/stm32/memprot_hal.c \
179 # drivers/mcu/stm32/memprot_stm32h5xx.c \
180 # drivers/mcu/stm32/serial_uart_stm32h5xx.c \
181 # drivers/mcu/stm32/sdio_h5xx.c \
182 # drivers/mcu/stm32/timer_stm32h5xx.c \
183 # drivers/mcu/stm32/adc_stm32h5xx.c \
184 # drivers/mcu/stm32/dma_stm32h5xx.c \
186 MCU_EXCLUDES = \
187 drivers/bus_i2c.c
189 MSC_SRC =
190 #MSC_SRC = \
191 drivers/mcu/stm32/usb_msc_hal.c \
192 drivers/usb_msc_common.c \
193 msc/usbd_storage.c \
194 msc/usbd_storage_emfat.c \
195 msc/emfat.c \
196 msc/emfat_file.c \
197 msc/usbd_storage_sd_spi.c \
198 msc/usbd_storage_sdio.c
200 DSP_LIB := $(ROOT)/lib/main/CMSIS/DSP
201 DEVICE_FLAGS += -DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -DUNALIGNED_SUPPORT_DISABLE -DARM_MATH_CM7