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
))
187 GROUP_OTHER_TARGETS
:= $(filter-out $(GROUP_1_TARGETS
) $(GROUP_2_TARGETS
) $(GROUP_3_TARGETS
) $(GROUP_4_TARGETS
), $(VALID_TARGETS
))
190 ifeq ($(filter $(TARGET
),$(ALT_TARGETS
)), $(TARGET
))
191 BASE_TARGET
:= $(firstword $(subst /,, $(subst .
/src
/main
/target
/,, $(dir $(wildcard $(ROOT
)/src
/main
/target
/*/$(TARGET
).mk
)))))
192 -include $(ROOT
)/src
/main
/target
/$(BASE_TARGET
)/$(TARGET
).mk
194 BASE_TARGET
:= $(TARGET
)
197 ifeq ($(filter $(TARGET
),$(OPBL_TARGETS
)), $(TARGET
))
201 ifeq ($(filter $(TARGET
),$(OSD_SLAVE_TARGETS
)), $(TARGET
))
210 # silently ignore if the file is not present. Allows for target specific.
211 -include $(ROOT
)/src
/main
/target
/$(BASE_TARGET
)/target.mk
213 F4_TARGETS
= $(F405_TARGETS
) $(F411_TARGETS
) $(F446_TARGETS
)
214 F7_TARGETS
= $(F7X2RE_TARGETS
) $(F7X5XE_TARGETS
) $(F7X5XG_TARGETS
) $(F7X5XI_TARGETS
) $(F7X6XG_TARGETS
)
216 ifeq ($(filter $(TARGET
),$(VALID_TARGETS
)),)
217 $(error Target
'$(TARGET)' is not valid
, must be one of
$(VALID_TARGETS
). Have you prepared a valid target.mk?
)
220 ifeq ($(filter $(TARGET
),$(F1_TARGETS
) $(F3_TARGETS
) $(F4_TARGETS
) $(F7_TARGETS
) $(SITL_TARGETS
)),)
221 $(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?
)
224 128K_TARGETS
= $(F1_TARGETS
)
225 256K_TARGETS
= $(F3_TARGETS
)
226 512K_TARGETS
= $(F411_TARGETS
) $(F446_TARGETS
) $(F7X2RE_TARGETS
) $(F7X5XE_TARGETS
)
227 1024K_TARGETS
= $(F405_TARGETS
) $(F7X5XG_TARGETS
) $(F7X6XG_TARGETS
)
228 2048K_TARGETS
= $(F7X5XI_TARGETS
) $(SITL_TARGETS
)
230 # Configure default flash sizes for the targets (largest size specified gets hit first) if flash not specified already.
231 ifeq ($(FLASH_SIZE
),)
232 ifeq ($(TARGET
),$(filter $(TARGET
),$(2048K_TARGETS
)))
234 else ifeq ($(TARGET
),$(filter $(TARGET
),$(1024K_TARGETS
)))
236 else ifeq ($(TARGET
),$(filter $(TARGET
),$(512K_TARGETS
)))
238 else ifeq ($(TARGET
),$(filter $(TARGET
),$(256K_TARGETS
)))
240 else ifeq ($(TARGET
),$(filter $(TARGET
),$(128K_TARGETS
)))
243 $(error FLASH_SIZE not configured for target
$(TARGET
))
247 # note that there is no hardfault debugging startup file assembly handler for other platforms
248 ifeq ($(DEBUG_HARDFAULTS
),F3
)
249 CFLAGS
+= -DDEBUG_HARDFAULTS
250 STM32F30x_COMMON_SRC
= startup_stm32f3_debug_hardfault_handler.S
252 STM32F30x_COMMON_SRC
= startup_stm32f30x_md_gcc.S
255 ifeq ($(DEBUG_HARDFAULTS
),F7
)
256 CFLAGS
+= -DDEBUG_HARDFAULTS
259 REVISION
:= $(shell git log
-1 --format
="%h")
261 FC_VER_MAJOR
:= $(shell grep
" FC_VERSION_MAJOR" src
/main
/build
/version.h | awk
'{print $$3}' )
262 FC_VER_MINOR
:= $(shell grep
" FC_VERSION_MINOR" src
/main
/build
/version.h | awk
'{print $$3}' )
263 FC_VER_PATCH
:= $(shell grep
" FC_VERSION_PATCH" src
/main
/build
/version.h | awk
'{print $$3}' )
265 FC_VER
:= $(FC_VER_MAJOR
).
$(FC_VER_MINOR
).
$(FC_VER_PATCH
)
267 # Search path for sources
268 VPATH
:= $(SRC_DIR
):$(SRC_DIR
)/startup
269 USBFS_DIR
= $(ROOT
)/lib
/main
/STM32_USB-FS-Device_Driver
270 USBPERIPH_SRC
= $(notdir $(wildcard $(USBFS_DIR
)/src
/*.c
))
271 FATFS_DIR
= $(ROOT
)/lib
/main
/FatFS
272 FATFS_SRC
= $(notdir $(wildcard $(FATFS_DIR
)/*.c
))
274 CSOURCES
:= $(shell find
$(SRC_DIR
) -name
'*.c')
276 ifeq ($(TARGET
),$(filter $(TARGET
),$(F3_TARGETS
)))
279 STDPERIPH_DIR
= $(ROOT
)/lib
/main
/STM32F30x_StdPeriph_Driver
280 STDPERIPH_SRC
= $(notdir $(wildcard $(STDPERIPH_DIR
)/src
/*.c
))
281 EXCLUDES
= stm32f30x_crc.c \
283 STARTUP_SRC
= startup_stm32f30x_md_gcc.S
285 STDPERIPH_SRC
:= $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC
))
286 DEVICE_STDPERIPH_SRC
= $(STDPERIPH_SRC
)
288 VPATH
:= $(VPATH
):$(CMSIS_DIR
)/CM4
/CoreSupport
:$(CMSIS_DIR
)/CM4
/DeviceSupport
/ST
/STM32F30x
289 CMSIS_SRC
= $(notdir $(wildcard $(CMSIS_DIR
)/CM4
/CoreSupport
/*.c \
290 $(CMSIS_DIR
)/CM4
/DeviceSupport
/ST
/STM32F30x
/*.c
))
292 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
293 $(STDPERIPH_DIR
)/inc \
294 $(CMSIS_DIR
)/CM4
/CoreSupport \
295 $(CMSIS_DIR
)/CM4
/DeviceSupport
/ST
/STM32F30x
297 ifneq ($(filter VCP
, $(FEATURES
)),)
298 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
302 VPATH
:= $(VPATH
):$(USBFS_DIR
)/src
304 DEVICE_STDPERIPH_SRC
:= $(DEVICE_STDPERIPH_SRC
)\
308 ifneq ($(filter SDCARD
, $(FEATURES
)),)
309 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
312 VPATH
:= $(VPATH
):$(FATFS_DIR
)
315 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f303_
$(FLASH_SIZE
)k.
ld
317 ARCH_FLAGS
= -mthumb
-mcpu
=cortex-m4
-mfloat-abi
=hard
-mfpu
=fpv4-sp-d16
-fsingle-precision-constant
-Wdouble-promotion
318 DEVICE_FLAGS
= -DSTM32F303xC
-DSTM32F303
322 else ifeq ($(TARGET
),$(filter $(TARGET
), $(F4_TARGETS
)))
325 STDPERIPH_DIR
= $(ROOT
)/lib
/main
/STM32F4xx_StdPeriph_Driver
326 STDPERIPH_SRC
= $(notdir $(wildcard $(STDPERIPH_DIR
)/src
/*.c
))
327 EXCLUDES
= stm32f4xx_crc.c \
333 stm32f4xx_flash_ramfunc.c \
337 stm32f4xx_spdifrx.c \
339 stm32f4xx_cryp_aes.c \
340 stm32f4xx_hash_md5.c \
341 stm32f4xx_cryp_des.c \
345 stm32f4xx_cryp_tdes.c \
346 stm32f4xx_hash_sha1.c
348 ifeq ($(TARGET
),$(filter $(TARGET
), $(F411_TARGETS
)))
349 EXCLUDES
+= stm32f4xx_fsmc.c
352 ifeq ($(TARGET
),$(filter $(TARGET
), $(F446_TARGETS
)))
353 EXCLUDES
+= stm32f4xx_fsmc.c
356 STDPERIPH_SRC
:= $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC
))
359 USBCORE_DIR
= $(ROOT
)/lib
/main
/STM32_USB_Device_Library
/Core
360 USBCORE_SRC
= $(notdir $(wildcard $(USBCORE_DIR
)/src
/*.c
))
361 USBOTG_DIR
= $(ROOT
)/lib
/main
/STM32_USB_OTG_Driver
362 USBOTG_SRC
= $(notdir $(wildcard $(USBOTG_DIR
)/src
/*.c
))
363 EXCLUDES
= usb_bsp_template.c \
364 usb_conf_template.c \
369 USBOTG_SRC
:= $(filter-out ${EXCLUDES}, $(USBOTG_SRC
))
370 USBCDC_DIR
= $(ROOT
)/lib
/main
/STM32_USB_Device_Library
/Class
/cdc
371 USBCDC_SRC
= $(notdir $(wildcard $(USBCDC_DIR
)/src
/*.c
))
372 EXCLUDES
= usbd_cdc_if_template.c
373 USBCDC_SRC
:= $(filter-out ${EXCLUDES}, $(USBCDC_SRC
))
374 VPATH
:= $(VPATH
):$(USBOTG_DIR
)/src
:$(USBCORE_DIR
)/src
:$(USBCDC_DIR
)/src
376 DEVICE_STDPERIPH_SRC
:= $(STDPERIPH_SRC
) \
382 VPATH
:= $(VPATH
):$(CMSIS_DIR
)/CM4
/CoreSupport
:$(CMSIS_DIR
)/CM4
/DeviceSupport
/ST
/STM32F4xx
383 CMSIS_SRC
= $(notdir $(wildcard $(CMSIS_DIR
)/CM4
/CoreSupport
/*.c \
384 $(CMSIS_DIR
)/CM4
/DeviceSupport
/ST
/STM32F4xx
/*.c
))
385 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
386 $(STDPERIPH_DIR
)/inc \
391 $(CMSIS_DIR
)/CM4
/CoreSupport \
392 $(CMSIS_DIR
)/CM4
/DeviceSupport
/ST
/STM32F4xx \
393 $(ROOT
)/src
/main
/vcpf4
395 ifneq ($(filter SDCARD
,$(FEATURES
)),)
396 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
398 VPATH
:= $(VPATH
):$(FATFS_DIR
)
402 ARCH_FLAGS
= -mthumb
-mcpu
=cortex-m4
-march
=armv7e-m
-mfloat-abi
=hard
-mfpu
=fpv4-sp-d16
-fsingle-precision-constant
-Wdouble-promotion
404 ifeq ($(TARGET
),$(filter $(TARGET
),$(F411_TARGETS
)))
405 DEVICE_FLAGS
= -DSTM32F411xE
406 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f411.
ld
407 STARTUP_SRC
= startup_stm32f411xe.s
408 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F405_TARGETS
)))
409 DEVICE_FLAGS
= -DSTM32F40_41xxx
410 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f405.
ld
411 STARTUP_SRC
= startup_stm32f40xx.s
412 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F446_TARGETS
)))
413 DEVICE_FLAGS
= -DSTM32F446xx
414 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f446.
ld
415 STARTUP_SRC
= startup_stm32f446xx.s
417 $(error Unknown MCU for F4 target
)
419 DEVICE_FLAGS
+= -DHSE_VALUE
=$(HSE_VALUE
)
424 else ifeq ($(TARGET
),$(filter $(TARGET
), $(F7_TARGETS
)))
427 STDPERIPH_DIR
= $(ROOT
)/lib
/main
/STM32F7xx_HAL_Driver
428 STDPERIPH_SRC
= $(notdir $(wildcard $(STDPERIPH_DIR
)/Src
/*.c
))
429 EXCLUDES
= stm32f7xx_hal_can.c \
430 stm32f7xx_hal_cec.c \
431 stm32f7xx_hal_crc.c \
432 stm32f7xx_hal_crc_ex.c \
433 stm32f7xx_hal_cryp.c \
434 stm32f7xx_hal_cryp_ex.c \
435 stm32f7xx_hal_dac.c \
436 stm32f7xx_hal_dac_ex.c \
437 stm32f7xx_hal_dcmi.c \
438 stm32f7xx_hal_dcmi_ex.c \
439 stm32f7xx_hal_dfsdm.c \
440 stm32f7xx_hal_dma2d.c \
441 stm32f7xx_hal_dsi.c \
442 stm32f7xx_hal_eth.c \
443 stm32f7xx_hal_hash.c \
444 stm32f7xx_hal_hash_ex.c \
445 stm32f7xx_hal_hcd.c \
446 stm32f7xx_hal_i2s.c \
447 stm32f7xx_hal_irda.c \
448 stm32f7xx_hal_iwdg.c \
449 stm32f7xx_hal_jpeg.c \
450 stm32f7xx_hal_lptim.c \
451 stm32f7xx_hal_ltdc.c \
452 stm32f7xx_hal_ltdc_ex.c \
453 stm32f7xx_hal_mdios.c \
454 stm32f7xx_hal_mmc.c \
455 stm32f7xx_hal_msp_template.c \
456 stm32f7xx_hal_nand.c \
457 stm32f7xx_hal_nor.c \
458 stm32f7xx_hal_qspi.c \
459 stm32f7xx_hal_rng.c \
460 stm32f7xx_hal_rtc.c \
461 stm32f7xx_hal_rtc_ex.c \
462 stm32f7xx_hal_sai.c \
463 stm32f7xx_hal_sai_ex.c \
465 stm32f7xx_hal_sdram.c \
466 stm32f7xx_hal_smartcard.c \
467 stm32f7xx_hal_smartcard_ex.c \
468 stm32f7xx_hal_smbus.c \
469 stm32f7xx_hal_spdifrx.c \
470 stm32f7xx_hal_sram.c \
471 stm32f7xx_hal_timebase_rtc_alarm_template.c \
472 stm32f7xx_hal_timebase_rtc_wakeup_template.c \
473 stm32f7xx_hal_timebase_tim_template.c \
474 stm32f7xx_hal_wwdg.c \
479 stm32f7xx_ll_dma2d.c \
480 stm32f7xx_ll_exti.c \
482 stm32f7xx_ll_gpio.c \
484 stm32f7xx_ll_lptim.c \
489 stm32f7xx_ll_sdmmc.c \
492 stm32f7xx_ll_usart.c \
495 STDPERIPH_SRC
:= $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC
))
498 USBCORE_DIR
= $(ROOT
)/lib
/main
/Middlewares
/ST
/STM32_USB_Device_Library
/Core
499 USBCORE_SRC
= $(notdir $(wildcard $(USBCORE_DIR
)/Src
/*.c
))
500 EXCLUDES
= usbd_conf_template.c
501 USBCORE_SRC
:= $(filter-out ${EXCLUDES}, $(USBCORE_SRC
))
503 USBCDC_DIR
= $(ROOT
)/lib
/main
/Middlewares
/ST
/STM32_USB_Device_Library
/Class
/CDC
504 USBCDC_SRC
= $(notdir $(wildcard $(USBCDC_DIR
)/Src
/*.c
))
505 EXCLUDES
= usbd_cdc_if_template.c
506 USBCDC_SRC
:= $(filter-out ${EXCLUDES}, $(USBCDC_SRC
))
508 VPATH
:= $(VPATH
):$(USBCDC_DIR
)/Src
:$(USBCORE_DIR
)/Src
510 DEVICE_STDPERIPH_SRC
:= $(STDPERIPH_SRC
) \
515 VPATH
:= $(VPATH
):$(CMSIS_DIR
)/CM7
/Include
:$(CMSIS_DIR
)/CM7
/Device
/ST
/STM32F7xx
516 VPATH
:= $(VPATH
):$(STDPERIPH_DIR
)/Src
517 CMSIS_SRC
= $(notdir $(wildcard $(CMSIS_DIR
)/CM7
/Include
/*.c \
518 $(CMSIS_DIR
)/CM7
/Device
/ST
/STM32F7xx
/*.c
))
519 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
520 $(STDPERIPH_DIR
)/Inc \
523 $(CMSIS_DIR
)/CM7
/Include \
524 $(CMSIS_DIR
)/CM7
/Device
/ST
/STM32F7xx
/Include \
525 $(ROOT
)/src
/main
/vcp_hal
527 ifneq ($(filter SDCARD
,$(FEATURES
)),)
528 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
530 VPATH
:= $(VPATH
):$(FATFS_DIR
)
534 ARCH_FLAGS
= -mthumb
-mcpu
=cortex-m7
-mfloat-abi
=hard
-mfpu
=fpv5-sp-d16
-fsingle-precision-constant
-Wdouble-promotion
536 ifeq ($(TARGET
),$(filter $(TARGET
),$(F7X5XG_TARGETS
)))
537 DEVICE_FLAGS
= -DSTM32F745xx
-DUSE_HAL_DRIVER
-D__FPU_PRESENT
538 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f745.
ld
539 STARTUP_SRC
= startup_stm32f745xx.s
540 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F7X6XG_TARGETS
)))
541 DEVICE_FLAGS
= -DSTM32F746xx
-DUSE_HAL_DRIVER
-D__FPU_PRESENT
542 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f746.
ld
543 STARTUP_SRC
= startup_stm32f746xx.s
544 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F7X2RE_TARGETS
)))
545 DEVICE_FLAGS
= -DSTM32F722xx
-DUSE_HAL_DRIVER
-D__FPU_PRESENT
546 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f722.
ld
547 STARTUP_SRC
= startup_stm32f722xx.s
549 $(error Unknown MCU for F7 target
)
551 DEVICE_FLAGS
+= -DHSE_VALUE
=$(HSE_VALUE
)
553 TARGET_FLAGS
= -D
$(TARGET
)
558 else ifeq ($(TARGET
),$(filter $(TARGET
), $(SITL_TARGETS
)))
560 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
561 $(ROOT
)/lib
/main
/dyad
563 SITL_SRC
:= $(ROOT
)/lib
/main
/dyad
/dyad.c
568 LD_SCRIPT
= src
/main
/target
/SITL
/parameter_group.
ld
571 TARGET_FLAGS
= -D
$(TARGET
)
580 STDPERIPH_DIR
= $(ROOT
)/lib
/main
/STM32F10x_StdPeriph_Driver
581 STDPERIPH_SRC
= $(notdir $(wildcard $(STDPERIPH_DIR
)/src
/*.c
))
582 EXCLUDES
= stm32f10x_crc.c \
585 STARTUP_SRC
= startup_stm32f10x_md_gcc.S
586 STDPERIPH_SRC
:= $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC
))
588 # Search path and source files for the CMSIS sources
589 VPATH
:= $(VPATH
):$(CMSIS_DIR
)/CM3
/CoreSupport
:$(CMSIS_DIR
)/CM3
/DeviceSupport
/ST
/STM32F10x
590 CMSIS_SRC
= $(notdir $(wildcard $(CMSIS_DIR
)/CM3
/CoreSupport
/*.c \
591 $(CMSIS_DIR
)/CM3
/DeviceSupport
/ST
/STM32F10x
/*.c
))
593 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
594 $(STDPERIPH_DIR
)/inc \
595 $(CMSIS_DIR
)/CM3
/CoreSupport \
596 $(CMSIS_DIR
)/CM3
/DeviceSupport
/ST
/STM32F10x
598 DEVICE_STDPERIPH_SRC
= $(STDPERIPH_SRC
)
600 ifneq ($(filter VCP
, $(FEATURES
)),)
601 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
605 VPATH
:= $(VPATH
):$(USBFS_DIR
)/src
607 DEVICE_STDPERIPH_SRC
:= $(DEVICE_STDPERIPH_SRC
) \
612 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f103_
$(FLASH_SIZE
)k.
ld
613 ARCH_FLAGS
= -mthumb
-mcpu
=cortex-m3
615 ifeq ($(DEVICE_FLAGS
),)
616 DEVICE_FLAGS
= -DSTM32F10X_MD
618 DEVICE_FLAGS
+= -DSTM32F10X
624 ifneq ($(BASE_TARGET
), $(TARGET
))
625 TARGET_FLAGS
:= $(TARGET_FLAGS
) -D
$(BASE_TARGET
)
628 ifneq ($(FLASH_SIZE
),)
629 DEVICE_FLAGS
:= $(DEVICE_FLAGS
) -DFLASH_SIZE
=$(FLASH_SIZE
)
632 ifneq ($(HSE_VALUE
),)
633 DEVICE_FLAGS
:= $(DEVICE_FLAGS
) -DHSE_VALUE
=$(HSE_VALUE
)
636 TARGET_DIR
= $(ROOT
)/src
/main
/target
/$(BASE_TARGET
)
637 TARGET_DIR_SRC
= $(notdir $(wildcard $(TARGET_DIR
)/*.c
))
640 TARGET_FLAGS
:= -DOPBL
$(TARGET_FLAGS
)
641 ifeq ($(TARGET
), $(filter $(TARGET
),$(F405_TARGETS
)))
642 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f405_opbl.
ld
643 else ifeq ($(TARGET
), $(filter $(TARGET
),$(F411_TARGETS
)))
644 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f411_opbl.
ld
645 else ifeq ($(TARGET
), $(filter $(TARGET
),$(F3_TARGETS
)))
646 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f303_
$(FLASH_SIZE
)k_opbl.
ld
647 else ifeq ($(TARGET
), $(filter $(TARGET
),$(F1_TARGETS
)))
648 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f103_
$(FLASH_SIZE
)k_opbl.
ld
650 .DEFAULT_GOAL
:= binary
655 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
656 $(ROOT
)/lib
/main
/MAVLink
658 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
661 VPATH
:= $(VPATH
):$(TARGET_DIR
)
664 build
/build_config.c \
675 common
/typeconversion.c \
676 config
/config_eeprom.c \
678 config
/parameter_group.c \
679 config
/config_streamer.c \
681 drivers
/buf_writer.c \
682 drivers
/bus_i2c_config.c \
683 drivers
/bus_i2c_soft.c \
685 drivers
/bus_spi_config.c \
686 drivers
/bus_spi_pinconfig.c \
687 drivers
/bus_spi_soft.c \
692 drivers
/light_led.c \
696 drivers
/serial_pinconfig.c \
697 drivers
/serial_uart.c \
698 drivers
/serial_uart_pinconfig.c \
699 drivers
/sound_beeper.c \
700 drivers
/stack_check.c \
703 drivers
/transponder_ir.c \
704 drivers
/transponder_ir_arcitimer.c \
705 drivers
/transponder_ir_ilap.c \
706 drivers
/transponder_ir_erlt.c \
712 fc/runtime_config.c \
715 io
/statusindicator.c \
716 io
/transponder_ir.c \
719 scheduler
/scheduler.c \
725 io
/displayport_max7456.c \
726 osd_slave
/osd_slave_init.c \
731 fc/controlrate_profile.c \
732 drivers
/gyro_sync.c \
733 drivers
/rx_nrf24l01.c \
736 drivers
/pwm_esc_detect.c \
737 drivers
/pwm_output.c \
739 drivers
/serial_softserial.c \
742 fc/rc_adjustments.c \
754 io
/serial_4way_avrootloader.c \
755 io
/serial_4way_stk500v2.c \
773 sensors
/acceleration.c \
774 sensors
/boardalignment.c \
777 sensors
/gyroanalyse.c \
778 sensors
/initialisation.c \
779 blackbox
/blackbox.c \
780 blackbox
/blackbox_encoding.c \
781 blackbox
/blackbox_io.c \
783 cms
/cms_menu_blackbox.c \
784 cms
/cms_menu_builtin.c \
786 cms
/cms_menu_ledstrip.c \
787 cms
/cms_menu_misc.c \
789 common
/colorconversion.c \
790 common
/gps_conversion.c \
791 drivers
/display_ug2864hsweg01.c \
792 drivers
/light_ws2811strip.c \
793 drivers
/serial_escserial.c \
794 drivers
/sonar_hcsr04.c \
795 drivers
/vtx_common.c \
796 flight
/navigation.c \
798 io
/displayport_max7456.c \
799 io
/displayport_msp.c \
800 io
/displayport_oled.c \
805 sensors
/barometer.c \
806 telemetry
/telemetry.c \
811 telemetry
/smartport.c \
813 telemetry
/mavlink.c \
815 telemetry
/ibus_shared.c \
816 sensors
/esc_sensor.c \
819 io
/vtx_smartaudio.c \
823 COMMON_DEVICE_SRC
= \
825 $(DEVICE_STDPERIPH_SRC
)
827 ifeq ($(OSD_SLAVE
),yes
)
828 TARGET_FLAGS
:= -DUSE_OSD_SLAVE
$(TARGET_FLAGS
)
829 COMMON_SRC
:= $(COMMON_SRC
) $(OSD_SLAVE_SRC
) $(COMMON_DEVICE_SRC
)
831 COMMON_SRC
:= $(COMMON_SRC
) $(FC_SRC
) $(COMMON_DEVICE_SRC
)
835 SPEED_OPTIMISED_SRC
:= ""
836 SIZE_OPTIMISED_SRC
:= ""
838 ifneq ($(TARGET
),$(filter $(TARGET
),$(F1_TARGETS
)))
839 SPEED_OPTIMISED_SRC
:= $(SPEED_OPTIMISED_SRC
) \
843 common
/typeconversion.c \
845 drivers
/buf_writer.c \
848 drivers
/gyro_sync.c \
850 drivers
/pwm_output.c \
853 drivers
/serial_uart.c \
860 fc/runtime_config.c \
875 scheduler
/scheduler.c \
876 sensors
/acceleration.c \
877 sensors
/boardalignment.c \
879 sensors
/gyroanalyse.c \
881 $(DEVICE_STDPERIPH_SRC
) \
882 drivers
/light_ws2811strip.c \
883 io
/displayport_max7456.c \
887 SIZE_OPTIMISED_SRC
:= $(SIZE_OPTIMISED_SRC
) \
888 drivers
/bus_i2c_config.c \
889 drivers
/bus_spi_config.c \
890 drivers
/bus_spi_pinconfig.c \
891 drivers
/serial_escserial.c \
892 drivers
/serial_pinconfig.c \
893 drivers
/serial_uart_init.c \
894 drivers
/serial_uart_pinconfig.c \
895 drivers
/vtx_rtc6705_soft_spi.c \
896 drivers
/vtx_rtc6705.c \
897 drivers
/vtx_common.c \
901 config
/config_eeprom.c \
903 config
/parameter_group.c \
904 config
/config_streamer.c \
906 io
/serial_4way_avrootloader.c \
907 io
/serial_4way_stk500v2.c \
911 cms
/cms_menu_blackbox.c \
912 cms
/cms_menu_builtin.c \
914 cms
/cms_menu_ledstrip.c \
915 cms
/cms_menu_misc.c \
919 io
/vtx_smartaudio.c \
924 ifeq ($(TARGET
),$(filter $(TARGET
),$(F4_TARGETS
)))
926 vcpf4
/stm32f4xx_it.c \
930 vcpf4
/usbd_cdc_vcp.c \
931 drivers
/serial_usb_vcp.c \
933 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F7_TARGETS
)))
935 vcp_hal
/usbd_desc.c \
936 vcp_hal
/usbd_conf.c \
937 vcp_hal
/usbd_cdc_interface.c \
938 drivers
/serial_usb_vcp.c \
949 drivers
/serial_usb_vcp.c \
953 STM32F10x_COMMON_SRC
= \
954 drivers
/adc_stm32f10x.c \
955 drivers
/bus_i2c_stm32f10x.c \
957 drivers
/gpio_stm32f10x.c \
959 drivers
/light_ws2811strip_stdperiph.c \
960 drivers
/serial_uart_init.c \
961 drivers
/serial_uart_stm32f10x.c \
962 drivers
/system_stm32f10x.c \
963 drivers
/timer_stm32f10x.c
965 STM32F30x_COMMON_SRC
= \
966 target
/system_stm32f30x.c \
967 drivers
/adc_stm32f30x.c \
968 drivers
/bus_i2c_stm32f30x.c \
970 drivers
/gpio_stm32f30x.c \
971 drivers
/light_ws2811strip_stdperiph.c \
972 drivers
/pwm_output_dshot.c \
973 drivers
/serial_uart_init.c \
974 drivers
/serial_uart_stm32f30x.c \
975 drivers
/system_stm32f30x.c \
976 drivers
/timer_stm32f30x.c
978 STM32F4xx_COMMON_SRC
= \
979 target
/system_stm32f4xx.c \
980 drivers
/accgyro
/accgyro_mpu.c \
981 drivers
/adc_stm32f4xx.c \
982 drivers
/bus_i2c_stm32f10x.c \
983 drivers
/dma_stm32f4xx.c \
984 drivers
/gpio_stm32f4xx.c \
986 drivers
/light_ws2811strip_stdperiph.c \
987 drivers
/pwm_output_dshot.c \
988 drivers
/serial_uart_init.c \
989 drivers
/serial_uart_stm32f4xx.c \
990 drivers
/system_stm32f4xx.c \
991 drivers
/timer_stm32f4xx.c
993 STM32F7xx_COMMON_SRC
= \
994 target
/system_stm32f7xx.c \
995 drivers
/accgyro
/accgyro_mpu.c \
996 drivers
/adc_stm32f7xx.c \
997 drivers
/bus_i2c_hal.c \
998 drivers
/dma_stm32f7xx.c \
999 drivers
/gpio_stm32f7xx.c \
1000 drivers
/light_ws2811strip_hal.c \
1001 drivers
/bus_spi_hal.c \
1002 drivers
/pwm_output_dshot_hal.c \
1003 drivers
/timer_hal.c \
1004 drivers
/timer_stm32f7xx.c \
1005 drivers
/system_stm32f7xx.c \
1006 drivers
/serial_uart_stm32f7xx.c \
1007 drivers
/serial_uart_hal.c
1013 drivers
/serial_uart.c
1018 drivers
/bus_i2c_config.c \
1020 drivers
/bus_spi_config.c \
1021 drivers
/bus_spi_pinconfig.c \
1023 drivers
/pwm_output.c \
1025 drivers
/light_led.c \
1028 drivers
/serial_escserial.c \
1029 drivers
/serial_pinconfig.c \
1030 drivers
/serial_uart.c \
1031 drivers
/serial_uart_init.c \
1032 drivers
/serial_uart_pinconfig.c \
1033 drivers
/rx_xn297.c \
1034 drivers
/display_ug2864hsweg01.c \
1037 io
/displayport_oled.c
1040 # check if target.mk supplied
1041 ifeq ($(TARGET
),$(filter $(TARGET
),$(F4_TARGETS
)))
1042 SRC
:= $(STARTUP_SRC
) $(STM32F4xx_COMMON_SRC
) $(TARGET_SRC
) $(VARIANT_SRC
)
1043 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F7_TARGETS
)))
1044 SRC
:= $(STARTUP_SRC
) $(STM32F7xx_COMMON_SRC
) $(TARGET_SRC
) $(VARIANT_SRC
)
1045 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F3_TARGETS
)))
1046 SRC
:= $(STARTUP_SRC
) $(STM32F30x_COMMON_SRC
) $(TARGET_SRC
) $(VARIANT_SRC
)
1047 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F1_TARGETS
)))
1048 SRC
:= $(STARTUP_SRC
) $(STM32F10x_COMMON_SRC
) $(TARGET_SRC
) $(VARIANT_SRC
)
1049 else ifeq ($(TARGET
),$(filter $(TARGET
),$(SITL_TARGETS
)))
1050 SRC
:= $(TARGET_SRC
) $(SITL_SRC
) $(VARIANT_SRC
)
1053 ifneq ($(filter $(TARGET
),$(F3_TARGETS
) $(F4_TARGETS
) $(F7_TARGETS
)),)
1054 DSPLIB
:= $(ROOT
)/lib
/main
/DSP_Lib
1055 DEVICE_FLAGS
+= -DARM_MATH_MATRIX_CHECK
-DARM_MATH_ROUNDING
-D__FPU_PRESENT
=1 -DUNALIGNED_SUPPORT_DISABLE
1057 ifneq ($(filter $(TARGET
),$(F3_TARGETS
)) $(F4_TARGETS
)),)
1058 DEVICE_FLAGS
+= -DARM_MATH_CM4
1060 ifneq ($(filter $(TARGET
),$(F7_TARGETS
)),)
1061 DEVICE_FLAGS
+= -DARM_MATH_CM7
1064 INCLUDE_DIRS
+= $(DSPLIB
)/Include
1066 SRC
+= $(DSPLIB
)/Source
/BasicMathFunctions
/arm_mult_f32.c
1067 SRC
+= $(DSPLIB
)/Source
/TransformFunctions
/arm_rfft_fast_f32.c
1068 SRC
+= $(DSPLIB
)/Source
/TransformFunctions
/arm_cfft_f32.c
1069 SRC
+= $(DSPLIB
)/Source
/TransformFunctions
/arm_rfft_fast_init_f32.c
1070 SRC
+= $(DSPLIB
)/Source
/TransformFunctions
/arm_cfft_radix8_f32.c
1071 SRC
+= $(DSPLIB
)/Source
/CommonTables
/arm_common_tables.c
1073 SRC
+= $(DSPLIB
)/Source
/ComplexMathFunctions
/arm_cmplx_mag_f32.c
1074 SRC
+= $(DSPLIB
)/Source
/StatisticsFunctions
/arm_max_f32.c
1076 SRC
+= $(wildcard $(DSPLIB
)/Source
/*/*.S
)
1081 ifneq ($(filter ONBOARDFLASH
,$(FEATURES
)),)
1083 drivers
/flash_m25p16.c \
1087 SRC
+= $(COMMON_SRC
)
1090 ifeq ($(TARGET
),$(filter $(TARGET
),$(F7_TARGETS
)))
1091 SRC
:= $(filter-out ${F7EXCLUDES}, $(SRC
))
1095 ifeq ($(TARGET
),$(filter $(TARGET
),$(SITL_TARGETS
)))
1096 SRC
:= $(filter-out ${SITLEXCLUDES}, $(SRC
))
1099 ifneq ($(filter SDCARD
,$(FEATURES
)),)
1102 drivers
/sdcard_standard.c \
1103 io
/asyncfatfs
/asyncfatfs.c \
1104 io
/asyncfatfs
/fat_standard.c
1107 ifneq ($(filter VCP
,$(FEATURES
)),)
1110 # end target specific make file checks
1113 # Search path and source files for the ST stdperiph library
1114 VPATH
:= $(VPATH
):$(STDPERIPH_DIR
)/src
1116 ###############################################################################
1117 # Things that might need changing to use different tools
1120 # Find out if ccache is installed on the system
1122 RESULT
= $(shell (which
$(CCACHE
) > /dev
/null
2>&1; echo
$$?
) )
1128 CROSS_CC
:= $(CCACHE
) $(ARM_SDK_PREFIX
)gcc
1129 CROSS_CXX
:= $(CCACHE
) $(ARM_SDK_PREFIX
)g
++
1130 OBJCOPY
:= $(ARM_SDK_PREFIX
)objcopy
1131 OBJDUMP
:= $(ARM_SDK_PREFIX
)objdump
1132 SIZE
:= $(ARM_SDK_PREFIX
)size
1138 ifneq ($(DEBUG
),GDB
)
1139 OPTIMISATION_BASE
:= -flto
-fuse-linker-plugin
-ffast-math
1143 ifeq ($(TARGET
),$(filter $(TARGET
),$(F1_TARGETS
)))
1144 OPTIMISE_DEFAULT
:= -Os
1146 LTO_FLAGS
:= $(OPTIMISATION_BASE
) $(OPTIMISE_DEFAULT
)
1148 else ifeq ($(TARGET
),$(filter $(TARGET
),$(SITL_TARGETS
)))
1149 OPTIMISE_DEFAULT
:= -Ofast
1150 OPTIMISE_SPEED
:= -Ofast
1151 OPTIMISE_SIZE
:= -Os
1153 LTO_FLAGS
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SPEED
)
1156 OPTIMISE_DEFAULT
:= -O2
1157 OPTIMISE_SPEED
:= -Ofast
1158 OPTIMISE_SIZE
:= -Os
1160 LTO_FLAGS
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SPEED
)
1164 CC_DEFAULT_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_DEFAULT
)
1165 CC_SPEED_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SPEED
)
1166 CC_SIZE_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SIZE
)
1169 OPTIMISE_DEFAULT
:= -Og
1171 CC_DEBUG_OPTIMISATION
:= $(OPTIMISE_DEFAULT
)
1173 LTO_FLAGS
:= $(OPTIMISE_DEFAULT
)
1176 DEBUG_FLAGS
= -ggdb3
-DDEBUG
1178 CFLAGS
+= $(ARCH_FLAGS
) \
1179 $(addprefix -D
,$(OPTIONS
)) \
1180 $(addprefix -I
,$(INCLUDE_DIRS
)) \
1183 -Wall
-Wextra
-Wunsafe-loop-optimizations
-Wdouble-promotion \
1184 -ffunction-sections \
1188 -DUSE_STDPERIPH_DRIVER \
1191 -D
'__FORKNAME__="$(FORKNAME)"' \
1192 -D
'__TARGET__="$(TARGET)"' \
1193 -D
'__REVISION__="$(REVISION)"' \
1199 ASFLAGS
= $(ARCH_FLAGS
) \
1200 -x assembler-with-cpp \
1201 $(addprefix -I
,$(INCLUDE_DIRS
)) \
1206 --specs
=nano.specs \
1213 -Wl
,-gc-sections
,-Map
,$(TARGET_MAP
) \
1214 -Wl
,-L
$(LINKER_DIR
) \
1216 -Wl
,--no-wchar-size-warning \
1220 ifeq ($(TARGET
),$(filter $(TARGET
),$(SITL_TARGETS
)))
1229 -Wl
,-gc-sections
,-Map
,$(TARGET_MAP
) \
1230 -Wl
,-L
$(LINKER_DIR
) \
1234 ifneq ($(filter SITL_STATIC
,$(OPTIONS
)),)
1241 ###############################################################################
1242 # No user-serviceable parts below
1243 ###############################################################################
1245 CPPCHECK
= cppcheck
$(CSOURCES
) --enable
=all --platform
=unix64 \
1246 --std
=c99
--inline-suppr
--quiet
--force \
1247 $(addprefix -I
,$(INCLUDE_DIRS
)) \
1248 -I
/usr
/include -I
/usr
/include/linux
1251 # Things we will build
1253 TARGET_BIN
= $(BIN_DIR
)/$(FORKNAME
)_
$(FC_VER
)_
$(TARGET
).bin
1254 TARGET_HEX
= $(BIN_DIR
)/$(FORKNAME
)_
$(FC_VER
)_
$(TARGET
).hex
1255 TARGET_ELF
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).elf
1256 TARGET_LST
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).lst
1257 TARGET_OBJS
= $(addsuffix .o
,$(addprefix $(OBJECT_DIR
)/$(TARGET
)/,$(basename $(SRC
))))
1258 TARGET_DEPS
= $(addsuffix .d
,$(addprefix $(OBJECT_DIR
)/$(TARGET
)/,$(basename $(SRC
))))
1259 TARGET_MAP
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).map
1262 CLEAN_ARTIFACTS
:= $(TARGET_BIN
)
1263 CLEAN_ARTIFACTS
+= $(TARGET_HEX
)
1264 CLEAN_ARTIFACTS
+= $(TARGET_ELF
) $(TARGET_OBJS
) $(TARGET_MAP
)
1265 CLEAN_ARTIFACTS
+= $(TARGET_LST
)
1267 # Make sure build date and revision is updated on every incremental build
1268 $(OBJECT_DIR
)/$(TARGET
)/build
/version.o
: $(SRC
)
1270 # List of buildable ELF files and their object dependencies.
1271 # It would be nice to compute these lists, but that seems to be just beyond make.
1273 $(TARGET_LST
): $(TARGET_ELF
)
1274 $(V0
) $(OBJDUMP
) -S
--disassemble
$< > $@
1276 $(TARGET_HEX
): $(TARGET_ELF
)
1277 $(V0
) $(OBJCOPY
) -O ihex
--set-start
0x8000000 $< $@
1279 $(TARGET_BIN
): $(TARGET_ELF
)
1280 $(V0
) $(OBJCOPY
) -O binary
$< $@
1282 $(TARGET_ELF
): $(TARGET_OBJS
)
1283 $(V1
) echo Linking
$(TARGET
)
1284 $(V1
) $(CROSS_CC
) -o
$@
$^
$(LDFLAGS
)
1285 $(V0
) $(SIZE
) $(TARGET_ELF
)
1288 ifneq ($(DEBUG
),GDB
)
1289 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.c
1290 $(V1
) mkdir
-p
$(dir $@
)
1291 $(V1
) $(if
$(findstring $(subst .
/src
/main
/,,$<),$(SPEED_OPTIMISED_SRC
)), \
1292 echo
"%% (speed optimised) $(notdir $<)" "$(STDOUT)" && \
1293 $(CROSS_CC
) -c
-o
$@
$(CFLAGS
) $(CC_SPEED_OPTIMISATION
) $<, \
1294 $(if
$(findstring $(subst .
/src
/main
/,,$<),$(SIZE_OPTIMISED_SRC
)), \
1295 echo
"%% (size optimised) $(notdir $<)" "$(STDOUT)" && \
1296 $(CROSS_CC
) -c
-o
$@
$(CFLAGS
) $(CC_SIZE_OPTIMISATION
) $<, \
1297 echo
"%% $(notdir $<)" "$(STDOUT)" && \
1298 $(CROSS_CC
) -c
-o
$@
$(CFLAGS
) $(CC_DEFAULT_OPTIMISATION
) $<))
1300 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.c
1301 $(V1
) mkdir
-p
$(dir $@
)
1302 $(V1
) echo
"%% $(notdir $<)" "$(STDOUT)" && \
1303 $(CROSS_CC
) -c
-o
$@
$(CFLAGS
) $(CC_DEBUG_OPTIMISATION
) $<
1307 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.s
1308 $(V1
) mkdir
-p
$(dir $@
)
1309 $(V1
) echo
"%% $(notdir $<)" "$(STDOUT)"
1310 $(V1
) $(CROSS_CC
) -c
-o
$@
$(ASFLAGS
) $<
1312 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.S
1313 $(V1
) mkdir
-p
$(dir $@
)
1314 $(V1
) echo
"%% $(notdir $<)" "$(STDOUT)"
1315 $(V1
) $(CROSS_CC
) -c
-o
$@
$(ASFLAGS
) $<
1318 ## all : Build all valid targets
1319 all: $(VALID_TARGETS
)
1321 ## official : Build all official (travis) targets
1322 official
: $(OFFICIAL_TARGETS
)
1324 ## targets-group-1 : build some targets
1325 targets-group-1
: $(GROUP_1_TARGETS
)
1327 ## targets-group-2 : build some targets
1328 targets-group-2
: $(GROUP_2_TARGETS
)
1330 ## targets-group-3 : build some targets
1331 targets-group-3
: $(GROUP_3_TARGETS
)
1333 ## targets-group-3 : build some targets
1334 targets-group-4
: $(GROUP_4_TARGETS
)
1336 ## targets-group-rest: build the rest of the targets (not listed in group 1, 2 or 3)
1337 targets-group-rest
: $(GROUP_OTHER_TARGETS
)
1342 echo
"Building $@" && \
1343 time
$(MAKE
) binary hex TARGET
=$@
&& \
1344 echo
"Building $@ succeeded."
1346 CLEAN_TARGETS
= $(addprefix clean_
,$(VALID_TARGETS
) )
1347 TARGETS_CLEAN
= $(addsuffix _clean
,$(VALID_TARGETS
) )
1349 ## clean : clean up temporary / machine-generated files
1351 $(V0
) @echo
"Cleaning $(TARGET)"
1352 $(V0
) rm -f
$(CLEAN_ARTIFACTS
)
1353 $(V0
) rm -rf
$(OBJECT_DIR
)/$(TARGET
)
1354 $(V0
) @echo
"Cleaning $(TARGET) succeeded."
1356 ## clean_test : clean up temporary / machine-generated files (tests)
1358 $(V0
) cd src
/test && $(MAKE
) clean || true
1360 ## clean_<TARGET> : clean up one specific target
1362 $(V0
) $(MAKE
) -j TARGET
=$(subst clean_
,,$@
) clean
1364 ## <TARGET>_clean : clean up one specific target (alias for above)
1366 $(V0
) $(MAKE
) -j TARGET
=$(subst _clean
,,$@
) clean
1368 ## clean_all : clean all valid targets
1369 clean_all
:$(CLEAN_TARGETS
)
1371 ## all_clean : clean all valid targets (alias for above)
1372 all_clean
:$(TARGETS_CLEAN
)
1375 flash_
$(TARGET
): $(TARGET_HEX
)
1376 $(V0
) stty
-F
$(SERIAL_DEVICE
) raw speed
115200 -crtscts cs8
-parenb
-cstopb
-ixon
1377 $(V0
) echo
-n
'R' >$(SERIAL_DEVICE
)
1378 $(V0
) stm32flash
-w
$(TARGET_HEX
) -v
-g
0x0 -b
115200 $(SERIAL_DEVICE
)
1380 ## flash : flash firmware (.hex) onto flight controller
1381 flash
: flash_
$(TARGET
)
1383 st-flash_
$(TARGET
): $(TARGET_BIN
)
1384 $(V0
) st-flash
--reset write
$< 0x08000000
1386 ## st-flash : flash firmware (.bin) onto flight controller
1387 st-flash
: st-flash_
$(TARGET
)
1390 $(V0
) $(MAKE
) -j
$(TARGET_BIN
)
1393 $(V0
) $(MAKE
) -j
$(TARGET_HEX
)
1395 unbrick_
$(TARGET
): $(TARGET_HEX
)
1396 $(V0
) stty
-F
$(SERIAL_DEVICE
) raw speed
115200 -crtscts cs8
-parenb
-cstopb
-ixon
1397 $(V0
) stm32flash
-w
$(TARGET_HEX
) -v
-g
0x0 -b
115200 $(SERIAL_DEVICE
)
1399 ## unbrick : unbrick flight controller
1400 unbrick
: unbrick_
$(TARGET
)
1402 ## cppcheck : run static analysis on C source code
1403 cppcheck
: $(CSOURCES
)
1406 cppcheck-result.xml
: $(CSOURCES
)
1407 $(V0
) $(CPPCHECK
) --xml-version
=2 2> cppcheck-result.xml
1419 ## version : print firmware version
1423 ## help : print this help message and exit
1424 help
: Makefile make
/tools.mk
1426 $(V0
) @echo
"Makefile for the $(FORKNAME) firmware"
1428 $(V0
) @echo
"Usage:"
1429 $(V0
) @echo
" make [V=<verbosity>] [TARGET=<target>] [OPTIONS=\"<options>\"]"
1431 $(V0
) @echo
" make <target> [V=<verbosity>] [OPTIONS=\"<options>\"]"
1433 $(V0
) @echo
"Valid TARGET values are: $(VALID_TARGETS)"
1435 $(V0
) @sed
-n
's/^## //p' $?
1437 ## targets : print a list of all valid target platforms (for consumption by scripts)
1439 $(V0
) @echo
"Valid targets: $(VALID_TARGETS)"
1440 $(V0
) @echo
"Target: $(TARGET)"
1441 $(V0
) @echo
"Base target: $(BASE_TARGET)"
1442 $(V0
) @echo
"targets-group-1: $(GROUP_1_TARGETS)"
1443 $(V0
) @echo
"targets-group-2: $(GROUP_2_TARGETS)"
1444 $(V0
) @echo
"targets-group-3: $(GROUP_3_TARGETS)"
1445 $(V0
) @echo
"targets-group-4: $(GROUP_4_TARGETS)"
1446 $(V0
) @echo
"targets-group-rest: $(GROUP_OTHER_TARGETS)"
1448 ## test : run the cleanflight test suite
1449 ## junittest : run the cleanflight test suite, producing Junit XML result files.
1451 $(V0
) cd src
/test && $(MAKE
) $@
1453 # rebuild everything when makefile changes
1454 $(TARGET_OBJS
) : Makefile
1456 # include auto-generated dependencies
1457 -include $(TARGET_DEPS
)