update Matek F405 documentation for soft serial
[inav.git] / Makefile
blobacb78e8dda471fe6f9dc4022070672565ffd2e8a
1 ###############################################################################
2 # "THE BEER-WARE LICENSE" (Revision 42):
3 # <msmith@FreeBSD.ORG> wrote this file. As long as you retain this notice you
4 # can do whatever you want with this stuff. If we meet some day, and you think
5 # this stuff is worth it, you can buy me a beer in return
6 ###############################################################################
8 # Makefile for building the iNav firmware.
10 # Invoke this with 'make help' to see the list of supported targets.
12 ###############################################################################
15 # Things that the user might override on the commandline
18 # The target to build, see VALID_TARGETS below
19 TARGET ?= SPRACINGF3
21 # Compile-time options
22 OPTIONS ?=
24 # compile for OpenPilot BootLoader support
25 OPBL ?= no
27 # Debugger optons, must be empty or GDB
28 DEBUG ?=
30 # Insert the debugging hardfault debugger
31 # releases should not be built with this flag as it does not disable pwm output
32 DEBUG_HARDFAULTS ?=
34 # Serial port/Device for flashing
35 SERIAL_DEVICE ?= $(firstword $(wildcard /dev/ttyUSB*) no-port-found)
37 # Flash size (KB). Some low-end chips actually have more flash than advertised, use this to override.
38 FLASH_SIZE ?=
40 ## V : Set verbosity level based on the V= parameter
41 ## V=0 Low
42 ## V=1 High
43 export AT := @
45 ifndef V
46 export V0 :=
47 export V1 := $(AT)
48 export STDOUT :=
49 else ifeq ($(V), 0)
50 export V0 := $(AT)
51 export V1 := $(AT)
52 export STDOUT:= "> /dev/null"
53 export MAKE := $(MAKE) --no-print-directory
54 else ifeq ($(V), 1)
55 export V0 :=
56 export V1 :=
57 export STDOUT :=
58 endif
60 ###############################################################################
61 # Things that need to be maintained as the source changes
64 FORKNAME = inav
66 # Working directories
67 ROOT := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
68 SRC_DIR = $(ROOT)/src/main
69 OBJECT_DIR = $(ROOT)/obj/main
70 BIN_DIR = $(ROOT)/obj
71 CMSIS_DIR = $(ROOT)/lib/main/CMSIS
72 INCLUDE_DIRS = $(SRC_DIR) \
73 $(ROOT)/src/main/target
74 LINKER_DIR = $(ROOT)/src/main/target/link
76 # default xtal value for F4 targets
77 HSE_VALUE = 8000000
79 # used for turning on features like VCP and SDCARD
80 FEATURES =
82 ALT_TARGETS = $(sort $(filter-out target, $(basename $(notdir $(wildcard $(ROOT)/src/main/target/*/*.mk)))))
83 OPBL_TARGETS = $(filter %_OPBL, $(ALT_TARGETS))
85 VALID_TARGETS = $(dir $(wildcard $(ROOT)/src/main/target/*/target.mk))
86 VALID_TARGETS := $(subst /,, $(subst ./src/main/target/,, $(VALID_TARGETS)))
87 VALID_TARGETS := $(VALID_TARGETS) $(ALT_TARGETS)
88 VALID_TARGETS := $(sort $(VALID_TARGETS))
90 CLEAN_TARGETS = $(addprefix clean_,$(VALID_TARGETS) )
91 TARGETS_CLEAN = $(addsuffix _clean,$(VALID_TARGETS) )
93 ifeq ($(filter $(TARGET),$(ALT_TARGETS)), $(TARGET))
94 BASE_TARGET := $(firstword $(subst /,, $(subst ./src/main/target/,, $(dir $(wildcard $(ROOT)/src/main/target/*/$(TARGET).mk)))))
95 -include $(ROOT)/src/main/target/$(BASE_TARGET)/$(TARGET).mk
96 else
97 BASE_TARGET := $(TARGET)
98 endif
100 ifeq ($(filter $(TARGET),$(OPBL_TARGETS)), $(TARGET))
101 OPBL = yes
102 endif
104 # silently ignore if the file is not present. Allows for target specific.
105 -include $(ROOT)/src/main/target/$(BASE_TARGET)/target.mk
107 F4_TARGETS = $(F405_TARGETS) $(F411_TARGETS) $(F427_TARGETS) $(F446_TARGETS)
108 F7_TARGETS = $(F7X2RE_TARGETS) $(F7X5XE_TARGETS) $(F7X5XG_TARGETS) $(F7X5XI_TARGETS) $(F7X6XG_TARGETS)
110 ifeq ($(filter $(TARGET),$(VALID_TARGETS)),)
111 $(error Target '$(TARGET)' is not valid, must be one of $(VALID_TARGETS). Have you prepared a valid target.mk?)
112 endif
114 ifeq ($(filter $(TARGET),$(F1_TARGETS) $(F3_TARGETS) $(F4_TARGETS) $(F7_TARGETS)),)
115 $(error Target '$(TARGET)' has not specified a valid STM group, must be one of F1, F3, F405, F411, F427 or F7x. Have you prepared a valid target.mk?)
116 endif
118 128K_TARGETS = $(F1_TARGETS)
119 256K_TARGETS = $(F3_TARGETS)
120 512K_TARGETS = $(F411_TARGETS) $(F446_TARGETS) $(F7X2RE_TARGETS) $(F7X5XE_TARGETS)
121 1024K_TARGETS = $(F405_TARGETS) $(F7X5XG_TARGETS) $(F7X6XG_TARGETS)
122 2048K_TARGETS = $(F427_TARGETS) $(F7X5XI_TARGETS)
124 # Configure default flash sizes for the targets (largest size specified gets hit first) if flash not specified already.
125 ifeq ($(FLASH_SIZE),)
126 ifeq ($(TARGET),$(filter $(TARGET),$(2048K_TARGETS)))
127 FLASH_SIZE = 2048
128 else ifeq ($(TARGET),$(filter $(TARGET),$(1024K_TARGETS)))
129 FLASH_SIZE = 1024
130 else ifeq ($(TARGET),$(filter $(TARGET),$(512K_TARGETS)))
131 FLASH_SIZE = 512
132 else ifeq ($(TARGET),$(filter $(TARGET),$(256K_TARGETS)))
133 FLASH_SIZE = 256
134 else ifeq ($(TARGET),$(filter $(TARGET),$(128K_TARGETS)))
135 FLASH_SIZE = 128
136 else
137 $(error FLASH_SIZE not configured for target $(TARGET))
138 endif
139 endif
141 GROUP_1_TARGETS := AIRHEROF3 AIRHEROF3_QUAD COLIBRI_RACE LUX_RACE SPARKY REVO SPARKY2 COLIBRI FALCORE PIKOBLX
142 GROUP_2_TARGETS := SPRACINGF3 SPRACINGF3EVO SPRACINGF3EVO_1SS SPRACINGF3MINI SPRACINGF3NEO SPRACINGF4EVO
143 GROUP_3_TARGETS := OMNIBUS AIRBOTF4 BLUEJAYF4 OMNIBUSF4 OMNIBUSF4PRO OMNIBUSF4V3 SPARKY2 MATEKF405 OMNIBUSF7 DYSF4PRO MATEKF405OSD MATEKF405_SERVOS6
144 GROUP_4_TARGETS := ANYFC ANYFCF7 ANYFCF7_EXTERNAL_BARO ANYFCM7 ALIENFLIGHTNGF7 PIXRACER
145 GROUP_OTHER_TARGETS := $(filter-out $(GROUP_1_TARGETS) $(GROUP_2_TARGETS) $(GROUP_3_TARGETS) $(GROUP_4_TARGETS), $(VALID_TARGETS))
147 # note that there is no hardfault debugging startup file assembly handler for other platforms
148 ifeq ($(DEBUG_HARDFAULTS),F3)
149 CFLAGS += -DDEBUG_HARDFAULTS
150 STM32F30x_COMMON_SRC = startup_stm32f3_debug_hardfault_handler.S
151 else
152 STM32F30x_COMMON_SRC = startup_stm32f30x_md_gcc.S
153 endif
155 ifeq ($(DEBUG_HARDFAULTS),F7)
156 CFLAGS += -DDEBUG_HARDFAULTS
157 endif
159 REVISION = $(shell git log -1 --format="%h")
161 FC_VER_MAJOR := $(shell grep " FC_VERSION_MAJOR" src/main/build/version.h | awk '{print $$3}' )
162 FC_VER_MINOR := $(shell grep " FC_VERSION_MINOR" src/main/build/version.h | awk '{print $$3}' )
163 FC_VER_PATCH := $(shell grep " FC_VERSION_PATCH" src/main/build/version.h | awk '{print $$3}' )
165 FC_VER := $(FC_VER_MAJOR).$(FC_VER_MINOR).$(FC_VER_PATCH)
167 # Search path for sources
168 VPATH := $(SRC_DIR):$(SRC_DIR)/startup
169 USBFS_DIR = $(ROOT)/lib/main/STM32_USB-FS-Device_Driver
170 USBPERIPH_SRC = $(notdir $(wildcard $(USBFS_DIR)/src/*.c))
171 FATFS_DIR = $(ROOT)/lib/main/FatFS
172 FATFS_SRC = $(notdir $(wildcard $(FATFS_DIR)/*.c))
174 CSOURCES := $(shell find $(SRC_DIR) -name '*.c')
176 ifeq ($(TARGET),$(filter $(TARGET),$(F3_TARGETS)))
177 # F3 TARGETS
179 STDPERIPH_DIR = $(ROOT)/lib/main/STM32F30x_StdPeriph_Driver
180 STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/src/*.c))
181 EXCLUDES = stm32f30x_crc.c \
182 stm32f30x_can.c
184 STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC))
185 DEVICE_STDPERIPH_SRC = $(STDPERIPH_SRC)
187 VPATH := $(VPATH):$(CMSIS_DIR)/CM1/CoreSupport:$(CMSIS_DIR)/CM1/DeviceSupport/ST/STM32F30x
188 CMSIS_SRC = $(notdir $(wildcard $(CMSIS_DIR)/CM1/CoreSupport/*.c \
189 $(CMSIS_DIR)/CM1/DeviceSupport/ST/STM32F30x/*.c))
191 INCLUDE_DIRS := $(INCLUDE_DIRS) \
192 $(STDPERIPH_DIR)/inc \
193 $(CMSIS_DIR)/CM1/CoreSupport \
194 $(CMSIS_DIR)/CM1/DeviceSupport/ST/STM32F30x
196 ifneq ($(filter VCP, $(FEATURES)),)
197 INCLUDE_DIRS := $(INCLUDE_DIRS) \
198 $(USBFS_DIR)/inc \
199 $(ROOT)/src/main/vcp
201 VPATH := $(VPATH):$(USBFS_DIR)/src
203 DEVICE_STDPERIPH_SRC := $(DEVICE_STDPERIPH_SRC)\
204 $(USBPERIPH_SRC)
205 endif
207 ifneq ($(filter SDCARD, $(FEATURES)),)
208 INCLUDE_DIRS := $(INCLUDE_DIRS) \
209 $(FATFS_DIR) \
211 VPATH := $(VPATH):$(FATFS_DIR)
212 endif
214 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f303_$(FLASH_SIZE)k.ld
216 ARCH_FLAGS = -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -Wdouble-promotion
217 DEVICE_FLAGS = -DSTM32F303xC -DSTM32F303
218 TARGET_FLAGS = -D$(TARGET)
219 # End F3 targets
221 # Start F4 targets
222 else ifeq ($(TARGET),$(filter $(TARGET), $(F4_TARGETS)))
224 #STDPERIPH
225 STDPERIPH_DIR = $(ROOT)/lib/main/STM32F4xx_StdPeriph_Driver
226 STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/src/*.c))
227 EXCLUDES = stm32f4xx_crc.c \
228 stm32f4xx_can.c \
229 stm32f4xx_fmc.c \
230 stm32f4xx_sai.c \
231 stm32f4xx_cec.c \
232 stm32f4xx_dsi.c \
233 stm32f4xx_flash_ramfunc.c \
234 stm32f4xx_fmpi2c.c \
235 stm32f4xx_lptim.c \
236 stm32f4xx_qspi.c \
237 stm32f4xx_spdifrx.c \
238 stm32f4xx_cryp.c \
239 stm32f4xx_cryp_aes.c \
240 stm32f4xx_hash_md5.c \
241 stm32f4xx_cryp_des.c \
242 stm32f4xx_rtc.c \
243 stm32f4xx_hash.c \
244 stm32f4xx_dbgmcu.c \
245 stm32f4xx_cryp_tdes.c \
246 stm32f4xx_hash_sha1.c
248 ifeq ($(TARGET),$(filter $(TARGET), $(F411_TARGETS)))
249 EXCLUDES += stm32f4xx_fsmc.c
250 endif
252 ifeq ($(TARGET),$(filter $(TARGET), $(F427_TARGETS)))
253 EXCLUDES += stm32f4xx_fsmc.c
254 endif
256 ifeq ($(TARGET),$(filter $(TARGET), $(F446_TARGETS)))
257 EXCLUDES += stm32f4xx_fsmc.c
258 endif
260 STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC))
262 #USB
263 USBCORE_DIR = $(ROOT)/lib/main/STM32_USB_Device_Library/Core
264 USBCORE_SRC = $(notdir $(wildcard $(USBCORE_DIR)/src/*.c))
265 USBOTG_DIR = $(ROOT)/lib/main/STM32_USB_OTG_Driver
266 USBOTG_SRC = $(notdir $(wildcard $(USBOTG_DIR)/src/*.c))
267 EXCLUDES = usb_bsp_template.c \
268 usb_conf_template.c \
269 usb_hcd_int.c \
270 usb_hcd.c \
271 usb_otg.c
273 USBOTG_SRC := $(filter-out ${EXCLUDES}, $(USBOTG_SRC))
274 USBCDC_DIR = $(ROOT)/lib/main/STM32_USB_Device_Library/Class/cdc
275 USBCDC_SRC = $(notdir $(wildcard $(USBCDC_DIR)/src/*.c))
276 EXCLUDES = usbd_cdc_if_template.c
277 USBCDC_SRC := $(filter-out ${EXCLUDES}, $(USBCDC_SRC))
278 VPATH := $(VPATH):$(USBOTG_DIR)/src:$(USBCORE_DIR)/src:$(USBCDC_DIR)/src
280 DEVICE_STDPERIPH_SRC := $(STDPERIPH_SRC) \
281 $(USBOTG_SRC) \
282 $(USBCORE_SRC) \
283 $(USBCDC_SRC)
285 #CMSIS
286 VPATH := $(VPATH):$(CMSIS_DIR)/CM4/CoreSupport:$(CMSIS_DIR)/CM4/DeviceSupport/ST/STM32F4xx
287 CMSIS_SRC = $(notdir $(wildcard $(CMSIS_DIR)/CM4/CoreSupport/*.c \
288 $(CMSIS_DIR)/CM4/DeviceSupport/ST/STM32F4xx/*.c))
289 INCLUDE_DIRS := $(INCLUDE_DIRS) \
290 $(STDPERIPH_DIR)/inc \
291 $(USBOTG_DIR)/inc \
292 $(USBCORE_DIR)/inc \
293 $(USBCDC_DIR)/inc \
294 $(USBFS_DIR)/inc \
295 $(CMSIS_DIR)/CM4/CoreSupport \
296 $(CMSIS_DIR)/CM4/DeviceSupport/ST/STM32F4xx \
297 $(ROOT)/src/main/vcpf4
299 ifneq ($(filter SDCARD,$(FEATURES)),)
300 INCLUDE_DIRS := $(INCLUDE_DIRS) \
301 $(FATFS_DIR)
302 VPATH := $(VPATH):$(FATFS_DIR)
303 endif
305 #Flags
306 ARCH_FLAGS = -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -Wdouble-promotion
308 ifeq ($(TARGET),$(filter $(TARGET),$(F411_TARGETS)))
309 DEVICE_FLAGS = -DSTM32F411xE
310 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f411.ld
311 STARTUP_SRC = startup_stm32f411xe.s
312 else ifeq ($(TARGET),$(filter $(TARGET),$(F405_TARGETS)))
313 DEVICE_FLAGS = -DSTM32F40_41xxx
314 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f405.ld
315 STARTUP_SRC = startup_stm32f40xx.s
316 else ifeq ($(TARGET),$(filter $(TARGET),$(F446_TARGETS)))
317 DEVICE_FLAGS = -DSTM32F446xx
318 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f446.ld
319 STARTUP_SRC = startup_stm32f446xx.s
320 else ifeq ($(TARGET),$(filter $(TARGET),$(F427_TARGETS)))
321 DEVICE_FLAGS = -DSTM32F427_437xx
322 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f427.ld
323 STARTUP_SRC = startup_stm32f427xx.s
324 else
325 $(error Unknown MCU for F4 target)
326 endif
328 DEVICE_FLAGS += -DHSE_VALUE=$(HSE_VALUE)
330 TARGET_FLAGS = -D$(TARGET)
331 # End F4 targets
333 # Start F7 targets
334 else ifeq ($(TARGET),$(filter $(TARGET), $(F7_TARGETS)))
336 #STDPERIPH
337 STDPERIPH_DIR = $(ROOT)/lib/main/STM32F7xx_HAL_Driver
338 STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/Src/*.c))
339 EXCLUDES = stm32f7xx_hal_can.c \
340 stm32f7xx_hal_cec.c \
341 stm32f7xx_hal_crc.c \
342 stm32f7xx_hal_crc_ex.c \
343 stm32f7xx_hal_cryp.c \
344 stm32f7xx_hal_cryp_ex.c \
345 stm32f7xx_hal_dac.c \
346 stm32f7xx_hal_dac_ex.c \
347 stm32f7xx_hal_dcmi.c \
348 stm32f7xx_hal_dcmi_ex.c \
349 stm32f7xx_hal_dfsdm.c \
350 stm32f7xx_hal_dma2d.c \
351 stm32f7xx_hal_dsi.c \
352 stm32f7xx_hal_eth.c \
353 stm32f7xx_hal_hash.c \
354 stm32f7xx_hal_hash_ex.c \
355 stm32f7xx_hal_hcd.c \
356 stm32f7xx_hal_i2s.c \
357 stm32f7xx_hal_irda.c \
358 stm32f7xx_hal_iwdg.c \
359 stm32f7xx_hal_jpeg.c \
360 stm32f7xx_hal_lptim.c \
361 stm32f7xx_hal_ltdc.c \
362 stm32f7xx_hal_ltdc_ex.c \
363 stm32f7xx_hal_mdios.c \
364 stm32f7xx_hal_mmc.c \
365 stm32f7xx_hal_msp_template.c \
366 stm32f7xx_hal_nand.c \
367 stm32f7xx_hal_nor.c \
368 stm32f7xx_hal_qspi.c \
369 stm32f7xx_hal_rng.c \
370 stm32f7xx_hal_rtc.c \
371 stm32f7xx_hal_rtc_ex.c \
372 stm32f7xx_hal_sai.c \
373 stm32f7xx_hal_sai_ex.c \
374 stm32f7xx_hal_sd.c \
375 stm32f7xx_hal_sdram.c \
376 stm32f7xx_hal_smartcard.c \
377 stm32f7xx_hal_smartcard_ex.c \
378 stm32f7xx_hal_smbus.c \
379 stm32f7xx_hal_spdifrx.c \
380 stm32f7xx_hal_sram.c \
381 stm32f7xx_hal_timebase_rtc_alarm_template.c \
382 stm32f7xx_hal_timebase_rtc_wakeup_template.c \
383 stm32f7xx_hal_timebase_tim_template.c \
384 stm32f7xx_hal_wwdg.c \
385 stm32f7xx_ll_adc.c \
386 stm32f7xx_ll_crc.c \
387 stm32f7xx_ll_dac.c \
388 stm32f7xx_ll_dma.c \
389 stm32f7xx_ll_dma2d.c \
390 stm32f7xx_ll_exti.c \
391 stm32f7xx_ll_fmc.c \
392 stm32f7xx_ll_gpio.c \
393 stm32f7xx_ll_i2c.c \
394 stm32f7xx_ll_lptim.c \
395 stm32f7xx_ll_pwr.c \
396 stm32f7xx_ll_rcc.c \
397 stm32f7xx_ll_rng.c \
398 stm32f7xx_ll_rtc.c \
399 stm32f7xx_ll_sdmmc.c \
400 stm32f7xx_ll_spi.c \
401 stm32f7xx_ll_tim.c \
402 stm32f7xx_ll_usart.c \
403 stm32f7xx_ll_utils.c
405 STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC))
407 #USB
408 USBCORE_DIR = $(ROOT)/lib/main/Middlewares/ST/STM32_USB_Device_Library/Core
409 USBCORE_SRC = $(notdir $(wildcard $(USBCORE_DIR)/Src/*.c))
410 EXCLUDES = usbd_conf_template.c
411 USBCORE_SRC := $(filter-out ${EXCLUDES}, $(USBCORE_SRC))
413 USBCDC_DIR = $(ROOT)/lib/main/Middlewares/ST/STM32_USB_Device_Library/Class/CDC
414 USBCDC_SRC = $(notdir $(wildcard $(USBCDC_DIR)/Src/*.c))
415 EXCLUDES = usbd_cdc_if_template.c
416 USBCDC_SRC := $(filter-out ${EXCLUDES}, $(USBCDC_SRC))
418 VPATH := $(VPATH):$(USBCDC_DIR)/Src:$(USBCORE_DIR)/Src
420 DEVICE_STDPERIPH_SRC := $(STDPERIPH_SRC) \
421 $(USBCORE_SRC) \
422 $(USBCDC_SRC)
424 #CMSIS
425 VPATH := $(VPATH):$(CMSIS_DIR)/CM7/Include:$(CMSIS_DIR)/CM7/Device/ST/STM32F7xx
426 VPATH := $(VPATH):$(STDPERIPH_DIR)/Src
427 CMSIS_SRC = $(notdir $(wildcard $(CMSIS_DIR)/CM7/Include/*.c \
428 $(CMSIS_DIR)/CM7/Device/ST/STM32F7xx/*.c))
429 INCLUDE_DIRS := $(INCLUDE_DIRS) \
430 $(STDPERIPH_DIR)/Inc \
431 $(USBCORE_DIR)/Inc \
432 $(USBCDC_DIR)/Inc \
433 $(CMSIS_DIR)/CM7/Include \
434 $(CMSIS_DIR)/CM7/Device/ST/STM32F7xx/Include \
435 $(ROOT)/src/main/vcp_hal
437 ifneq ($(filter SDCARD,$(FEATURES)),)
438 INCLUDE_DIRS := $(INCLUDE_DIRS) \
439 $(FATFS_DIR)
440 VPATH := $(VPATH):$(FATFS_DIR)
441 endif
443 #Flags
444 ARCH_FLAGS = -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -fsingle-precision-constant -Wdouble-promotion
446 ifeq ($(TARGET),$(filter $(TARGET),$(F7X5XG_TARGETS)))
447 DEVICE_FLAGS = -DSTM32F745xx -DUSE_HAL_DRIVER -D__FPU_PRESENT
448 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f745.ld
449 STARTUP_SRC = startup_stm32f745xx.s
450 else ifeq ($(TARGET),$(filter $(TARGET),$(F7X6XG_TARGETS)))
451 DEVICE_FLAGS = -DSTM32F746xx -DUSE_HAL_DRIVER -D__FPU_PRESENT
452 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f746.ld
453 STARTUP_SRC = startup_stm32f746xx.s
454 else ifeq ($(TARGET),$(filter $(TARGET),$(F7X2RE_TARGETS)))
455 DEVICE_FLAGS = -DSTM32F722xx -DUSE_HAL_DRIVER -D__FPU_PRESENT
456 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f722.ld
457 STARTUP_SRC = startup_stm32f722xx.s
458 else
459 $(error Unknown MCU for F7 target)
460 endif
461 DEVICE_FLAGS += -DHSE_VALUE=$(HSE_VALUE)
463 TARGET_FLAGS = -D$(TARGET)
465 # End F7 targets
467 # Start F1 targets
468 else
470 STDPERIPH_DIR = $(ROOT)/lib/main/STM32F10x_StdPeriph_Driver
471 STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/src/*.c))
472 EXCLUDES = stm32f10x_crc.c \
473 stm32f10x_cec.c \
474 stm32f10x_can.c
476 STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC))
478 # Search path and source files for the CMSIS sources
479 VPATH := $(VPATH):$(CMSIS_DIR)/CM3/CoreSupport:$(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x
480 CMSIS_SRC = $(notdir $(wildcard $(CMSIS_DIR)/CM3/CoreSupport/*.c \
481 $(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x/*.c))
483 INCLUDE_DIRS := $(INCLUDE_DIRS) \
484 $(STDPERIPH_DIR)/inc \
485 $(CMSIS_DIR)/CM3/CoreSupport \
486 $(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x \
488 DEVICE_STDPERIPH_SRC = $(STDPERIPH_SRC)
490 ifneq ($(filter VCP, $(FEATURES)),)
491 INCLUDE_DIRS := $(INCLUDE_DIRS) \
492 $(USBFS_DIR)/inc \
493 $(ROOT)/src/main/vcp
495 VPATH := $(VPATH):$(USBFS_DIR)/src
497 DEVICE_STDPERIPH_SRC := $(DEVICE_STDPERIPH_SRC) \
498 $(USBPERIPH_SRC)
500 endif
502 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f103_$(FLASH_SIZE)k.ld
503 ARCH_FLAGS = -mthumb -mcpu=cortex-m3
504 TARGET_FLAGS := -D$(TARGET) -pedantic $(TARGET_FLAGS)
506 ifeq ($(DEVICE_FLAGS),)
507 DEVICE_FLAGS = -DSTM32F10X_MD
508 endif
509 DEVICE_FLAGS += -DSTM32F10X
511 endif
513 # End F1 targets
515 ifneq ($(BASE_TARGET), $(TARGET))
516 TARGET_FLAGS := $(TARGET_FLAGS) -D$(BASE_TARGET)
517 endif
519 ifneq ($(FLASH_SIZE),)
520 DEVICE_FLAGS := $(DEVICE_FLAGS) -DFLASH_SIZE=$(FLASH_SIZE)
521 endif
523 ifneq ($(HSE_VALUE),)
524 DEVICE_FLAGS := $(DEVICE_FLAGS) -DHSE_VALUE=$(HSE_VALUE)
525 endif
527 TARGET_DIR = $(ROOT)/src/main/target/$(BASE_TARGET)
528 TARGET_DIR_SRC = $(notdir $(wildcard $(TARGET_DIR)/*.c))
530 ifeq ($(OPBL),yes)
531 TARGET_FLAGS := -DOPBL $(TARGET_FLAGS)
532 ifeq ($(TARGET), $(filter $(TARGET),$(F405_TARGETS)))
533 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f405_opbl.ld
534 else ifeq ($(TARGET), $(filter $(TARGET),$(F411_TARGETS)))
535 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f411_opbl.ld
536 else ifeq ($(TARGET), $(filter $(TARGET),$(F3_TARGETS)))
537 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f303_$(FLASH_SIZE)k_opbl.ld
538 else ifeq ($(TARGET), $(filter $(TARGET),$(F1_TARGETS)))
539 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f103_$(FLASH_SIZE)k_opbl.ld
540 endif
541 .DEFAULT_GOAL := binary
542 else
543 .DEFAULT_GOAL := hex
544 endif
546 INCLUDE_DIRS := $(INCLUDE_DIRS) \
547 $(ROOT)/lib/main/MAVLink
549 INCLUDE_DIRS := $(INCLUDE_DIRS) \
550 $(TARGET_DIR)
552 VPATH := $(VPATH):$(TARGET_DIR)
554 COMMON_SRC = \
555 $(TARGET_DIR_SRC) \
556 main.c \
557 target/common_hardware.c \
558 build/assert.c \
559 build/build_config.c \
560 build/debug.c \
561 build/version.c \
562 common/bitarray.c \
563 common/crc.c \
564 common/encoding.c \
565 common/filter.c \
566 common/maths.c \
567 common/memory.c \
568 common/printf.c \
569 common/streambuf.c \
570 common/time.c \
571 common/typeconversion.c \
572 common/string_light.c \
573 config/config_eeprom.c \
574 config/config_streamer.c \
575 config/feature.c \
576 config/parameter_group.c \
577 drivers/adc.c \
578 drivers/buf_writer.c \
579 drivers/bus.c \
580 drivers/bus_busdev_i2c.c \
581 drivers/bus_busdev_spi.c \
582 drivers/bus_i2c_soft.c \
583 drivers/bus_spi.c \
584 drivers/display.c \
585 drivers/exti.c \
586 drivers/gps_i2cnav.c \
587 drivers/io.c \
588 drivers/io_pca9685.c \
589 drivers/light_led.c \
590 drivers/logging.c \
591 drivers/resource.c \
592 drivers/rx_nrf24l01.c \
593 drivers/rx_spi.c \
594 drivers/rx_xn297.c \
595 drivers/pitotmeter_adc.c \
596 drivers/pwm_esc_detect.c \
597 drivers/pwm_mapping.c \
598 drivers/pwm_output.c \
599 drivers/rcc.c \
600 drivers/rx_pwm.c \
601 drivers/serial.c \
602 drivers/serial_uart.c \
603 drivers/sound_beeper.c \
604 drivers/stack_check.c \
605 drivers/system.c \
606 drivers/timer.c \
607 drivers/lights_io.c \
608 fc/cli.c \
609 fc/config.c \
610 fc/controlrate_profile.c \
611 fc/fc_core.c \
612 fc/fc_init.c \
613 fc/fc_tasks.c \
614 fc/fc_hardfaults.c \
615 fc/fc_msp.c \
616 fc/fc_msp_box.c \
617 fc/rc_adjustments.c \
618 fc/rc_controls.c \
619 fc/rc_curves.c \
620 fc/rc_modes.c \
621 fc/runtime_config.c \
622 fc/settings.c \
623 fc/stats.c \
624 flight/failsafe.c \
625 flight/hil.c \
626 flight/imu.c \
627 flight/mixer.c \
628 flight/pid.c \
629 flight/pid_autotune.c \
630 flight/servos.c \
631 io/beeper.c \
632 io/lights.c \
633 io/pwmdriver_i2c.c \
634 io/serial.c \
635 io/serial_4way.c \
636 io/serial_4way_avrootloader.c \
637 io/serial_4way_stk500v2.c \
638 io/statusindicator.c \
639 io/rcdevice.c \
640 io/rcdevice_cam.c \
641 msp/msp_serial.c \
642 rx/fport.c \
643 rx/ibus.c \
644 rx/jetiexbus.c \
645 rx/msp.c \
646 rx/uib_rx.c \
647 rx/nrf24_cx10.c \
648 rx/nrf24_inav.c \
649 rx/nrf24_h8_3d.c \
650 rx/nrf24_syma.c \
651 rx/nrf24_v202.c \
652 rx/pwm.c \
653 rx/rx.c \
654 rx/rx_spi.c \
655 rx/crsf.c \
656 rx/sbus.c \
657 rx/sbus_channels.c \
658 rx/spektrum.c \
659 rx/sumd.c \
660 rx/sumh.c \
661 rx/xbus.c \
662 rx/eleres.c \
663 scheduler/scheduler.c \
664 sensors/acceleration.c \
665 sensors/battery.c \
666 sensors/temperature.c \
667 sensors/boardalignment.c \
668 sensors/compass.c \
669 sensors/diagnostics.c \
670 sensors/gyro.c \
671 sensors/initialisation.c \
672 uav_interconnect/uav_interconnect_bus.c \
673 uav_interconnect/uav_interconnect_rangefinder.c \
674 $(CMSIS_SRC) \
675 $(DEVICE_STDPERIPH_SRC)
677 HIGHEND_SRC = \
678 blackbox/blackbox.c \
679 blackbox/blackbox_encoding.c \
680 blackbox/blackbox_io.c \
681 cms/cms.c \
682 cms/cms_menu_blackbox.c \
683 cms/cms_menu_builtin.c \
684 cms/cms_menu_imu.c \
685 cms/cms_menu_ledstrip.c \
686 cms/cms_menu_misc.c \
687 cms/cms_menu_navigation.c \
688 cms/cms_menu_osd.c \
689 cms/cms_menu_vtx_smartaudio.c \
690 cms/cms_menu_vtx_tramp.c \
691 common/colorconversion.c \
692 common/gps_conversion.c \
693 drivers/display_ug2864hsweg01.c \
694 drivers/rangefinder/rangefinder_hcsr04.c \
695 drivers/rangefinder/rangefinder_hcsr04_i2c.c \
696 drivers/rangefinder/rangefinder_srf10.c \
697 drivers/rangefinder/rangefinder_vl53l0x.c \
698 drivers/opflow/opflow_fake.c \
699 drivers/opflow/opflow_virtual.c \
700 drivers/vtx_common.c \
701 io/opflow_cxof.c \
702 io/dashboard.c \
703 io/displayport_max7456.c \
704 io/displayport_msp.c \
705 io/displayport_oled.c \
706 io/gps.c \
707 io/gps_ublox.c \
708 io/gps_nmea.c \
709 io/gps_naza.c \
710 io/gps_i2cnav.c \
711 io/ledstrip.c \
712 io/osd.c \
713 navigation/navigation.c \
714 navigation/navigation_fixedwing.c \
715 navigation/navigation_fw_launch.c \
716 navigation/navigation_geo.c \
717 navigation/navigation_multicopter.c \
718 navigation/navigation_pos_estimator.c \
719 sensors/barometer.c \
720 sensors/pitotmeter.c \
721 sensors/rangefinder.c \
722 sensors/opflow.c \
723 telemetry/crsf.c \
724 telemetry/frsky.c \
725 telemetry/hott.c \
726 telemetry/ibus_shared.c \
727 telemetry/ibus.c \
728 telemetry/ltm.c \
729 telemetry/mavlink.c \
730 telemetry/msp_shared.c \
731 telemetry/smartport.c \
732 telemetry/telemetry.c \
733 io/vtx_string.c \
734 io/vtx_smartaudio.c \
735 io/vtx_tramp.c \
736 io/vtx_control.c
738 ifeq ($(TARGET),$(filter $(TARGET),$(F4_TARGETS)))
739 VCP_SRC = \
740 vcpf4/stm32f4xx_it.c \
741 vcpf4/usb_bsp.c \
742 vcpf4/usbd_desc.c \
743 vcpf4/usbd_usr.c \
744 vcpf4/usbd_cdc_vcp.c \
745 drivers/serial_usb_vcp.c \
746 drivers/usb_io.c
747 else ifeq ($(TARGET),$(filter $(TARGET),$(F7_TARGETS)))
748 VCP_SRC = \
749 vcp_hal/usbd_desc.c \
750 vcp_hal/usbd_conf.c \
751 vcp_hal/usbd_cdc_interface.c \
752 drivers/serial_usb_vcp.c \
753 drivers/usb_io.c
754 else
755 VCP_SRC = \
756 vcp/hw_config.c \
757 vcp/stm32_it.c \
758 vcp/usb_desc.c \
759 vcp/usb_endp.c \
760 vcp/usb_istr.c \
761 vcp/usb_prop.c \
762 vcp/usb_pwr.c \
763 drivers/serial_usb_vcp.c \
764 drivers/usb_io.c
765 endif
767 STM32F10x_COMMON_SRC = \
768 startup_stm32f10x_md_gcc.S \
769 drivers/accgyro/accgyro.c \
770 drivers/adc_stm32f10x.c \
771 drivers/bus_i2c_stm32f10x.c \
772 drivers/dma.c \
773 drivers/gpio_stm32f10x.c \
774 drivers/inverter.c \
775 drivers/serial_softserial.c \
776 drivers/serial_uart_stm32f10x.c \
777 drivers/system_stm32f10x.c \
778 drivers/timer_stm32f10x.c
780 STM32F30x_COMMON_SRC = \
781 startup_stm32f30x_md_gcc.S \
782 target/system_stm32f30x.c \
783 drivers/accgyro/accgyro.c \
784 drivers/adc_stm32f30x.c \
785 drivers/bus_i2c_stm32f30x.c \
786 drivers/dma.c \
787 drivers/gpio_stm32f30x.c \
788 drivers/serial_uart_stm32f30x.c \
789 drivers/system_stm32f30x.c \
790 drivers/timer_stm32f30x.c
792 STM32F4xx_COMMON_SRC = \
793 target/system_stm32f4xx.c \
794 drivers/accgyro/accgyro.c \
795 drivers/accgyro/accgyro_mpu.c \
796 drivers/adc_stm32f4xx.c \
797 drivers/adc_stm32f4xx.c \
798 drivers/bus_i2c_stm32f10x.c \
799 drivers/gpio_stm32f4xx.c \
800 drivers/inverter.c \
801 drivers/serial_softserial.c \
802 drivers/serial_uart_stm32f4xx.c \
803 drivers/system_stm32f4xx.c \
804 drivers/timer_stm32f4xx.c \
805 drivers/dma_stm32f4xx.c
807 STM32F7xx_COMMON_SRC = \
808 target/system_stm32f7xx.c \
809 drivers/accgyro/accgyro.c \
810 drivers/accgyro/accgyro_mpu.c \
811 drivers/adc_stm32f7xx.c \
812 drivers/bus_i2c_hal.c \
813 drivers/dma_stm32f7xx.c \
814 drivers/gpio_stm32f7xx.c \
815 drivers/inverter.c \
816 drivers/bus_spi_hal.c \
817 drivers/timer_hal.c \
818 drivers/timer_stm32f7xx.c \
819 drivers/system_stm32f7xx.c \
820 drivers/serial_uart_stm32f7xx.c \
821 drivers/serial_uart_hal.c
823 F7EXCLUDES = drivers/bus_spi.c \
824 drivers/bus_i2c.c \
825 drivers/timer.c \
826 drivers/serial_uart.c
828 # check if target.mk supplied
829 ifeq ($(TARGET),$(filter $(TARGET),$(F4_TARGETS)))
830 TARGET_SRC := $(STARTUP_SRC) $(STM32F4xx_COMMON_SRC) $(TARGET_SRC)
831 else ifeq ($(TARGET),$(filter $(TARGET),$(F7_TARGETS)))
832 TARGET_SRC := $(STARTUP_SRC) $(STM32F7xx_COMMON_SRC) $(TARGET_SRC)
833 else ifeq ($(TARGET),$(filter $(TARGET),$(F3_TARGETS)))
834 TARGET_SRC := $(STM32F30x_COMMON_SRC) $(TARGET_SRC)
835 else ifeq ($(TARGET),$(filter $(TARGET),$(F1_TARGETS)))
836 TARGET_SRC := $(STM32F10x_COMMON_SRC) $(TARGET_SRC)
837 endif
839 ifneq ($(filter ONBOARDFLASH,$(FEATURES)),)
840 TARGET_SRC += \
841 drivers/flash_m25p16.c \
842 io/flashfs.c
843 endif
845 ifeq ($(TARGET),$(filter $(TARGET),$(F7_TARGETS) $(F4_TARGETS) $(F3_TARGETS)))
846 TARGET_SRC += $(HIGHEND_SRC)
847 else ifneq ($(filter HIGHEND,$(FEATURES)),)
848 TARGET_SRC += $(HIGHEND_SRC)
849 endif
851 TARGET_SRC += $(COMMON_SRC)
852 #excludes
853 ifeq ($(TARGET),$(filter $(TARGET),$(F7_TARGETS)))
854 TARGET_SRC := $(filter-out ${F7EXCLUDES}, $(TARGET_SRC))
855 endif
857 ifneq ($(filter SDCARD,$(FEATURES)),)
858 TARGET_SRC += \
859 drivers/sdcard.c \
860 drivers/sdcard_standard.c \
861 io/asyncfatfs/asyncfatfs.c \
862 io/asyncfatfs/fat_standard.c
863 endif
865 ifneq ($(filter VCP,$(FEATURES)),)
866 TARGET_SRC += $(VCP_SRC)
867 endif
868 # end target specific make file checks
870 # Search path and source files for the ST stdperiph library
871 VPATH := $(VPATH):$(STDPERIPH_DIR)/src
873 ###############################################################################
874 # Things that might need changing to use different tools
877 # Tool names
878 ifneq ($(TOOLCHAINPATH),)
879 CROSS_CC = $(TOOLCHAINPATH)/arm-none-eabi-gcc
880 OBJCOPY = $(TOOLCHAINPATH)/arm-none-eabi-objcopy
881 SIZE = $(TOOLCHAINPATH)/arm-none-eabi-size
882 else
883 CROSS_CC = arm-none-eabi-gcc
884 OBJCOPY = arm-none-eabi-objcopy
885 SIZE = arm-none-eabi-size
886 endif
889 # Tool options.
892 ifeq ($(DEBUG),GDB)
893 OPTIMIZE = -O0
894 LTO_FLAGS = $(OPTIMIZE)
895 else
896 OPTIMIZE = -Os
897 LTO_FLAGS = -flto -fuse-linker-plugin $(OPTIMIZE)
898 endif
900 DEBUG_FLAGS = -ggdb3 -DDEBUG
902 CFLAGS += $(ARCH_FLAGS) \
903 $(LTO_FLAGS) \
904 $(addprefix -D,$(OPTIONS)) \
905 $(addprefix -I,$(INCLUDE_DIRS)) \
906 $(DEBUG_FLAGS) \
907 -std=gnu99 \
908 -Wall -Wextra -Wunsafe-loop-optimizations -Wdouble-promotion \
909 -Werror=switch \
910 -ffunction-sections \
911 -fdata-sections \
912 $(DEVICE_FLAGS) \
913 -DUSE_STDPERIPH_DRIVER \
914 $(TARGET_FLAGS) \
915 -D'__FORKNAME__="$(FORKNAME)"' \
916 -D'__TARGET__="$(TARGET)"' \
917 -D'__REVISION__="$(REVISION)"' \
918 -save-temps=obj \
919 -MMD -MP
921 ASFLAGS = $(ARCH_FLAGS) \
922 -x assembler-with-cpp \
923 $(addprefix -I,$(INCLUDE_DIRS)) \
924 -D$(TARGET) \
925 -MMD -MP
927 LDFLAGS = -lm \
928 -nostartfiles \
929 --specs=nano.specs \
930 -lc \
931 -lnosys \
932 $(ARCH_FLAGS) \
933 $(LTO_FLAGS) \
934 $(DEBUG_FLAGS) \
935 -static \
936 -Wl,-gc-sections,-Map,$(TARGET_MAP) \
937 -Wl,-L$(LINKER_DIR) \
938 -Wl,--cref \
939 -Wl,--no-wchar-size-warning \
940 -T$(LD_SCRIPT)
942 ###############################################################################
943 # No user-serviceable parts below
944 ###############################################################################
946 CPPCHECK = cppcheck $(CSOURCES) --enable=all --platform=unix64 \
947 --std=c99 --inline-suppr --quiet --force \
948 $(addprefix -I,$(INCLUDE_DIRS)) \
949 -I/usr/include -I/usr/include/linux
952 # Things we will build
954 TARGET_BIN = $(BIN_DIR)/$(FORKNAME)_$(FC_VER)_$(TARGET).bin
955 TARGET_HEX = $(BIN_DIR)/$(FORKNAME)_$(FC_VER)_$(TARGET).hex
956 TARGET_ELF = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET).elf
957 TARGET_OBJS = $(addsuffix .o,$(addprefix $(OBJECT_DIR)/$(TARGET)/,$(basename $(TARGET_SRC))))
958 TARGET_DEPS = $(addsuffix .d,$(addprefix $(OBJECT_DIR)/$(TARGET)/,$(basename $(TARGET_SRC))))
959 TARGET_MAP = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET).map
962 CLEAN_ARTIFACTS := $(TARGET_BIN)
963 CLEAN_ARTIFACTS += $(TARGET_HEX)
964 CLEAN_ARTIFACTS += $(TARGET_ELF) $(TARGET_OBJS) $(TARGET_MAP)
966 # Make sure build date and revision is updated on every incremental build
967 $(OBJECT_DIR)/$(TARGET)/build/version.o : $(TARGET_SRC)
969 # Settings generator
970 .PHONY: .FORCE settings clean-settings
971 UTILS_DIR = $(ROOT)/src/utils
972 SETTINGS_GENERATOR = $(UTILS_DIR)/settings.rb
973 BUILD_STAMP = $(UTILS_DIR)/build_stamp.rb
974 STAMP = $(BIN_DIR)/build.stamp
976 GENERATED_SETTINGS = $(SRC_DIR)/fc/settings_generated.h $(SRC_DIR)/fc/settings_generated.c
977 SETTINGS_FILE = $(SRC_DIR)/fc/settings.yaml
978 GENERATED_FILES = $(GENERATED_SETTINGS)
979 $(GENERATED_SETTINGS): $(SETTINGS_GENERATOR) $(SETTINGS_FILE) $(STAMP)
981 $(STAMP): .FORCE
982 $(V1) CFLAGS="$(CFLAGS)" TARGET=$(TARGET) ruby $(BUILD_STAMP) $(SETTINGS_FILE) $(STAMP)
984 # Use a pattern rule, since they're different than normal rules.
985 # See https://www.gnu.org/software/make/manual/make.html#Pattern-Examples
986 %generated.h %generated.c:
987 $(V1) echo "settings.yaml -> settings_generated.h, settings_generated.c" "$(STDOUT)"
988 $(V1) CFLAGS="$(CFLAGS)" TARGET=$(TARGET) ruby $(SETTINGS_GENERATOR) . $(SETTINGS_FILE)
990 settings-json:
991 $(V0) CFLAGS="$(CFLAGS)" TARGET=$(TARGET) ruby $(SETTINGS_GENERATOR) . $(SETTINGS_FILE) --json settings.json
993 clean-settings:
994 $(V1) $(RM) $(GENERATED_SETTINGS)
996 # List of buildable ELF files and their object dependencies.
997 # It would be nice to compute these lists, but that seems to be just beyond make.
999 $(TARGET_HEX): $(TARGET_ELF)
1000 $(V0) $(OBJCOPY) -O ihex --set-start 0x8000000 $< $@
1002 $(TARGET_BIN): $(TARGET_ELF)
1003 $(V0) $(OBJCOPY) -O binary $< $@
1005 $(TARGET_ELF): $(TARGET_OBJS)
1006 $(V1) echo Linking $(TARGET)
1007 $(V1) $(CROSS_CC) -o $@ $(filter %.o, $^) $(LDFLAGS)
1008 $(V0) $(SIZE) $(TARGET_ELF)
1010 # Compile
1011 $(OBJECT_DIR)/$(TARGET)/%.o: %.c
1012 $(V1) mkdir -p $(dir $@)
1013 $(V1) echo %% $(notdir $<) "$(STDOUT)"
1014 $(V1) $(CROSS_CC) -c -o $@ $(CFLAGS) $<
1016 # Assemble
1017 $(OBJECT_DIR)/$(TARGET)/%.o: %.s
1018 $(V1) mkdir -p $(dir $@)
1019 $(V1) echo %% $(notdir $<) "$(STDOUT)"
1020 $(V1) $(CROSS_CC) -c -o $@ $(ASFLAGS) $<
1022 $(OBJECT_DIR)/$(TARGET)/%.o: %.S
1023 $(V1) mkdir -p $(dir $@)
1024 $(V1) echo %% $(notdir $<) "$(STDOUT)"
1025 $(V1) $(CROSS_CC) -c -o $@ $(ASFLAGS) $<
1028 ## all : Build all valid targets
1029 all: $(VALID_TARGETS)
1031 ## targets-group-1 : build some targets
1032 targets-group-1: $(GROUP_1_TARGETS)
1034 ## targets-group-2 : build some targets
1035 targets-group-2: $(GROUP_2_TARGETS)
1037 ## targets-group-3 : build some targets
1038 targets-group-3: $(GROUP_3_TARGETS)
1040 ## targets-group-3 : build some targets
1041 targets-group-4: $(GROUP_4_TARGETS)
1043 ## targets-group-rest: build the rest of the targets (not listed in group 1, 2 or 3)
1044 targets-group-rest: $(GROUP_OTHER_TARGETS)
1046 $(VALID_TARGETS):
1047 $(V0) echo "" && \
1048 echo "Building $@" && \
1049 $(MAKE) -j 8 TARGET=$@ && \
1050 echo "Building $@ succeeded."
1052 ## clean : clean up all temporary / machine-generated files
1053 clean:
1054 $(V0) echo "Cleaning $(TARGET)"
1055 $(V0) rm -f $(CLEAN_ARTIFACTS)
1056 $(V0) rm -rf $(OBJECT_DIR)/$(TARGET)
1057 $(V0) rm -f $(GENERATED_SETTINGS)
1058 $(V0) echo "Cleaning $(TARGET) succeeded."
1060 ## clean_test : clean up all temporary / machine-generated files (tests)
1061 clean_test:
1062 $(V0) cd src/test && $(MAKE) clean || true
1064 ## clean_<TARGET> : clean up one specific target
1065 $(CLEAN_TARGETS) :
1066 $(V0) $(MAKE) -j 8 TARGET=$(subst clean_,,$@) clean
1068 ## <TARGET>_clean : clean up one specific target (alias for above)
1069 $(TARGETS_CLEAN) :
1070 $(V0) $(MAKE) -j 8 TARGET=$(subst _clean,,$@) clean
1072 ## clean_all : clean all valid targets
1073 clean_all:$(CLEAN_TARGETS)
1075 ## all_clean : clean all valid targets (alias for above)
1076 all_clean:$(TARGETS_CLEAN)
1078 flash_$(TARGET): $(TARGET_HEX)
1079 $(V0) stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
1080 $(V0) echo -n 'R' >$(SERIAL_DEVICE)
1081 $(V0) stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
1083 ## flash : flash firmware (.hex) onto flight controller
1084 flash: flash_$(TARGET)
1086 st-flash_$(TARGET): $(TARGET_BIN)
1087 $(V0) st-flash --reset write $< 0x08000000
1089 ## st-flash : flash firmware (.bin) onto flight controller
1090 st-flash: st-flash_$(TARGET)
1092 binary: $(TARGET_BIN)
1093 hex: $(TARGET_HEX)
1095 unbrick_$(TARGET): $(TARGET_HEX)
1096 $(V0) stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
1097 $(V0) stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
1099 ## unbrick : unbrick flight controller
1100 unbrick: unbrick_$(TARGET)
1102 ## cppcheck : run static analysis on C source code
1103 cppcheck: $(CSOURCES)
1104 $(V0) $(CPPCHECK)
1106 cppcheck-result.xml: $(CSOURCES)
1107 $(V0) $(CPPCHECK) --xml-version=2 2> cppcheck-result.xml
1109 ## help : print this help message and exit
1110 help: Makefile
1111 $(V0) @echo ""
1112 $(V0) @echo "Makefile for the $(FORKNAME) firmware"
1113 $(V0) @echo ""
1114 $(V0) @echo "Usage:"
1115 $(V0) @echo " make [TARGET=<target>] [OPTIONS=\"<options>\"]"
1116 $(V0) @echo "Or:"
1117 $(V0) @echo " make <target> [OPTIONS=\"<options>\"]"
1118 $(V0) @echo ""
1119 $(V0) @echo "Valid TARGET values are: $(VALID_TARGETS)"
1120 $(V0) @echo ""
1121 $(V0) @sed -n 's/^## //p' $<
1123 ## targets : print a list of all valid target platforms (for consumption by scripts)
1124 targets:
1125 $(V0) @echo "Valid targets: $(VALID_TARGETS)"
1126 $(V0) @echo "Target: $(TARGET)"
1127 $(V0) @echo "Base target: $(BASE_TARGET)"
1128 $(V0) @echo "targets-group-1: $(GROUP_1_TARGETS)"
1129 $(V0) @echo "targets-group-2: $(GROUP_2_TARGETS)"
1130 $(V0) @echo "targets-group-3: $(GROUP_3_TARGETS)"
1131 $(V0) @echo "targets-group-4: $(GROUP_4_TARGETS)"
1132 $(V0) @echo "targets-group-rest: $(GROUP_OTHER_TARGETS)"
1134 ## test : run the cleanflight test suite
1135 test:
1136 $(V0) cd src/test && $(MAKE) test || true
1138 # rebuild everything when makefile changes
1139 # Make the generated files and the build stamp order only prerequisites,
1140 # so they will be generated before TARGET_OBJS but regenerating them
1141 # won't cause all TARGET_OBJS to be rebuilt.
1142 $(TARGET_OBJS) : Makefile | $(GENERATED_FILES) $(STAMP)
1144 # include auto-generated dependencies
1145 -include $(TARGET_DEPS)