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 betaflight 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
21 # Compile-time options
24 # compile for OpenPilot BootLoader support
27 # Debugger optons, must be empty or GDB
30 # Insert the debugging hardfault debugger
31 # releases should not be built with this flag as it does not disable pwm output
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.
41 ###############################################################################
42 # Things that need to be maintained as the source changes
48 ROOT
:= $(patsubst %/,%,$(dir $(lastword
$(MAKEFILE_LIST
))))
49 SRC_DIR
= $(ROOT
)/src
/main
50 OBJECT_DIR
= $(ROOT
)/obj
/main
52 CMSIS_DIR
= $(ROOT
)/lib
/main
/CMSIS
53 INCLUDE_DIRS
= $(SRC_DIR
) \
54 $(ROOT
)/src
/main
/target
55 LINKER_DIR
= $(ROOT
)/src
/main
/target
/link
57 ## V : Set verbosity level based on the V= parameter
60 include $(ROOT
)/make
/build_verbosity.mk
62 # Build tools, so we all share the same versions
63 # import macros common to all supported build systems
64 include $(ROOT
)/make
/system-id.mk
66 # developer preferences, edit these at will, they'll be gitignored
67 -include $(ROOT
)/make
/local.mk
69 # configure some directories that are relative to wherever ROOT_DIR is located
71 TOOLS_DIR
:= $(ROOT
)/tools
73 BUILD_DIR
:= $(ROOT
)/build
74 DL_DIR
:= $(ROOT
)/downloads
78 # import macros that are OS specific
79 include $(ROOT
)/make
/$(OSFAMILY
).mk
81 # include the tools makefile
82 include $(ROOT
)/make
/tools.mk
84 # default xtal value for F4 targets
87 # used for turning on features like VCP and SDCARD
90 OFFICIAL_TARGETS
= ALIENFLIGHTF3 ALIENFLIGHTF4 ANYFCF7 BETAFLIGHTF3 BLUEJAYF4 CC3D FURYF4 NAZE REVO SIRINFPV SPARKY SPRACINGF3 SPRACINGF3EVO SPRACINGF3NEO SPRACINGF4EVO STM32F3DISCOVERY
91 ALT_TARGETS
= $(sort $(filter-out target
, $(basename $(notdir $(wildcard $(ROOT
)/src
/main
/target
/*/*.mk
)))))
92 OPBL_TARGETS
= $(filter %_OPBL
, $(ALT_TARGETS
))
93 OSD_SLAVE_TARGETS
= SPRACINGF3OSD
95 VALID_TARGETS
= $(dir $(wildcard $(ROOT
)/src
/main
/target
/*/target.mk
))
96 VALID_TARGETS
:= $(subst /,, $(subst .
/src
/main
/target
/,, $(VALID_TARGETS
)))
97 VALID_TARGETS
:= $(VALID_TARGETS
) $(ALT_TARGETS
)
98 VALID_TARGETS
:= $(sort $(VALID_TARGETS
))
178 GROUP_OTHER_TARGETS
:= $(filter-out $(GROUP_1_TARGETS
) $(GROUP_2_TARGETS
) $(GROUP_3_TARGETS
) $(GROUP_4_TARGETS
), $(VALID_TARGETS
))
181 ifeq ($(filter $(TARGET
),$(ALT_TARGETS
)), $(TARGET
))
182 BASE_TARGET
:= $(firstword $(subst /,, $(subst .
/src
/main
/target
/,, $(dir $(wildcard $(ROOT
)/src
/main
/target
/*/$(TARGET
).mk
)))))
183 -include $(ROOT
)/src
/main
/target
/$(BASE_TARGET
)/$(TARGET
).mk
185 BASE_TARGET
:= $(TARGET
)
188 ifeq ($(filter $(TARGET
),$(OPBL_TARGETS
)), $(TARGET
))
192 ifeq ($(filter $(TARGET
),$(OSD_SLAVE_TARGETS
)), $(TARGET
))
201 # silently ignore if the file is not present. Allows for target specific.
202 -include $(ROOT
)/src
/main
/target
/$(BASE_TARGET
)/target.mk
204 F4_TARGETS
= $(F405_TARGETS
) $(F411_TARGETS
) $(F446_TARGETS
)
205 F7_TARGETS
= $(F7X2RE_TARGETS
) $(F7X5XE_TARGETS
) $(F7X5XG_TARGETS
) $(F7X5XI_TARGETS
) $(F7X6XG_TARGETS
)
207 ifeq ($(filter $(TARGET
),$(VALID_TARGETS
)),)
208 $(error Target
'$(TARGET)' is not valid
, must be one of
$(VALID_TARGETS
). Have you prepared a valid target.mk?
)
211 ifeq ($(filter $(TARGET
),$(F1_TARGETS
) $(F3_TARGETS
) $(F4_TARGETS
) $(F7_TARGETS
) $(SITL_TARGETS
)),)
212 $(error Target
'$(TARGET)' has not specified a valid STM group
, must be one of F1
, F3
, F405
, F411 or F7x5. Have you prepared a valid target.mk?
)
215 128K_TARGETS
= $(F1_TARGETS
)
216 256K_TARGETS
= $(F3_TARGETS
)
217 512K_TARGETS
= $(F411_TARGETS
) $(F446_TARGETS
) $(F7X2RE_TARGETS
) $(F7X5XE_TARGETS
)
218 1024K_TARGETS
= $(F405_TARGETS
) $(F7X5XG_TARGETS
) $(F7X6XG_TARGETS
)
219 2048K_TARGETS
= $(F7X5XI_TARGETS
) $(SITL_TARGETS
)
221 # Configure default flash sizes for the targets (largest size specified gets hit first) if flash not specified already.
222 ifeq ($(FLASH_SIZE
),)
223 ifeq ($(TARGET
),$(filter $(TARGET
),$(2048K_TARGETS
)))
225 else ifeq ($(TARGET
),$(filter $(TARGET
),$(1024K_TARGETS
)))
227 else ifeq ($(TARGET
),$(filter $(TARGET
),$(512K_TARGETS
)))
229 else ifeq ($(TARGET
),$(filter $(TARGET
),$(256K_TARGETS
)))
231 else ifeq ($(TARGET
),$(filter $(TARGET
),$(128K_TARGETS
)))
234 $(error FLASH_SIZE not configured for target
$(TARGET
))
238 # note that there is no hardfault debugging startup file assembly handler for other platforms
239 ifeq ($(DEBUG_HARDFAULTS
),F3
)
240 CFLAGS
+= -DDEBUG_HARDFAULTS
241 STM32F30x_COMMON_SRC
= startup_stm32f3_debug_hardfault_handler.S
243 STM32F30x_COMMON_SRC
= startup_stm32f30x_md_gcc.S
246 ifeq ($(DEBUG_HARDFAULTS
),F7
)
247 CFLAGS
+= -DDEBUG_HARDFAULTS
250 REVISION
:= $(shell git log
-1 --format
="%h")
252 FC_VER_MAJOR
:= $(shell grep
" FC_VERSION_MAJOR" src
/main
/build
/version.h | awk
'{print $$3}' )
253 FC_VER_MINOR
:= $(shell grep
" FC_VERSION_MINOR" src
/main
/build
/version.h | awk
'{print $$3}' )
254 FC_VER_PATCH
:= $(shell grep
" FC_VERSION_PATCH" src
/main
/build
/version.h | awk
'{print $$3}' )
256 FC_VER
:= $(FC_VER_MAJOR
).
$(FC_VER_MINOR
).
$(FC_VER_PATCH
)
258 # Search path for sources
259 VPATH
:= $(SRC_DIR
):$(SRC_DIR
)/startup
260 USBFS_DIR
= $(ROOT
)/lib
/main
/STM32_USB-FS-Device_Driver
261 USBPERIPH_SRC
= $(notdir $(wildcard $(USBFS_DIR
)/src
/*.c
))
262 FATFS_DIR
= $(ROOT
)/lib
/main
/FatFS
263 FATFS_SRC
= $(notdir $(wildcard $(FATFS_DIR
)/*.c
))
265 CSOURCES
:= $(shell find
$(SRC_DIR
) -name
'*.c')
267 ifeq ($(TARGET
),$(filter $(TARGET
),$(F3_TARGETS
)))
270 STDPERIPH_DIR
= $(ROOT
)/lib
/main
/STM32F30x_StdPeriph_Driver
271 STDPERIPH_SRC
= $(notdir $(wildcard $(STDPERIPH_DIR
)/src
/*.c
))
272 EXCLUDES
= stm32f30x_crc.c \
274 STARTUP_SRC
= startup_stm32f30x_md_gcc.S
276 STDPERIPH_SRC
:= $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC
))
277 DEVICE_STDPERIPH_SRC
= $(STDPERIPH_SRC
)
279 VPATH
:= $(VPATH
):$(CMSIS_DIR
)/CM4
/CoreSupport
:$(CMSIS_DIR
)/CM4
/DeviceSupport
/ST
/STM32F30x
280 CMSIS_SRC
= $(notdir $(wildcard $(CMSIS_DIR
)/CM4
/CoreSupport
/*.c \
281 $(CMSIS_DIR
)/CM4
/DeviceSupport
/ST
/STM32F30x
/*.c
))
283 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
284 $(STDPERIPH_DIR
)/inc \
285 $(CMSIS_DIR
)/CM4
/CoreSupport \
286 $(CMSIS_DIR
)/CM4
/DeviceSupport
/ST
/STM32F30x
288 ifneq ($(filter VCP
, $(FEATURES
)),)
289 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
293 VPATH
:= $(VPATH
):$(USBFS_DIR
)/src
295 DEVICE_STDPERIPH_SRC
:= $(DEVICE_STDPERIPH_SRC
)\
299 ifneq ($(filter SDCARD
, $(FEATURES
)),)
300 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
303 VPATH
:= $(VPATH
):$(FATFS_DIR
)
306 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f303_
$(FLASH_SIZE
)k.
ld
308 ARCH_FLAGS
= -mthumb
-mcpu
=cortex-m4
-mfloat-abi
=hard
-mfpu
=fpv4-sp-d16
-fsingle-precision-constant
-Wdouble-promotion
309 DEVICE_FLAGS
= -DSTM32F303xC
-DSTM32F303
313 else ifeq ($(TARGET
),$(filter $(TARGET
), $(F4_TARGETS
)))
316 STDPERIPH_DIR
= $(ROOT
)/lib
/main
/STM32F4xx_StdPeriph_Driver
317 STDPERIPH_SRC
= $(notdir $(wildcard $(STDPERIPH_DIR
)/src
/*.c
))
318 EXCLUDES
= stm32f4xx_crc.c \
324 stm32f4xx_flash_ramfunc.c \
328 stm32f4xx_spdifrx.c \
330 stm32f4xx_cryp_aes.c \
331 stm32f4xx_hash_md5.c \
332 stm32f4xx_cryp_des.c \
336 stm32f4xx_cryp_tdes.c \
337 stm32f4xx_hash_sha1.c
339 ifeq ($(TARGET
),$(filter $(TARGET
), $(F411_TARGETS
)))
340 EXCLUDES
+= stm32f4xx_fsmc.c
343 ifeq ($(TARGET
),$(filter $(TARGET
), $(F446_TARGETS
)))
344 EXCLUDES
+= stm32f4xx_fsmc.c
347 STDPERIPH_SRC
:= $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC
))
350 USBCORE_DIR
= $(ROOT
)/lib
/main
/STM32_USB_Device_Library
/Core
351 USBCORE_SRC
= $(notdir $(wildcard $(USBCORE_DIR
)/src
/*.c
))
352 USBOTG_DIR
= $(ROOT
)/lib
/main
/STM32_USB_OTG_Driver
353 USBOTG_SRC
= $(notdir $(wildcard $(USBOTG_DIR
)/src
/*.c
))
354 EXCLUDES
= usb_bsp_template.c \
355 usb_conf_template.c \
360 USBOTG_SRC
:= $(filter-out ${EXCLUDES}, $(USBOTG_SRC
))
361 USBCDC_DIR
= $(ROOT
)/lib
/main
/STM32_USB_Device_Library
/Class
/cdc
362 USBCDC_SRC
= $(notdir $(wildcard $(USBCDC_DIR
)/src
/*.c
))
363 EXCLUDES
= usbd_cdc_if_template.c
364 USBCDC_SRC
:= $(filter-out ${EXCLUDES}, $(USBCDC_SRC
))
365 VPATH
:= $(VPATH
):$(USBOTG_DIR
)/src
:$(USBCORE_DIR
)/src
:$(USBCDC_DIR
)/src
367 DEVICE_STDPERIPH_SRC
:= $(STDPERIPH_SRC
) \
373 VPATH
:= $(VPATH
):$(CMSIS_DIR
)/CM4
/CoreSupport
:$(CMSIS_DIR
)/CM4
/DeviceSupport
/ST
/STM32F4xx
374 CMSIS_SRC
= $(notdir $(wildcard $(CMSIS_DIR
)/CM4
/CoreSupport
/*.c \
375 $(CMSIS_DIR
)/CM4
/DeviceSupport
/ST
/STM32F4xx
/*.c
))
376 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
377 $(STDPERIPH_DIR
)/inc \
382 $(CMSIS_DIR
)/CM4
/CoreSupport \
383 $(CMSIS_DIR
)/CM4
/DeviceSupport
/ST
/STM32F4xx \
384 $(ROOT
)/src
/main
/vcpf4
386 ifneq ($(filter SDCARD
,$(FEATURES
)),)
387 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
389 VPATH
:= $(VPATH
):$(FATFS_DIR
)
393 ARCH_FLAGS
= -mthumb
-mcpu
=cortex-m4
-march
=armv7e-m
-mfloat-abi
=hard
-mfpu
=fpv4-sp-d16
-fsingle-precision-constant
-Wdouble-promotion
395 ifeq ($(TARGET
),$(filter $(TARGET
),$(F411_TARGETS
)))
396 DEVICE_FLAGS
= -DSTM32F411xE
397 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f411.
ld
398 STARTUP_SRC
= startup_stm32f411xe.s
399 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F405_TARGETS
)))
400 DEVICE_FLAGS
= -DSTM32F40_41xxx
401 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f405.
ld
402 STARTUP_SRC
= startup_stm32f40xx.s
403 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F446_TARGETS
)))
404 DEVICE_FLAGS
= -DSTM32F446xx
405 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f446.
ld
406 STARTUP_SRC
= startup_stm32f446xx.s
408 $(error Unknown MCU for F4 target
)
410 DEVICE_FLAGS
+= -DHSE_VALUE
=$(HSE_VALUE
)
415 else ifeq ($(TARGET
),$(filter $(TARGET
), $(F7_TARGETS
)))
418 STDPERIPH_DIR
= $(ROOT
)/lib
/main
/STM32F7xx_HAL_Driver
419 STDPERIPH_SRC
= $(notdir $(wildcard $(STDPERIPH_DIR
)/Src
/*.c
))
420 EXCLUDES
= stm32f7xx_hal_can.c \
421 stm32f7xx_hal_cec.c \
422 stm32f7xx_hal_crc.c \
423 stm32f7xx_hal_crc_ex.c \
424 stm32f7xx_hal_cryp.c \
425 stm32f7xx_hal_cryp_ex.c \
426 stm32f7xx_hal_dac.c \
427 stm32f7xx_hal_dac_ex.c \
428 stm32f7xx_hal_dcmi.c \
429 stm32f7xx_hal_dcmi_ex.c \
430 stm32f7xx_hal_dfsdm.c \
431 stm32f7xx_hal_dma2d.c \
432 stm32f7xx_hal_dsi.c \
433 stm32f7xx_hal_eth.c \
434 stm32f7xx_hal_hash.c \
435 stm32f7xx_hal_hash_ex.c \
436 stm32f7xx_hal_hcd.c \
437 stm32f7xx_hal_i2s.c \
438 stm32f7xx_hal_irda.c \
439 stm32f7xx_hal_iwdg.c \
440 stm32f7xx_hal_jpeg.c \
441 stm32f7xx_hal_lptim.c \
442 stm32f7xx_hal_ltdc.c \
443 stm32f7xx_hal_ltdc_ex.c \
444 stm32f7xx_hal_mdios.c \
445 stm32f7xx_hal_mmc.c \
446 stm32f7xx_hal_msp_template.c \
447 stm32f7xx_hal_nand.c \
448 stm32f7xx_hal_nor.c \
449 stm32f7xx_hal_qspi.c \
450 stm32f7xx_hal_rng.c \
451 stm32f7xx_hal_rtc.c \
452 stm32f7xx_hal_rtc_ex.c \
453 stm32f7xx_hal_sai.c \
454 stm32f7xx_hal_sai_ex.c \
456 stm32f7xx_hal_sdram.c \
457 stm32f7xx_hal_smartcard.c \
458 stm32f7xx_hal_smartcard_ex.c \
459 stm32f7xx_hal_smbus.c \
460 stm32f7xx_hal_spdifrx.c \
461 stm32f7xx_hal_sram.c \
462 stm32f7xx_hal_timebase_rtc_alarm_template.c \
463 stm32f7xx_hal_timebase_rtc_wakeup_template.c \
464 stm32f7xx_hal_timebase_tim_template.c \
465 stm32f7xx_hal_wwdg.c \
470 stm32f7xx_ll_dma2d.c \
471 stm32f7xx_ll_exti.c \
473 stm32f7xx_ll_gpio.c \
475 stm32f7xx_ll_lptim.c \
480 stm32f7xx_ll_sdmmc.c \
483 stm32f7xx_ll_usart.c \
486 STDPERIPH_SRC
:= $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC
))
489 USBCORE_DIR
= $(ROOT
)/lib
/main
/Middlewares
/ST
/STM32_USB_Device_Library
/Core
490 USBCORE_SRC
= $(notdir $(wildcard $(USBCORE_DIR
)/Src
/*.c
))
491 EXCLUDES
= usbd_conf_template.c
492 USBCORE_SRC
:= $(filter-out ${EXCLUDES}, $(USBCORE_SRC
))
494 USBCDC_DIR
= $(ROOT
)/lib
/main
/Middlewares
/ST
/STM32_USB_Device_Library
/Class
/CDC
495 USBCDC_SRC
= $(notdir $(wildcard $(USBCDC_DIR
)/Src
/*.c
))
496 EXCLUDES
= usbd_cdc_if_template.c
497 USBCDC_SRC
:= $(filter-out ${EXCLUDES}, $(USBCDC_SRC
))
499 VPATH
:= $(VPATH
):$(USBCDC_DIR
)/Src
:$(USBCORE_DIR
)/Src
501 DEVICE_STDPERIPH_SRC
:= $(STDPERIPH_SRC
) \
506 VPATH
:= $(VPATH
):$(CMSIS_DIR
)/CM7
/Include
:$(CMSIS_DIR
)/CM7
/Device
/ST
/STM32F7xx
507 VPATH
:= $(VPATH
):$(STDPERIPH_DIR
)/Src
508 CMSIS_SRC
= $(notdir $(wildcard $(CMSIS_DIR
)/CM7
/Include
/*.c \
509 $(CMSIS_DIR
)/CM7
/Device
/ST
/STM32F7xx
/*.c
))
510 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
511 $(STDPERIPH_DIR
)/Inc \
514 $(CMSIS_DIR
)/CM7
/Include \
515 $(CMSIS_DIR
)/CM7
/Device
/ST
/STM32F7xx
/Include \
516 $(ROOT
)/src
/main
/vcp_hal
518 ifneq ($(filter SDCARD
,$(FEATURES
)),)
519 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
521 VPATH
:= $(VPATH
):$(FATFS_DIR
)
525 ARCH_FLAGS
= -mthumb
-mcpu
=cortex-m7
-mfloat-abi
=hard
-mfpu
=fpv5-sp-d16
-fsingle-precision-constant
-Wdouble-promotion
527 ifeq ($(TARGET
),$(filter $(TARGET
),$(F7X5XG_TARGETS
)))
528 DEVICE_FLAGS
= -DSTM32F745xx
-DUSE_HAL_DRIVER
-D__FPU_PRESENT
529 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f745.
ld
530 STARTUP_SRC
= startup_stm32f745xx.s
531 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F7X6XG_TARGETS
)))
532 DEVICE_FLAGS
= -DSTM32F746xx
-DUSE_HAL_DRIVER
-D__FPU_PRESENT
533 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f746.
ld
534 STARTUP_SRC
= startup_stm32f746xx.s
535 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F7X2RE_TARGETS
)))
536 DEVICE_FLAGS
= -DSTM32F722xx
-DUSE_HAL_DRIVER
-D__FPU_PRESENT
537 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f722.
ld
538 STARTUP_SRC
= startup_stm32f722xx.s
540 $(error Unknown MCU for F7 target
)
542 DEVICE_FLAGS
+= -DHSE_VALUE
=$(HSE_VALUE
)
544 TARGET_FLAGS
= -D
$(TARGET
)
549 else ifeq ($(TARGET
),$(filter $(TARGET
), $(SITL_TARGETS
)))
551 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
552 $(ROOT
)/lib
/main
/dyad
554 SITL_SRC
:= $(ROOT
)/lib
/main
/dyad
/dyad.c
559 LD_SCRIPT
= src
/main
/target
/SITL
/parameter_group.
ld
562 TARGET_FLAGS
= -D
$(TARGET
)
571 STDPERIPH_DIR
= $(ROOT
)/lib
/main
/STM32F10x_StdPeriph_Driver
572 STDPERIPH_SRC
= $(notdir $(wildcard $(STDPERIPH_DIR
)/src
/*.c
))
573 EXCLUDES
= stm32f10x_crc.c \
576 STARTUP_SRC
= startup_stm32f10x_md_gcc.S
577 STDPERIPH_SRC
:= $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC
))
579 # Search path and source files for the CMSIS sources
580 VPATH
:= $(VPATH
):$(CMSIS_DIR
)/CM3
/CoreSupport
:$(CMSIS_DIR
)/CM3
/DeviceSupport
/ST
/STM32F10x
581 CMSIS_SRC
= $(notdir $(wildcard $(CMSIS_DIR
)/CM3
/CoreSupport
/*.c \
582 $(CMSIS_DIR
)/CM3
/DeviceSupport
/ST
/STM32F10x
/*.c
))
584 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
585 $(STDPERIPH_DIR
)/inc \
586 $(CMSIS_DIR
)/CM3
/CoreSupport \
587 $(CMSIS_DIR
)/CM3
/DeviceSupport
/ST
/STM32F10x
589 DEVICE_STDPERIPH_SRC
= $(STDPERIPH_SRC
)
591 ifneq ($(filter VCP
, $(FEATURES
)),)
592 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
596 VPATH
:= $(VPATH
):$(USBFS_DIR
)/src
598 DEVICE_STDPERIPH_SRC
:= $(DEVICE_STDPERIPH_SRC
) \
603 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f103_
$(FLASH_SIZE
)k.
ld
604 ARCH_FLAGS
= -mthumb
-mcpu
=cortex-m3
606 ifeq ($(DEVICE_FLAGS
),)
607 DEVICE_FLAGS
= -DSTM32F10X_MD
609 DEVICE_FLAGS
+= -DSTM32F10X
615 ifneq ($(BASE_TARGET
), $(TARGET
))
616 TARGET_FLAGS
:= $(TARGET_FLAGS
) -D
$(BASE_TARGET
)
619 ifneq ($(FLASH_SIZE
),)
620 DEVICE_FLAGS
:= $(DEVICE_FLAGS
) -DFLASH_SIZE
=$(FLASH_SIZE
)
623 ifneq ($(HSE_VALUE
),)
624 DEVICE_FLAGS
:= $(DEVICE_FLAGS
) -DHSE_VALUE
=$(HSE_VALUE
)
627 TARGET_DIR
= $(ROOT
)/src
/main
/target
/$(BASE_TARGET
)
628 TARGET_DIR_SRC
= $(notdir $(wildcard $(TARGET_DIR
)/*.c
))
631 TARGET_FLAGS
:= -DOPBL
$(TARGET_FLAGS
)
632 ifeq ($(TARGET
), $(filter $(TARGET
),$(F405_TARGETS
)))
633 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f405_opbl.
ld
634 else ifeq ($(TARGET
), $(filter $(TARGET
),$(F411_TARGETS
)))
635 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f411_opbl.
ld
636 else ifeq ($(TARGET
), $(filter $(TARGET
),$(F3_TARGETS
)))
637 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f303_
$(FLASH_SIZE
)k_opbl.
ld
638 else ifeq ($(TARGET
), $(filter $(TARGET
),$(F1_TARGETS
)))
639 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f103_
$(FLASH_SIZE
)k_opbl.
ld
641 .DEFAULT_GOAL
:= binary
646 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
647 $(ROOT
)/lib
/main
/MAVLink
649 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
652 VPATH
:= $(VPATH
):$(TARGET_DIR
)
655 build
/build_config.c \
665 common
/typeconversion.c \
666 config
/config_eeprom.c \
668 config
/parameter_group.c \
669 config
/config_streamer.c \
671 drivers
/buf_writer.c \
672 drivers
/bus_i2c_soft.c \
674 drivers
/bus_spi_soft.c \
679 drivers
/light_led.c \
683 drivers
/serial_uart.c \
684 drivers
/sound_beeper.c \
685 drivers
/stack_check.c \
688 drivers
/transponder_ir.c \
694 fc/runtime_config.c \
697 io
/statusindicator.c \
698 io
/transponder_ir.c \
700 scheduler
/scheduler.c \
706 io
/displayport_max7456.c \
707 osd_slave
/osd_slave_init.c \
712 fc/controlrate_profile.c \
713 drivers
/gyro_sync.c \
714 drivers
/rx_nrf24l01.c \
717 drivers
/pwm_esc_detect.c \
718 drivers
/pwm_output.c \
720 drivers
/serial_softserial.c \
723 fc/rc_adjustments.c \
734 io
/serial_4way_avrootloader.c \
735 io
/serial_4way_stk500v2.c \
753 sensors
/acceleration.c \
754 sensors
/boardalignment.c \
757 sensors
/gyroanalyse.c \
758 sensors
/initialisation.c \
759 blackbox
/blackbox.c \
760 blackbox
/blackbox_encoding.c \
761 blackbox
/blackbox_io.c \
763 cms
/cms_menu_blackbox.c \
764 cms
/cms_menu_builtin.c \
766 cms
/cms_menu_ledstrip.c \
767 cms
/cms_menu_misc.c \
769 common
/colorconversion.c \
770 common
/gps_conversion.c \
771 drivers
/display_ug2864hsweg01.c \
772 drivers
/light_ws2811strip.c \
773 drivers
/serial_escserial.c \
774 drivers
/sonar_hcsr04.c \
775 drivers
/vtx_common.c \
776 drivers
/transponder_ir.c \
777 flight
/navigation.c \
779 io
/displayport_max7456.c \
780 io
/displayport_msp.c \
781 io
/displayport_oled.c \
786 sensors
/barometer.c \
787 telemetry
/telemetry.c \
792 telemetry
/smartport.c \
794 telemetry
/mavlink.c \
796 telemetry
/ibus_shared.c \
797 sensors
/esc_sensor.c \
800 io
/vtx_smartaudio.c \
804 COMMON_DEVICE_SRC
= \
806 $(DEVICE_STDPERIPH_SRC
)
808 ifeq ($(OSD_SLAVE
),yes
)
809 TARGET_FLAGS
:= -DUSE_OSD_SLAVE
$(TARGET_FLAGS
)
810 COMMON_SRC
:= $(COMMON_SRC
) $(OSD_SLAVE_SRC
) $(COMMON_DEVICE_SRC
)
812 COMMON_SRC
:= $(COMMON_SRC
) $(FC_SRC
) $(COMMON_DEVICE_SRC
)
816 SPEED_OPTIMISED_SRC
:= ""
817 SIZE_OPTIMISED_SRC
:= ""
819 ifneq ($(TARGET
),$(filter $(TARGET
),$(F1_TARGETS
)))
820 SPEED_OPTIMISED_SRC
:= $(SPEED_OPTIMISED_SRC
) \
824 common
/typeconversion.c \
826 drivers
/buf_writer.c \
827 drivers
/bus_i2c_soft.c \
829 drivers
/bus_spi_soft.c \
831 drivers
/gyro_sync.c \
833 drivers
/light_led.c \
835 drivers
/rx_nrf24l01.c \
838 drivers
/pwm_output.c \
842 drivers
/serial_uart.c \
843 drivers
/sound_beeper.c \
850 fc/runtime_config.c \
872 scheduler
/scheduler.c \
873 sensors
/acceleration.c \
874 sensors
/boardalignment.c \
876 sensors
/gyroanalyse.c \
878 $(DEVICE_STDPERIPH_SRC
) \
879 drivers
/display_ug2864hsweg01.c \
880 drivers
/light_ws2811strip.c \
881 drivers
/serial_softserial.c \
883 io
/displayport_max7456.c \
887 SIZE_OPTIMISED_SRC
:= $(SIZE_OPTIMISED_SRC
) \
888 drivers
/serial_escserial.c \
889 drivers
/vtx_common.c \
893 config
/config_eeprom.c \
895 config
/parameter_group.c \
896 config
/config_streamer.c \
898 io
/serial_4way_avrootloader.c \
899 io
/serial_4way_stk500v2.c \
902 cms
/cms_menu_blackbox.c \
903 cms
/cms_menu_builtin.c \
905 cms
/cms_menu_ledstrip.c \
906 cms
/cms_menu_misc.c \
909 io
/vtx_smartaudio.c \
913 ifeq ($(TARGET
),$(filter $(TARGET
),$(F4_TARGETS
)))
915 vcpf4
/stm32f4xx_it.c \
919 vcpf4
/usbd_cdc_vcp.c \
920 drivers
/serial_usb_vcp.c \
922 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F7_TARGETS
)))
924 vcp_hal
/usbd_desc.c \
925 vcp_hal
/usbd_conf.c \
926 vcp_hal
/usbd_cdc_interface.c \
927 drivers
/serial_usb_vcp.c \
938 drivers
/serial_usb_vcp.c \
942 STM32F10x_COMMON_SRC
= \
943 drivers
/adc_stm32f10x.c \
944 drivers
/bus_i2c_stm32f10x.c \
946 drivers
/gpio_stm32f10x.c \
948 drivers
/light_ws2811strip_stdperiph.c \
949 drivers
/serial_uart_stm32f10x.c \
950 drivers
/system_stm32f10x.c \
951 drivers
/timer_stm32f10x.c
953 STM32F30x_COMMON_SRC
= \
954 target
/system_stm32f30x.c \
955 drivers
/adc_stm32f30x.c \
956 drivers
/bus_i2c_stm32f30x.c \
958 drivers
/gpio_stm32f30x.c \
959 drivers
/light_ws2811strip_stdperiph.c \
960 drivers
/pwm_output_dshot.c \
961 drivers
/serial_uart_stm32f30x.c \
962 drivers
/system_stm32f30x.c \
963 drivers
/timer_stm32f30x.c
965 STM32F4xx_COMMON_SRC
= \
966 target
/system_stm32f4xx.c \
967 drivers
/accgyro
/accgyro_mpu.c \
968 drivers
/adc_stm32f4xx.c \
969 drivers
/bus_i2c_stm32f10x.c \
970 drivers
/dma_stm32f4xx.c \
971 drivers
/gpio_stm32f4xx.c \
973 drivers
/light_ws2811strip_stdperiph.c \
974 drivers
/pwm_output_dshot.c \
975 drivers
/serial_uart_stm32f4xx.c \
976 drivers
/system_stm32f4xx.c \
977 drivers
/timer_stm32f4xx.c
979 STM32F7xx_COMMON_SRC
= \
980 target
/system_stm32f7xx.c \
981 drivers
/accgyro
/accgyro_mpu.c \
982 drivers
/adc_stm32f7xx.c \
983 drivers
/bus_i2c_hal.c \
984 drivers
/dma_stm32f7xx.c \
985 drivers
/gpio_stm32f7xx.c \
986 drivers
/light_ws2811strip_hal.c \
987 drivers
/bus_spi_hal.c \
988 drivers
/pwm_output_dshot_hal.c \
989 drivers
/timer_hal.c \
990 drivers
/timer_stm32f7xx.c \
991 drivers
/system_stm32f7xx.c \
992 drivers
/serial_uart_stm32f7xx.c \
993 drivers
/serial_uart_hal.c
995 F7EXCLUDES
= drivers
/bus_spi.c \
998 drivers
/serial_uart.c
1005 drivers
/pwm_output.c \
1007 drivers
/light_led.c \
1010 drivers
/serial_uart.c \
1011 drivers
/rx_xn297.c \
1012 drivers
/display_ug2864hsweg01.c \
1015 io
/displayport_oled.c
1018 # check if target.mk supplied
1019 ifeq ($(TARGET
),$(filter $(TARGET
),$(F4_TARGETS
)))
1020 SRC
:= $(STARTUP_SRC
) $(STM32F4xx_COMMON_SRC
) $(TARGET_SRC
) $(VARIANT_SRC
)
1021 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F7_TARGETS
)))
1022 SRC
:= $(STARTUP_SRC
) $(STM32F7xx_COMMON_SRC
) $(TARGET_SRC
) $(VARIANT_SRC
)
1023 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F3_TARGETS
)))
1024 SRC
:= $(STARTUP_SRC
) $(STM32F30x_COMMON_SRC
) $(TARGET_SRC
) $(VARIANT_SRC
)
1025 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F1_TARGETS
)))
1026 SRC
:= $(STARTUP_SRC
) $(STM32F10x_COMMON_SRC
) $(TARGET_SRC
) $(VARIANT_SRC
)
1027 else ifeq ($(TARGET
),$(filter $(TARGET
),$(SITL_TARGETS
)))
1028 SRC
:= $(TARGET_SRC
) $(SITL_SRC
) $(VARIANT_SRC
)
1031 ifneq ($(filter $(TARGET
),$(F3_TARGETS
) $(F4_TARGETS
) $(F7_TARGETS
)),)
1032 DSPLIB
:= $(ROOT
)/lib
/main
/DSP_Lib
1033 DEVICE_FLAGS
+= -DARM_MATH_MATRIX_CHECK
-DARM_MATH_ROUNDING
-D__FPU_PRESENT
=1 -DUNALIGNED_SUPPORT_DISABLE
1035 ifneq ($(filter $(TARGET
),$(F3_TARGETS
)) $(F4_TARGETS
)),)
1036 DEVICE_FLAGS
+= -DARM_MATH_CM4
1038 ifneq ($(filter $(TARGET
),$(F7_TARGETS
)),)
1039 DEVICE_FLAGS
+= -DARM_MATH_CM7
1042 INCLUDE_DIRS
+= $(DSPLIB
)/Include
1044 SRC
+= $(DSPLIB
)/Source
/BasicMathFunctions
/arm_mult_f32.c
1045 SRC
+= $(DSPLIB
)/Source
/TransformFunctions
/arm_rfft_fast_f32.c
1046 SRC
+= $(DSPLIB
)/Source
/TransformFunctions
/arm_cfft_f32.c
1047 SRC
+= $(DSPLIB
)/Source
/TransformFunctions
/arm_rfft_fast_init_f32.c
1048 SRC
+= $(DSPLIB
)/Source
/TransformFunctions
/arm_cfft_radix8_f32.c
1049 SRC
+= $(DSPLIB
)/Source
/CommonTables
/arm_common_tables.c
1051 SRC
+= $(DSPLIB
)/Source
/ComplexMathFunctions
/arm_cmplx_mag_f32.c
1052 SRC
+= $(DSPLIB
)/Source
/StatisticsFunctions
/arm_max_f32.c
1054 SRC
+= $(wildcard $(DSPLIB
)/Source
/*/*.S
)
1059 ifneq ($(filter ONBOARDFLASH
,$(FEATURES
)),)
1061 drivers
/flash_m25p16.c \
1065 SRC
+= $(COMMON_SRC
)
1068 ifeq ($(TARGET
),$(filter $(TARGET
),$(F7_TARGETS
)))
1069 SRC
:= $(filter-out ${F7EXCLUDES}, $(SRC
))
1073 ifeq ($(TARGET
),$(filter $(TARGET
),$(SITL_TARGETS
)))
1074 SRC
:= $(filter-out ${SITLEXCLUDES}, $(SRC
))
1077 ifneq ($(filter SDCARD
,$(FEATURES
)),)
1080 drivers
/sdcard_standard.c \
1081 io
/asyncfatfs
/asyncfatfs.c \
1082 io
/asyncfatfs
/fat_standard.c
1085 ifneq ($(filter VCP
,$(FEATURES
)),)
1088 # end target specific make file checks
1091 # Search path and source files for the ST stdperiph library
1092 VPATH
:= $(VPATH
):$(STDPERIPH_DIR
)/src
1094 ###############################################################################
1095 # Things that might need changing to use different tools
1098 # Find out if ccache is installed on the system
1100 RESULT
= $(shell (which
$(CCACHE
) > /dev
/null
2>&1; echo
$$?
) )
1106 CROSS_CC
:= $(CCACHE
) $(ARM_SDK_PREFIX
)gcc
1107 CROSS_CXX
:= $(CCACHE
) $(ARM_SDK_PREFIX
)g
++
1108 OBJCOPY
:= $(ARM_SDK_PREFIX
)objcopy
1109 SIZE
:= $(ARM_SDK_PREFIX
)size
1115 ifneq ($(DEBUG
),GDB
)
1116 OPTIMISATION_BASE
:= -flto
-fuse-linker-plugin
-ffast-math
1117 OPTIMISE_SPEED
:= ""
1120 ifeq ($(TARGET
),$(filter $(TARGET
),$(F1_TARGETS
)))
1121 OPTIMISE_DEFAULT
:= -Os
1123 LTO_FLAGS
:= $(OPTIMISATION_BASE
) $(OPTIMISE_DEFAULT
)
1125 else ifeq ($(TARGET
),$(filter $(TARGET
),$(SITL_TARGETS
)))
1126 OPTIMISE_DEFAULT
:= -Ofast
1127 OPTIMISE_SPEED
:= -Ofast
1128 OPTIMISE_SIZE
:= -Os
1130 LTO_FLAGS
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SPEED
)
1133 OPTIMISE_DEFAULT
:= -O2
1134 OPTIMISE_SPEED
:= -Ofast
1135 OPTIMISE_SIZE
:= -Os
1137 LTO_FLAGS
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SPEED
)
1141 CC_DEFAULT_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_DEFAULT
)
1142 CC_SPEED_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SPEED
)
1143 CC_SIZE_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SIZE
)
1146 OPTIMISE_DEFAULT
:= -Og
1148 CC_DEBUG_OPTIMISATION
:= $(OPTIMISE_DEFAULT
)
1150 LTO_FLAGS
:= $(OPTIMISE_DEFAULT
)
1153 DEBUG_FLAGS
= -ggdb3
-DDEBUG
1155 CFLAGS
+= $(ARCH_FLAGS
) \
1156 $(addprefix -D
,$(OPTIONS
)) \
1157 $(addprefix -I
,$(INCLUDE_DIRS
)) \
1160 -Wall
-Wextra
-Wunsafe-loop-optimizations
-Wdouble-promotion \
1161 -ffunction-sections \
1165 -DUSE_STDPERIPH_DRIVER \
1168 -D
'__FORKNAME__="$(FORKNAME)"' \
1169 -D
'__TARGET__="$(TARGET)"' \
1170 -D
'__REVISION__="$(REVISION)"' \
1176 ASFLAGS
= $(ARCH_FLAGS
) \
1177 -x assembler-with-cpp \
1178 $(addprefix -I
,$(INCLUDE_DIRS
)) \
1183 --specs
=nano.specs \
1190 -Wl
,-gc-sections
,-Map
,$(TARGET_MAP
) \
1191 -Wl
,-L
$(LINKER_DIR
) \
1193 -Wl
,--no-wchar-size-warning \
1197 ifeq ($(TARGET
),$(filter $(TARGET
),$(SITL_TARGETS
)))
1206 -Wl
,-gc-sections
,-Map
,$(TARGET_MAP
) \
1207 -Wl
,-L
$(LINKER_DIR
) \
1211 ifneq ($(filter SITL_STATIC
,$(OPTIONS
)),)
1218 ###############################################################################
1219 # No user-serviceable parts below
1220 ###############################################################################
1222 CPPCHECK
= cppcheck
$(CSOURCES
) --enable
=all --platform
=unix64 \
1223 --std
=c99
--inline-suppr
--quiet
--force \
1224 $(addprefix -I
,$(INCLUDE_DIRS
)) \
1225 -I
/usr
/include -I
/usr
/include/linux
1228 # Things we will build
1230 TARGET_BIN
= $(BIN_DIR
)/$(FORKNAME
)_
$(FC_VER
)_
$(TARGET
).bin
1231 TARGET_HEX
= $(BIN_DIR
)/$(FORKNAME
)_
$(FC_VER
)_
$(TARGET
).hex
1232 TARGET_ELF
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).elf
1233 TARGET_OBJS
= $(addsuffix .o
,$(addprefix $(OBJECT_DIR
)/$(TARGET
)/,$(basename $(SRC
))))
1234 TARGET_DEPS
= $(addsuffix .d
,$(addprefix $(OBJECT_DIR
)/$(TARGET
)/,$(basename $(SRC
))))
1235 TARGET_MAP
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).map
1238 CLEAN_ARTIFACTS
:= $(TARGET_BIN
)
1239 CLEAN_ARTIFACTS
+= $(TARGET_HEX
)
1240 CLEAN_ARTIFACTS
+= $(TARGET_ELF
) $(TARGET_OBJS
) $(TARGET_MAP
)
1242 # Make sure build date and revision is updated on every incremental build
1243 $(OBJECT_DIR
)/$(TARGET
)/build
/version.o
: $(SRC
)
1245 # List of buildable ELF files and their object dependencies.
1246 # It would be nice to compute these lists, but that seems to be just beyond make.
1248 $(TARGET_HEX
): $(TARGET_ELF
)
1249 $(V0
) $(OBJCOPY
) -O ihex
--set-start
0x8000000 $< $@
1251 $(TARGET_BIN
): $(TARGET_ELF
)
1252 $(V0
) $(OBJCOPY
) -O binary
$< $@
1254 $(TARGET_ELF
): $(TARGET_OBJS
)
1255 $(V1
) echo Linking
$(TARGET
)
1256 $(V1
) $(CROSS_CC
) -o
$@
$^
$(LDFLAGS
)
1257 $(V0
) $(SIZE
) $(TARGET_ELF
)
1260 ifneq ($(DEBUG
),GDB
)
1261 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.c
1262 $(V1
) mkdir
-p
$(dir $@
)
1263 $(V1
) $(if
$(findstring $(subst .
/src
/main
/,,$<),$(SPEED_OPTIMISED_SRC
)), \
1264 echo
"%% (speed optimised) $(notdir $<)" "$(STDOUT)" && \
1265 $(CROSS_CC
) -c
-o
$@
$(CFLAGS
) $(CC_SPEED_OPTIMISATION
) $<, \
1266 $(if
$(findstring $(subst .
/src
/main
/,,$<),$(SIZE_OPTIMISED_SRC
)), \
1267 echo
"%% (size optimised) $(notdir $<)" "$(STDOUT)" && \
1268 $(CROSS_CC
) -c
-o
$@
$(CFLAGS
) $(CC_SIZE_OPTIMISATION
) $<, \
1269 echo
"%% $(notdir $<)" "$(STDOUT)" && \
1270 $(CROSS_CC
) -c
-o
$@
$(CFLAGS
) $(CC_DEFAULT_OPTIMISATION
) $<))
1272 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.c
1273 $(V1
) mkdir
-p
$(dir $@
)
1274 $(V1
) echo
"%% $(notdir $<)" "$(STDOUT)" && \
1275 $(CROSS_CC
) -c
-o
$@
$(CFLAGS
) $(CC_DEBUG_OPTIMISATION
) $<
1279 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.s
1280 $(V1
) mkdir
-p
$(dir $@
)
1281 $(V1
) echo
"%% $(notdir $<)" "$(STDOUT)"
1282 $(V1
) $(CROSS_CC
) -c
-o
$@
$(ASFLAGS
) $<
1284 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.S
1285 $(V1
) mkdir
-p
$(dir $@
)
1286 $(V1
) echo
"%% $(notdir $<)" "$(STDOUT)"
1287 $(V1
) $(CROSS_CC
) -c
-o
$@
$(ASFLAGS
) $<
1290 ## all : Build all valid targets
1291 all: $(VALID_TARGETS
)
1293 ## official : Build all official (travis) targets
1294 official
: $(OFFICIAL_TARGETS
)
1296 ## targets-group-1 : build some targets
1297 targets-group-1
: $(GROUP_1_TARGETS
)
1299 ## targets-group-2 : build some targets
1300 targets-group-2
: $(GROUP_2_TARGETS
)
1302 ## targets-group-3 : build some targets
1303 targets-group-3
: $(GROUP_3_TARGETS
)
1305 ## targets-group-3 : build some targets
1306 targets-group-4
: $(GROUP_4_TARGETS
)
1308 ## targets-group-rest: build the rest of the targets (not listed in group 1, 2 or 3)
1309 targets-group-rest
: $(GROUP_OTHER_TARGETS
)
1314 echo
"Building $@" && \
1315 time
$(MAKE
) binary hex TARGET
=$@
&& \
1316 echo
"Building $@ succeeded."
1320 CLEAN_TARGETS
= $(addprefix clean_
,$(VALID_TARGETS
) )
1321 TARGETS_CLEAN
= $(addsuffix _clean
,$(VALID_TARGETS
) )
1323 ## clean : clean up temporary / machine-generated files
1325 $(V0
) echo
"Cleaning $(TARGET)"
1326 $(V0
) rm -f
$(CLEAN_ARTIFACTS
)
1327 $(V0
) rm -rf
$(OBJECT_DIR
)/$(TARGET
)
1328 $(V0
) echo
"Cleaning $(TARGET) succeeded."
1330 ## clean_test : clean up temporary / machine-generated files (tests)
1332 $(V0
) cd src
/test && $(MAKE
) clean || true
1334 ## clean_<TARGET> : clean up one specific target
1336 $(V0
) $(MAKE
) -j TARGET
=$(subst clean_
,,$@
) clean
1338 ## <TARGET>_clean : clean up one specific target (alias for above)
1340 $(V0
) $(MAKE
) -j TARGET
=$(subst _clean
,,$@
) clean
1342 ## clean_all : clean all valid targets
1343 clean_all
:$(CLEAN_TARGETS
)
1345 ## all_clean : clean all valid targets (alias for above)
1346 all_clean
:$(TARGETS_CLEAN
)
1349 flash_
$(TARGET
): $(TARGET_HEX
)
1350 $(V0
) stty
-F
$(SERIAL_DEVICE
) raw speed
115200 -crtscts cs8
-parenb
-cstopb
-ixon
1351 $(V0
) echo
-n
'R' >$(SERIAL_DEVICE
)
1352 $(V0
) stm32flash
-w
$(TARGET_HEX
) -v
-g
0x0 -b
115200 $(SERIAL_DEVICE
)
1354 ## flash : flash firmware (.hex) onto flight controller
1355 flash
: flash_
$(TARGET
)
1357 st-flash_
$(TARGET
): $(TARGET_BIN
)
1358 $(V0
) st-flash
--reset write
$< 0x08000000
1360 ## st-flash : flash firmware (.bin) onto flight controller
1361 st-flash
: st-flash_
$(TARGET
)
1364 $(V0
) $(MAKE
) -j
$(TARGET_BIN
)
1367 $(V0
) $(MAKE
) -j
$(TARGET_HEX
)
1369 unbrick_
$(TARGET
): $(TARGET_HEX
)
1370 $(V0
) stty
-F
$(SERIAL_DEVICE
) raw speed
115200 -crtscts cs8
-parenb
-cstopb
-ixon
1371 $(V0
) stm32flash
-w
$(TARGET_HEX
) -v
-g
0x0 -b
115200 $(SERIAL_DEVICE
)
1373 ## unbrick : unbrick flight controller
1374 unbrick
: unbrick_
$(TARGET
)
1376 ## cppcheck : run static analysis on C source code
1377 cppcheck
: $(CSOURCES
)
1380 cppcheck-result.xml
: $(CSOURCES
)
1381 $(V0
) $(CPPCHECK
) --xml-version
=2 2> cppcheck-result.xml
1393 ## version : print firmware version
1397 ## help : print this help message and exit
1398 help
: Makefile make
/tools.mk
1400 $(V0
) @echo
"Makefile for the $(FORKNAME) firmware"
1402 $(V0
) @echo
"Usage:"
1403 $(V0
) @echo
" make [V=<verbosity>] [TARGET=<target>] [OPTIONS=\"<options>\"]"
1405 $(V0
) @echo
" make <target> [V=<verbosity>] [OPTIONS=\"<options>\"]"
1407 $(V0
) @echo
"Valid TARGET values are: $(VALID_TARGETS)"
1409 $(V0
) @sed
-n
's/^## //p' $?
1411 ## targets : print a list of all valid target platforms (for consumption by scripts)
1413 $(V0
) @echo
"Valid targets: $(VALID_TARGETS)"
1414 $(V0
) @echo
"Target: $(TARGET)"
1415 $(V0
) @echo
"Base target: $(BASE_TARGET)"
1416 $(V0
) @echo
"targets-group-1: $(GROUP_1_TARGETS)"
1417 $(V0
) @echo
"targets-group-2: $(GROUP_2_TARGETS)"
1418 $(V0
) @echo
"targets-group-3: $(GROUP_3_TARGETS)"
1419 $(V0
) @echo
"targets-group-4: $(GROUP_4_TARGETS)"
1420 $(V0
) @echo
"targets-group-rest: $(GROUP_OTHER_TARGETS)"
1422 ## test : run the cleanflight test suite
1423 ## junittest : run the cleanflight test suite, producing Junit XML result files.
1425 $(V0
) cd src
/test && $(MAKE
) $@
1427 # rebuild everything when makefile changes
1428 $(TARGET_OBJS
) : Makefile
1430 # include auto-generated dependencies
1431 -include $(TARGET_DEPS
)