Fix gcc required subversion
[betaflight.git] / make / mcu / STM32G4.mk
blob510d6088f0616375eabf1473eb807e692175c588
2 # G4 Make file include
5 ifeq ($(DEBUG_HARDFAULTS),G4)
6 CFLAGS += -DDEBUG_HARDFAULTS
7 endif
9 #CMSIS
10 CMSIS_DIR := $(ROOT)/lib/main/CMSIS
12 #STDPERIPH
13 STDPERIPH_DIR = $(ROOT)/lib/main/STM32G4/Drivers/STM32G4xx_HAL_Driver
14 STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/Src/*.c))
15 EXCLUDES = \
16 stm32g4xx_hal_comp.c \
17 stm32g4xx_hal_crc.c \
18 stm32g4xx_hal_crc_ex.c \
19 stm32g4xx_hal_cryp.c \
20 stm32g4xx_hal_cryp_ex.c \
21 stm32g4xx_hal_dac.c \
22 stm32g4xx_hal_dac_ex.c \
23 stm32g4xx_hal_dma_ex.c \
24 stm32g4xx_hal_flash_ramfunc.c \
25 stm33g4xx_hal_fmac.c \
26 stm32g4xx_hal_hrtim.c \
27 stm32g4xx_hal_i2s.c \
28 stm32g4xx_hal_irda.c \
29 stm32g4xx_hal_iwdg.c \
30 stm32g4xx_hal_lptim.c \
31 stm32g4xx_hal_msp_template.c \
32 stm32g4xx_hal_nand.c \
33 stm32g4xx_hal_nor.c \
34 stm32g4xx_hal_opamp.c \
35 stm32g4xx_hal_opamp_ex.c \
36 stm32g4xx_hal_qspi.c \
37 stm32g4xx_hal_rng.c \
38 stm32g4xx_hal_sai.c \
39 stm32g4xx_hal_sai_ex.c \
40 stm32g4xx_hal_smartcard.c \
41 stm32g4xx_hal_smartcard_ex.c \
42 stm32g4xx_hal_smbus.c \
43 stm32g4xx_hal_spi.c \
44 stm32g4xx_hal_spi_ex.c \
45 stm32g4xx_hal_sram.c \
46 stm32g4xx_hal_timebase_tim_template.c \
47 stm32g4xx_hal_usart.c \
48 stm32g4xx_hal_usart_ex.c \
49 stm32g4xx_hal_wwdg.c \
50 stm32g4xx_ll_adc.c \
51 stm32g4xx_ll_comp.c \
52 stm32g4xx_ll_cordic.c \
53 stm32g4xx_ll_crc.c \
54 stm32g4xx_ll_crs.c \
55 stm32g4xx_ll_dac.c \
56 stm32g4xx_ll_exti.c \
57 stm32g4xx_ll_fmac.c \
58 stm32g4xx_ll_fmc.c \
59 stm32g4xx_ll_gpio.c \
60 stm32g4xx_ll_hrtim.c \
61 stm32g4xx_ll_i2c.c \
62 stm32g4xx_ll_lptim.c \
63 stm32g4xx_ll_lpuart.c \
64 stm32g4xx_ll_opamp.c \
65 stm32g4xx_ll_pwr.c \
66 stm32g4xx_ll_rcc.c \
67 stm32g4xx_ll_rng.c \
68 stm32g4xx_ll_rtc.c \
69 stm32g4xx_ll_ucpd.c \
70 stm32g4xx_ll_usart.c \
71 stm32g4xx_ll_utils.c
73 STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC))
75 #USB
76 USBCORE_DIR = $(ROOT)/lib/main/STM32G4/Middlewares/ST/STM32_USB_Device_Library/Core
77 USBCORE_SRC = $(notdir $(wildcard $(USBCORE_DIR)/Src/*.c))
78 EXCLUDES = usbd_conf_template.c
79 USBCORE_SRC := $(filter-out ${EXCLUDES}, $(USBCORE_SRC))
81 USBCDC_DIR = $(ROOT)/lib/main/STM32G4/Middlewares/ST/STM32_USB_Device_Library/Class/CDC
82 USBCDC_SRC = $(notdir $(wildcard $(USBCDC_DIR)/Src/*.c))
83 EXCLUDES = usbd_cdc_if_template.c
84 USBCDC_SRC := $(filter-out ${EXCLUDES}, $(USBCDC_SRC))
86 USBHID_DIR = $(ROOT)/lib/main/STM32G4/Middlewares/ST/STM32_USB_Device_Library/Class/HID
87 USBHID_SRC = $(notdir $(wildcard $(USBHID_DIR)/Src/*.c))
89 USBMSC_DIR = $(ROOT)/lib/main/STM32G4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC
90 USBMSC_SRC = $(notdir $(wildcard $(USBMSC_DIR)/Src/*.c))
91 EXCLUDES = usbd_msc_storage_template.c
92 USBMSC_SRC := $(filter-out ${EXCLUDES}, $(USBMSC_SRC))
94 VPATH := $(VPATH):$(USBCDC_DIR)/Src:$(USBCORE_DIR)/Src:$(USBHID_DIR)/Src:$(USBMSC_DIR)/Src
96 DEVICE_STDPERIPH_SRC := $(STDPERIPH_SRC) \
97 $(USBCORE_SRC) \
98 $(USBCDC_SRC) \
99 $(USBHID_SRC) \
100 $(USBMSC_SRC)
102 #CMSIS
103 VPATH := $(VPATH):$(CMSIS_DIR)/Include:$(CMSIS_DIR)/Device/ST/STM32G4xx
104 VPATH := $(VPATH):$(STDPERIPH_DIR)/Src
105 CMSIS_SRC :=
106 INCLUDE_DIRS := $(INCLUDE_DIRS) \
107 $(STDPERIPH_DIR)/Inc \
108 $(USBCORE_DIR)/Inc \
109 $(USBCDC_DIR)/Inc \
110 $(USBHID_DIR)/Inc \
111 $(USBMSC_DIR)/Inc \
112 $(CMSIS_DIR)/Core/Include \
113 $(ROOT)/lib/main/STM32G4/Drivers/CMSIS/Device/ST/STM32G4xx/Include \
114 $(ROOT)/src/main/vcp_hal
116 ifneq ($(filter SDCARD_SPI,$(FEATURES)),)
117 INCLUDE_DIRS := $(INCLUDE_DIRS) \
118 $(FATFS_DIR)
119 VPATH := $(VPATH):$(FATFS_DIR)
120 endif
122 ifneq ($(filter SDCARD_SDIO,$(FEATURES)),)
123 INCLUDE_DIRS := $(INCLUDE_DIRS) \
124 $(FATFS_DIR)
125 VPATH := $(VPATH):$(FATFS_DIR)
126 endif
128 #Flags
129 ARCH_FLAGS = -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant
131 DEVICE_FLAGS = -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -DUSE_DMA_RAM -DMAX_MPU_REGIONS=16
133 # G47X_TARGETS includes G47{3,4}{RE,CE,CEU}
135 ifeq ($(TARGET),$(filter $(TARGET),$(G47X_TARGETS)))
136 DEVICE_FLAGS += -DSTM32G474xx
137 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_g474.ld
138 STARTUP_SRC = startup_stm32g474xx.s
139 MCU_FLASH_SIZE = 512
140 # Override the OPTIMISE_SPEED compiler setting to save flash space on these 512KB targets.
141 # Performance is only slightly affected but around 50 kB of flash are saved.
142 OPTIMISE_SPEED = -O2
143 else
144 $(error Unknown MCU for G4 target)
145 endif
146 DEVICE_FLAGS += -DHSE_VALUE=$(HSE_VALUE)
148 TARGET_FLAGS = -D$(TARGET)
150 VCP_SRC = \
151 vcp_hal/usbd_desc.c \
152 vcp_hal/usbd_conf_stm32g4xx.c \
153 vcp_hal/usbd_cdc_hid.c \
154 vcp_hal/usbd_cdc_interface.c \
155 drivers/serial_usb_vcp.c \
156 drivers/usb_io.c
158 MCU_COMMON_SRC = \
159 drivers/accgyro/accgyro_mpu.c \
160 drivers/adc_stm32g4xx.c \
161 drivers/bus_i2c_hal.c \
162 drivers/bus_i2c_hal_init.c \
163 drivers/bus_i2c_timing.c \
164 drivers/bus_spi_ll.c \
165 drivers/dma_stm32g4xx.c \
166 drivers/dshot_bitbang.c \
167 drivers/dshot_bitbang_decode.c \
168 drivers/dshot_bitbang_ll.c \
169 drivers/light_ws2811strip_hal.c \
170 drivers/memprot_hal.c \
171 drivers/memprot_stm32g4xx.c \
172 drivers/persistent.c \
173 drivers/pwm_output_dshot_shared.c \
174 drivers/pwm_output_dshot_hal.c \
175 drivers/timer_hal.c \
176 drivers/timer_stm32g4xx.c \
177 drivers/transponder_ir_io_hal.c \
178 drivers/system_stm32g4xx.c \
179 drivers/serial_uart_stm32g4xx.c \
180 drivers/serial_uart_hal.c \
181 startup/system_stm32g4xx.c
183 MCU_EXCLUDES = \
184 drivers/bus_i2c.c \
185 drivers/timer.c
187 # G4's MSC use the same driver layer file with F7
188 MSC_SRC = \
189 drivers/usb_msc_common.c \
190 drivers/usb_msc_f7xx.c \
191 msc/usbd_storage.c
193 ifneq ($(filter SDCARD_SDIO,$(FEATURES)),)
194 MCU_COMMON_SRC += \
195 drivers/sdio_g4xx.c
196 MSC_SRC += \
197 msc/usbd_storage_sdio.c
198 endif
200 ifneq ($(filter SDCARD_SPI,$(FEATURES)),)
201 MSC_SRC += \
202 msc/usbd_storage_sd_spi.c
203 endif
205 ifneq ($(filter ONBOARDFLASH,$(FEATURES)),)
206 MSC_SRC += \
207 msc/usbd_storage_emfat.c \
208 msc/emfat.c \
209 msc/emfat_file.c
210 endif
212 DSP_LIB := $(ROOT)/lib/main/CMSIS/DSP
213 DEVICE_FLAGS += -DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -D__FPU_PRESENT=1 -DUNALIGNED_SUPPORT_DISABLE -DARM_MATH_CM4