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
))
186 GROUP_OTHER_TARGETS
:= $(filter-out $(GROUP_1_TARGETS
) $(GROUP_2_TARGETS
) $(GROUP_3_TARGETS
) $(GROUP_4_TARGETS
), $(VALID_TARGETS
))
189 ifeq ($(filter $(TARGET
),$(ALT_TARGETS
)), $(TARGET
))
190 BASE_TARGET
:= $(firstword $(subst /,, $(subst .
/src
/main
/target
/,, $(dir $(wildcard $(ROOT
)/src
/main
/target
/*/$(TARGET
).mk
)))))
191 -include $(ROOT
)/src
/main
/target
/$(BASE_TARGET
)/$(TARGET
).mk
193 BASE_TARGET
:= $(TARGET
)
196 ifeq ($(filter $(TARGET
),$(OPBL_TARGETS
)), $(TARGET
))
200 ifeq ($(filter $(TARGET
),$(OSD_SLAVE_TARGETS
)), $(TARGET
))
209 # silently ignore if the file is not present. Allows for target specific.
210 -include $(ROOT
)/src
/main
/target
/$(BASE_TARGET
)/target.mk
212 F4_TARGETS
= $(F405_TARGETS
) $(F411_TARGETS
) $(F446_TARGETS
)
213 F7_TARGETS
= $(F7X2RE_TARGETS
) $(F7X5XE_TARGETS
) $(F7X5XG_TARGETS
) $(F7X5XI_TARGETS
) $(F7X6XG_TARGETS
)
215 ifeq ($(filter $(TARGET
),$(VALID_TARGETS
)),)
216 $(error Target
'$(TARGET)' is not valid
, must be one of
$(VALID_TARGETS
). Have you prepared a valid target.mk?
)
219 ifeq ($(filter $(TARGET
),$(F1_TARGETS
) $(F3_TARGETS
) $(F4_TARGETS
) $(F7_TARGETS
) $(SITL_TARGETS
)),)
220 $(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?
)
223 128K_TARGETS
= $(F1_TARGETS
)
224 256K_TARGETS
= $(F3_TARGETS
)
225 512K_TARGETS
= $(F411_TARGETS
) $(F446_TARGETS
) $(F7X2RE_TARGETS
) $(F7X5XE_TARGETS
)
226 1024K_TARGETS
= $(F405_TARGETS
) $(F7X5XG_TARGETS
) $(F7X6XG_TARGETS
)
227 2048K_TARGETS
= $(F7X5XI_TARGETS
) $(SITL_TARGETS
)
229 # Configure default flash sizes for the targets (largest size specified gets hit first) if flash not specified already.
230 ifeq ($(FLASH_SIZE
),)
231 ifeq ($(TARGET
),$(filter $(TARGET
),$(2048K_TARGETS
)))
233 else ifeq ($(TARGET
),$(filter $(TARGET
),$(1024K_TARGETS
)))
235 else ifeq ($(TARGET
),$(filter $(TARGET
),$(512K_TARGETS
)))
237 else ifeq ($(TARGET
),$(filter $(TARGET
),$(256K_TARGETS
)))
239 else ifeq ($(TARGET
),$(filter $(TARGET
),$(128K_TARGETS
)))
242 $(error FLASH_SIZE not configured for target
$(TARGET
))
246 # note that there is no hardfault debugging startup file assembly handler for other platforms
247 ifeq ($(DEBUG_HARDFAULTS
),F3
)
248 CFLAGS
+= -DDEBUG_HARDFAULTS
249 STM32F30x_COMMON_SRC
= startup_stm32f3_debug_hardfault_handler.S
251 STM32F30x_COMMON_SRC
= startup_stm32f30x_md_gcc.S
254 ifeq ($(DEBUG_HARDFAULTS
),F7
)
255 CFLAGS
+= -DDEBUG_HARDFAULTS
258 REVISION
:= $(shell git log
-1 --format
="%h")
260 FC_VER_MAJOR
:= $(shell grep
" FC_VERSION_MAJOR" src
/main
/build
/version.h | awk
'{print $$3}' )
261 FC_VER_MINOR
:= $(shell grep
" FC_VERSION_MINOR" src
/main
/build
/version.h | awk
'{print $$3}' )
262 FC_VER_PATCH
:= $(shell grep
" FC_VERSION_PATCH" src
/main
/build
/version.h | awk
'{print $$3}' )
264 FC_VER
:= $(FC_VER_MAJOR
).
$(FC_VER_MINOR
).
$(FC_VER_PATCH
)
266 # Search path for sources
267 VPATH
:= $(SRC_DIR
):$(SRC_DIR
)/startup
268 USBFS_DIR
= $(ROOT
)/lib
/main
/STM32_USB-FS-Device_Driver
269 USBPERIPH_SRC
= $(notdir $(wildcard $(USBFS_DIR
)/src
/*.c
))
270 FATFS_DIR
= $(ROOT
)/lib
/main
/FatFS
271 FATFS_SRC
= $(notdir $(wildcard $(FATFS_DIR
)/*.c
))
273 CSOURCES
:= $(shell find
$(SRC_DIR
) -name
'*.c')
275 ifeq ($(TARGET
),$(filter $(TARGET
),$(F3_TARGETS
)))
278 STDPERIPH_DIR
= $(ROOT
)/lib
/main
/STM32F30x_StdPeriph_Driver
279 STDPERIPH_SRC
= $(notdir $(wildcard $(STDPERIPH_DIR
)/src
/*.c
))
280 EXCLUDES
= stm32f30x_crc.c \
282 STARTUP_SRC
= startup_stm32f30x_md_gcc.S
284 STDPERIPH_SRC
:= $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC
))
285 DEVICE_STDPERIPH_SRC
= $(STDPERIPH_SRC
)
287 VPATH
:= $(VPATH
):$(CMSIS_DIR
)/CM4
/CoreSupport
:$(CMSIS_DIR
)/CM4
/DeviceSupport
/ST
/STM32F30x
288 CMSIS_SRC
= $(notdir $(wildcard $(CMSIS_DIR
)/CM4
/CoreSupport
/*.c \
289 $(CMSIS_DIR
)/CM4
/DeviceSupport
/ST
/STM32F30x
/*.c
))
291 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
292 $(STDPERIPH_DIR
)/inc \
293 $(CMSIS_DIR
)/CM4
/CoreSupport \
294 $(CMSIS_DIR
)/CM4
/DeviceSupport
/ST
/STM32F30x
296 ifneq ($(filter VCP
, $(FEATURES
)),)
297 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
301 VPATH
:= $(VPATH
):$(USBFS_DIR
)/src
303 DEVICE_STDPERIPH_SRC
:= $(DEVICE_STDPERIPH_SRC
)\
307 ifneq ($(filter SDCARD
, $(FEATURES
)),)
308 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
311 VPATH
:= $(VPATH
):$(FATFS_DIR
)
314 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f303_
$(FLASH_SIZE
)k.
ld
316 ARCH_FLAGS
= -mthumb
-mcpu
=cortex-m4
-mfloat-abi
=hard
-mfpu
=fpv4-sp-d16
-fsingle-precision-constant
-Wdouble-promotion
317 DEVICE_FLAGS
= -DSTM32F303xC
-DSTM32F303
321 else ifeq ($(TARGET
),$(filter $(TARGET
), $(F4_TARGETS
)))
324 STDPERIPH_DIR
= $(ROOT
)/lib
/main
/STM32F4xx_StdPeriph_Driver
325 STDPERIPH_SRC
= $(notdir $(wildcard $(STDPERIPH_DIR
)/src
/*.c
))
326 EXCLUDES
= stm32f4xx_crc.c \
332 stm32f4xx_flash_ramfunc.c \
336 stm32f4xx_spdifrx.c \
338 stm32f4xx_cryp_aes.c \
339 stm32f4xx_hash_md5.c \
340 stm32f4xx_cryp_des.c \
344 stm32f4xx_cryp_tdes.c \
345 stm32f4xx_hash_sha1.c
347 ifeq ($(TARGET
),$(filter $(TARGET
), $(F411_TARGETS
)))
348 EXCLUDES
+= stm32f4xx_fsmc.c
351 ifeq ($(TARGET
),$(filter $(TARGET
), $(F446_TARGETS
)))
352 EXCLUDES
+= stm32f4xx_fsmc.c
355 STDPERIPH_SRC
:= $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC
))
358 USBCORE_DIR
= $(ROOT
)/lib
/main
/STM32_USB_Device_Library
/Core
359 USBCORE_SRC
= $(notdir $(wildcard $(USBCORE_DIR
)/src
/*.c
))
360 USBOTG_DIR
= $(ROOT
)/lib
/main
/STM32_USB_OTG_Driver
361 USBOTG_SRC
= $(notdir $(wildcard $(USBOTG_DIR
)/src
/*.c
))
362 EXCLUDES
= usb_bsp_template.c \
363 usb_conf_template.c \
368 USBOTG_SRC
:= $(filter-out ${EXCLUDES}, $(USBOTG_SRC
))
369 USBCDC_DIR
= $(ROOT
)/lib
/main
/STM32_USB_Device_Library
/Class
/cdc
370 USBCDC_SRC
= $(notdir $(wildcard $(USBCDC_DIR
)/src
/*.c
))
371 EXCLUDES
= usbd_cdc_if_template.c
372 USBCDC_SRC
:= $(filter-out ${EXCLUDES}, $(USBCDC_SRC
))
373 VPATH
:= $(VPATH
):$(USBOTG_DIR
)/src
:$(USBCORE_DIR
)/src
:$(USBCDC_DIR
)/src
375 DEVICE_STDPERIPH_SRC
:= $(STDPERIPH_SRC
) \
381 VPATH
:= $(VPATH
):$(CMSIS_DIR
)/CM4
/CoreSupport
:$(CMSIS_DIR
)/CM4
/DeviceSupport
/ST
/STM32F4xx
382 CMSIS_SRC
= $(notdir $(wildcard $(CMSIS_DIR
)/CM4
/CoreSupport
/*.c \
383 $(CMSIS_DIR
)/CM4
/DeviceSupport
/ST
/STM32F4xx
/*.c
))
384 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
385 $(STDPERIPH_DIR
)/inc \
390 $(CMSIS_DIR
)/CM4
/CoreSupport \
391 $(CMSIS_DIR
)/CM4
/DeviceSupport
/ST
/STM32F4xx \
392 $(ROOT
)/src
/main
/vcpf4
394 ifneq ($(filter SDCARD
,$(FEATURES
)),)
395 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
397 VPATH
:= $(VPATH
):$(FATFS_DIR
)
401 ARCH_FLAGS
= -mthumb
-mcpu
=cortex-m4
-march
=armv7e-m
-mfloat-abi
=hard
-mfpu
=fpv4-sp-d16
-fsingle-precision-constant
-Wdouble-promotion
403 ifeq ($(TARGET
),$(filter $(TARGET
),$(F411_TARGETS
)))
404 DEVICE_FLAGS
= -DSTM32F411xE
405 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f411.
ld
406 STARTUP_SRC
= startup_stm32f411xe.s
407 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F405_TARGETS
)))
408 DEVICE_FLAGS
= -DSTM32F40_41xxx
409 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f405.
ld
410 STARTUP_SRC
= startup_stm32f40xx.s
411 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F446_TARGETS
)))
412 DEVICE_FLAGS
= -DSTM32F446xx
413 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f446.
ld
414 STARTUP_SRC
= startup_stm32f446xx.s
416 $(error Unknown MCU for F4 target
)
418 DEVICE_FLAGS
+= -DHSE_VALUE
=$(HSE_VALUE
)
423 else ifeq ($(TARGET
),$(filter $(TARGET
), $(F7_TARGETS
)))
426 STDPERIPH_DIR
= $(ROOT
)/lib
/main
/STM32F7xx_HAL_Driver
427 STDPERIPH_SRC
= $(notdir $(wildcard $(STDPERIPH_DIR
)/Src
/*.c
))
428 EXCLUDES
= stm32f7xx_hal_can.c \
429 stm32f7xx_hal_cec.c \
430 stm32f7xx_hal_crc.c \
431 stm32f7xx_hal_crc_ex.c \
432 stm32f7xx_hal_cryp.c \
433 stm32f7xx_hal_cryp_ex.c \
434 stm32f7xx_hal_dac.c \
435 stm32f7xx_hal_dac_ex.c \
436 stm32f7xx_hal_dcmi.c \
437 stm32f7xx_hal_dcmi_ex.c \
438 stm32f7xx_hal_dfsdm.c \
439 stm32f7xx_hal_dma2d.c \
440 stm32f7xx_hal_dsi.c \
441 stm32f7xx_hal_eth.c \
442 stm32f7xx_hal_hash.c \
443 stm32f7xx_hal_hash_ex.c \
444 stm32f7xx_hal_hcd.c \
445 stm32f7xx_hal_i2s.c \
446 stm32f7xx_hal_irda.c \
447 stm32f7xx_hal_iwdg.c \
448 stm32f7xx_hal_jpeg.c \
449 stm32f7xx_hal_lptim.c \
450 stm32f7xx_hal_ltdc.c \
451 stm32f7xx_hal_ltdc_ex.c \
452 stm32f7xx_hal_mdios.c \
453 stm32f7xx_hal_mmc.c \
454 stm32f7xx_hal_msp_template.c \
455 stm32f7xx_hal_nand.c \
456 stm32f7xx_hal_nor.c \
457 stm32f7xx_hal_qspi.c \
458 stm32f7xx_hal_rng.c \
459 stm32f7xx_hal_rtc.c \
460 stm32f7xx_hal_rtc_ex.c \
461 stm32f7xx_hal_sai.c \
462 stm32f7xx_hal_sai_ex.c \
464 stm32f7xx_hal_sdram.c \
465 stm32f7xx_hal_smartcard.c \
466 stm32f7xx_hal_smartcard_ex.c \
467 stm32f7xx_hal_smbus.c \
468 stm32f7xx_hal_spdifrx.c \
469 stm32f7xx_hal_sram.c \
470 stm32f7xx_hal_timebase_rtc_alarm_template.c \
471 stm32f7xx_hal_timebase_rtc_wakeup_template.c \
472 stm32f7xx_hal_timebase_tim_template.c \
473 stm32f7xx_hal_wwdg.c \
478 stm32f7xx_ll_dma2d.c \
479 stm32f7xx_ll_exti.c \
481 stm32f7xx_ll_gpio.c \
483 stm32f7xx_ll_lptim.c \
488 stm32f7xx_ll_sdmmc.c \
491 stm32f7xx_ll_usart.c \
494 STDPERIPH_SRC
:= $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC
))
497 USBCORE_DIR
= $(ROOT
)/lib
/main
/Middlewares
/ST
/STM32_USB_Device_Library
/Core
498 USBCORE_SRC
= $(notdir $(wildcard $(USBCORE_DIR
)/Src
/*.c
))
499 EXCLUDES
= usbd_conf_template.c
500 USBCORE_SRC
:= $(filter-out ${EXCLUDES}, $(USBCORE_SRC
))
502 USBCDC_DIR
= $(ROOT
)/lib
/main
/Middlewares
/ST
/STM32_USB_Device_Library
/Class
/CDC
503 USBCDC_SRC
= $(notdir $(wildcard $(USBCDC_DIR
)/Src
/*.c
))
504 EXCLUDES
= usbd_cdc_if_template.c
505 USBCDC_SRC
:= $(filter-out ${EXCLUDES}, $(USBCDC_SRC
))
507 VPATH
:= $(VPATH
):$(USBCDC_DIR
)/Src
:$(USBCORE_DIR
)/Src
509 DEVICE_STDPERIPH_SRC
:= $(STDPERIPH_SRC
) \
514 VPATH
:= $(VPATH
):$(CMSIS_DIR
)/CM7
/Include
:$(CMSIS_DIR
)/CM7
/Device
/ST
/STM32F7xx
515 VPATH
:= $(VPATH
):$(STDPERIPH_DIR
)/Src
516 CMSIS_SRC
= $(notdir $(wildcard $(CMSIS_DIR
)/CM7
/Include
/*.c \
517 $(CMSIS_DIR
)/CM7
/Device
/ST
/STM32F7xx
/*.c
))
518 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
519 $(STDPERIPH_DIR
)/Inc \
522 $(CMSIS_DIR
)/CM7
/Include \
523 $(CMSIS_DIR
)/CM7
/Device
/ST
/STM32F7xx
/Include \
524 $(ROOT
)/src
/main
/vcp_hal
526 ifneq ($(filter SDCARD
,$(FEATURES
)),)
527 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
529 VPATH
:= $(VPATH
):$(FATFS_DIR
)
533 ARCH_FLAGS
= -mthumb
-mcpu
=cortex-m7
-mfloat-abi
=hard
-mfpu
=fpv5-sp-d16
-fsingle-precision-constant
-Wdouble-promotion
535 ifeq ($(TARGET
),$(filter $(TARGET
),$(F7X5XG_TARGETS
)))
536 DEVICE_FLAGS
= -DSTM32F745xx
-DUSE_HAL_DRIVER
-D__FPU_PRESENT
537 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f745.
ld
538 STARTUP_SRC
= startup_stm32f745xx.s
539 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F7X6XG_TARGETS
)))
540 DEVICE_FLAGS
= -DSTM32F746xx
-DUSE_HAL_DRIVER
-D__FPU_PRESENT
541 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f746.
ld
542 STARTUP_SRC
= startup_stm32f746xx.s
543 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F7X2RE_TARGETS
)))
544 DEVICE_FLAGS
= -DSTM32F722xx
-DUSE_HAL_DRIVER
-D__FPU_PRESENT
545 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f722.
ld
546 STARTUP_SRC
= startup_stm32f722xx.s
548 $(error Unknown MCU for F7 target
)
550 DEVICE_FLAGS
+= -DHSE_VALUE
=$(HSE_VALUE
)
552 TARGET_FLAGS
= -D
$(TARGET
)
557 else ifeq ($(TARGET
),$(filter $(TARGET
), $(SITL_TARGETS
)))
559 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
560 $(ROOT
)/lib
/main
/dyad
562 SITL_SRC
:= $(ROOT
)/lib
/main
/dyad
/dyad.c
567 LD_SCRIPT
= src
/main
/target
/SITL
/parameter_group.
ld
570 TARGET_FLAGS
= -D
$(TARGET
)
579 STDPERIPH_DIR
= $(ROOT
)/lib
/main
/STM32F10x_StdPeriph_Driver
580 STDPERIPH_SRC
= $(notdir $(wildcard $(STDPERIPH_DIR
)/src
/*.c
))
581 EXCLUDES
= stm32f10x_crc.c \
584 STARTUP_SRC
= startup_stm32f10x_md_gcc.S
585 STDPERIPH_SRC
:= $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC
))
587 # Search path and source files for the CMSIS sources
588 VPATH
:= $(VPATH
):$(CMSIS_DIR
)/CM3
/CoreSupport
:$(CMSIS_DIR
)/CM3
/DeviceSupport
/ST
/STM32F10x
589 CMSIS_SRC
= $(notdir $(wildcard $(CMSIS_DIR
)/CM3
/CoreSupport
/*.c \
590 $(CMSIS_DIR
)/CM3
/DeviceSupport
/ST
/STM32F10x
/*.c
))
592 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
593 $(STDPERIPH_DIR
)/inc \
594 $(CMSIS_DIR
)/CM3
/CoreSupport \
595 $(CMSIS_DIR
)/CM3
/DeviceSupport
/ST
/STM32F10x
597 DEVICE_STDPERIPH_SRC
= $(STDPERIPH_SRC
)
599 ifneq ($(filter VCP
, $(FEATURES
)),)
600 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
604 VPATH
:= $(VPATH
):$(USBFS_DIR
)/src
606 DEVICE_STDPERIPH_SRC
:= $(DEVICE_STDPERIPH_SRC
) \
611 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f103_
$(FLASH_SIZE
)k.
ld
612 ARCH_FLAGS
= -mthumb
-mcpu
=cortex-m3
614 ifeq ($(DEVICE_FLAGS
),)
615 DEVICE_FLAGS
= -DSTM32F10X_MD
617 DEVICE_FLAGS
+= -DSTM32F10X
623 ifneq ($(BASE_TARGET
), $(TARGET
))
624 TARGET_FLAGS
:= $(TARGET_FLAGS
) -D
$(BASE_TARGET
)
627 ifneq ($(FLASH_SIZE
),)
628 DEVICE_FLAGS
:= $(DEVICE_FLAGS
) -DFLASH_SIZE
=$(FLASH_SIZE
)
631 ifneq ($(HSE_VALUE
),)
632 DEVICE_FLAGS
:= $(DEVICE_FLAGS
) -DHSE_VALUE
=$(HSE_VALUE
)
635 TARGET_DIR
= $(ROOT
)/src
/main
/target
/$(BASE_TARGET
)
636 TARGET_DIR_SRC
= $(notdir $(wildcard $(TARGET_DIR
)/*.c
))
639 TARGET_FLAGS
:= -DOPBL
$(TARGET_FLAGS
)
640 ifeq ($(TARGET
), $(filter $(TARGET
),$(F405_TARGETS
)))
641 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f405_opbl.
ld
642 else ifeq ($(TARGET
), $(filter $(TARGET
),$(F411_TARGETS
)))
643 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f411_opbl.
ld
644 else ifeq ($(TARGET
), $(filter $(TARGET
),$(F3_TARGETS
)))
645 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f303_
$(FLASH_SIZE
)k_opbl.
ld
646 else ifeq ($(TARGET
), $(filter $(TARGET
),$(F1_TARGETS
)))
647 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f103_
$(FLASH_SIZE
)k_opbl.
ld
649 .DEFAULT_GOAL
:= binary
654 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
655 $(ROOT
)/lib
/main
/MAVLink
657 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
660 VPATH
:= $(VPATH
):$(TARGET_DIR
)
663 build
/build_config.c \
673 common
/typeconversion.c \
674 config
/config_eeprom.c \
676 config
/parameter_group.c \
677 config
/config_streamer.c \
679 drivers
/buf_writer.c \
680 drivers
/bus_i2c_config.c \
681 drivers
/bus_i2c_soft.c \
683 drivers
/bus_spi_soft.c \
688 drivers
/light_led.c \
692 drivers
/serial_pinconfig.c \
693 drivers
/serial_uart.c \
694 drivers
/serial_uart_pinconfig.c \
695 drivers
/sound_beeper.c \
696 drivers
/stack_check.c \
699 drivers
/transponder_ir.c \
700 drivers
/transponder_ir_arcitimer.c \
701 drivers
/transponder_ir_ilap.c \
702 drivers
/transponder_ir_erlt.c \
708 fc/runtime_config.c \
711 io
/statusindicator.c \
712 io
/transponder_ir.c \
714 scheduler
/scheduler.c \
720 io
/displayport_max7456.c \
721 osd_slave
/osd_slave_init.c \
726 fc/controlrate_profile.c \
727 drivers
/gyro_sync.c \
728 drivers
/rx_nrf24l01.c \
731 drivers
/pwm_esc_detect.c \
732 drivers
/pwm_output.c \
734 drivers
/serial_softserial.c \
737 fc/rc_adjustments.c \
748 io
/serial_4way_avrootloader.c \
749 io
/serial_4way_stk500v2.c \
767 sensors
/acceleration.c \
768 sensors
/boardalignment.c \
771 sensors
/gyroanalyse.c \
772 sensors
/initialisation.c \
773 blackbox
/blackbox.c \
774 blackbox
/blackbox_encoding.c \
775 blackbox
/blackbox_io.c \
777 cms
/cms_menu_blackbox.c \
778 cms
/cms_menu_builtin.c \
780 cms
/cms_menu_ledstrip.c \
781 cms
/cms_menu_misc.c \
783 common
/colorconversion.c \
784 common
/gps_conversion.c \
785 drivers
/display_ug2864hsweg01.c \
786 drivers
/light_ws2811strip.c \
787 drivers
/serial_escserial.c \
788 drivers
/sonar_hcsr04.c \
789 drivers
/vtx_common.c \
790 flight
/navigation.c \
792 io
/displayport_max7456.c \
793 io
/displayport_msp.c \
794 io
/displayport_oled.c \
799 sensors
/barometer.c \
800 telemetry
/telemetry.c \
805 telemetry
/smartport.c \
807 telemetry
/mavlink.c \
809 telemetry
/ibus_shared.c \
810 sensors
/esc_sensor.c \
813 io
/vtx_smartaudio.c \
817 COMMON_DEVICE_SRC
= \
819 $(DEVICE_STDPERIPH_SRC
)
821 ifeq ($(OSD_SLAVE
),yes
)
822 TARGET_FLAGS
:= -DUSE_OSD_SLAVE
$(TARGET_FLAGS
)
823 COMMON_SRC
:= $(COMMON_SRC
) $(OSD_SLAVE_SRC
) $(COMMON_DEVICE_SRC
)
825 COMMON_SRC
:= $(COMMON_SRC
) $(FC_SRC
) $(COMMON_DEVICE_SRC
)
829 SPEED_OPTIMISED_SRC
:= ""
830 SIZE_OPTIMISED_SRC
:= ""
832 ifneq ($(TARGET
),$(filter $(TARGET
),$(F1_TARGETS
)))
833 SPEED_OPTIMISED_SRC
:= $(SPEED_OPTIMISED_SRC
) \
837 common
/typeconversion.c \
839 drivers
/buf_writer.c \
840 drivers
/bus_i2c_soft.c \
842 drivers
/bus_spi_soft.c \
844 drivers
/gyro_sync.c \
846 drivers
/light_led.c \
848 drivers
/rx_nrf24l01.c \
851 drivers
/pwm_output.c \
855 drivers
/serial_uart.c \
856 drivers
/sound_beeper.c \
863 fc/runtime_config.c \
885 scheduler
/scheduler.c \
886 sensors
/acceleration.c \
887 sensors
/boardalignment.c \
889 sensors
/gyroanalyse.c \
891 $(DEVICE_STDPERIPH_SRC
) \
892 drivers
/display_ug2864hsweg01.c \
893 drivers
/light_ws2811strip.c \
894 drivers
/serial_softserial.c \
895 io
/displayport_max7456.c \
899 SIZE_OPTIMISED_SRC
:= $(SIZE_OPTIMISED_SRC
) \
900 drivers
/bus_i2c_config.c \
901 drivers
/serial_escserial.c \
902 drivers
/serial_pinconfig.c \
903 drivers
/serial_uart_init.c \
904 drivers
/serial_uart_pinconfig.c \
905 drivers
/vtx_rtc6705_soft_spi.c \
906 drivers
/vtx_rtc6705.c \
907 drivers
/vtx_common.c \
911 config
/config_eeprom.c \
913 config
/parameter_group.c \
914 config
/config_streamer.c \
916 io
/serial_4way_avrootloader.c \
917 io
/serial_4way_stk500v2.c \
921 cms
/cms_menu_blackbox.c \
922 cms
/cms_menu_builtin.c \
924 cms
/cms_menu_ledstrip.c \
925 cms
/cms_menu_misc.c \
929 io
/vtx_smartaudio.c \
934 ifeq ($(TARGET
),$(filter $(TARGET
),$(F4_TARGETS
)))
936 vcpf4
/stm32f4xx_it.c \
940 vcpf4
/usbd_cdc_vcp.c \
941 drivers
/serial_usb_vcp.c \
943 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F7_TARGETS
)))
945 vcp_hal
/usbd_desc.c \
946 vcp_hal
/usbd_conf.c \
947 vcp_hal
/usbd_cdc_interface.c \
948 drivers
/serial_usb_vcp.c \
959 drivers
/serial_usb_vcp.c \
963 STM32F10x_COMMON_SRC
= \
964 drivers
/adc_stm32f10x.c \
965 drivers
/bus_i2c_stm32f10x.c \
967 drivers
/gpio_stm32f10x.c \
969 drivers
/light_ws2811strip_stdperiph.c \
970 drivers
/serial_uart_init.c \
971 drivers
/serial_uart_stm32f10x.c \
972 drivers
/system_stm32f10x.c \
973 drivers
/timer_stm32f10x.c
975 STM32F30x_COMMON_SRC
= \
976 target
/system_stm32f30x.c \
977 drivers
/adc_stm32f30x.c \
978 drivers
/bus_i2c_stm32f30x.c \
980 drivers
/gpio_stm32f30x.c \
981 drivers
/light_ws2811strip_stdperiph.c \
982 drivers
/pwm_output_dshot.c \
983 drivers
/serial_uart_init.c \
984 drivers
/serial_uart_stm32f30x.c \
985 drivers
/system_stm32f30x.c \
986 drivers
/timer_stm32f30x.c
988 STM32F4xx_COMMON_SRC
= \
989 target
/system_stm32f4xx.c \
990 drivers
/accgyro
/accgyro_mpu.c \
991 drivers
/adc_stm32f4xx.c \
992 drivers
/bus_i2c_stm32f10x.c \
993 drivers
/dma_stm32f4xx.c \
994 drivers
/gpio_stm32f4xx.c \
996 drivers
/light_ws2811strip_stdperiph.c \
997 drivers
/pwm_output_dshot.c \
998 drivers
/serial_uart_init.c \
999 drivers
/serial_uart_stm32f4xx.c \
1000 drivers
/system_stm32f4xx.c \
1001 drivers
/timer_stm32f4xx.c
1003 STM32F7xx_COMMON_SRC
= \
1004 target
/system_stm32f7xx.c \
1005 drivers
/accgyro
/accgyro_mpu.c \
1006 drivers
/adc_stm32f7xx.c \
1007 drivers
/bus_i2c_hal.c \
1008 drivers
/dma_stm32f7xx.c \
1009 drivers
/gpio_stm32f7xx.c \
1010 drivers
/light_ws2811strip_hal.c \
1011 drivers
/bus_spi_hal.c \
1012 drivers
/pwm_output_dshot_hal.c \
1013 drivers
/timer_hal.c \
1014 drivers
/timer_stm32f7xx.c \
1015 drivers
/system_stm32f7xx.c \
1016 drivers
/serial_uart_stm32f7xx.c \
1017 drivers
/serial_uart_hal.c
1023 drivers
/serial_uart.c
1029 drivers
/bus_i2c_config.c \
1031 drivers
/pwm_output.c \
1033 drivers
/light_led.c \
1036 drivers
/serial_pinconfig.c \
1037 drivers
/serial_uart.c \
1038 drivers
/serial_uart_init.c \
1039 drivers
/serial_uart_pinconfig.c \
1040 drivers
/rx_xn297.c \
1041 drivers
/display_ug2864hsweg01.c \
1044 io
/displayport_oled.c
1047 # check if target.mk supplied
1048 ifeq ($(TARGET
),$(filter $(TARGET
),$(F4_TARGETS
)))
1049 SRC
:= $(STARTUP_SRC
) $(STM32F4xx_COMMON_SRC
) $(TARGET_SRC
) $(VARIANT_SRC
)
1050 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F7_TARGETS
)))
1051 SRC
:= $(STARTUP_SRC
) $(STM32F7xx_COMMON_SRC
) $(TARGET_SRC
) $(VARIANT_SRC
)
1052 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F3_TARGETS
)))
1053 SRC
:= $(STARTUP_SRC
) $(STM32F30x_COMMON_SRC
) $(TARGET_SRC
) $(VARIANT_SRC
)
1054 else ifeq ($(TARGET
),$(filter $(TARGET
),$(F1_TARGETS
)))
1055 SRC
:= $(STARTUP_SRC
) $(STM32F10x_COMMON_SRC
) $(TARGET_SRC
) $(VARIANT_SRC
)
1056 else ifeq ($(TARGET
),$(filter $(TARGET
),$(SITL_TARGETS
)))
1057 SRC
:= $(TARGET_SRC
) $(SITL_SRC
) $(VARIANT_SRC
)
1060 ifneq ($(filter $(TARGET
),$(F3_TARGETS
) $(F4_TARGETS
) $(F7_TARGETS
)),)
1061 DSPLIB
:= $(ROOT
)/lib
/main
/DSP_Lib
1062 DEVICE_FLAGS
+= -DARM_MATH_MATRIX_CHECK
-DARM_MATH_ROUNDING
-D__FPU_PRESENT
=1 -DUNALIGNED_SUPPORT_DISABLE
1064 ifneq ($(filter $(TARGET
),$(F3_TARGETS
)) $(F4_TARGETS
)),)
1065 DEVICE_FLAGS
+= -DARM_MATH_CM4
1067 ifneq ($(filter $(TARGET
),$(F7_TARGETS
)),)
1068 DEVICE_FLAGS
+= -DARM_MATH_CM7
1071 INCLUDE_DIRS
+= $(DSPLIB
)/Include
1073 SRC
+= $(DSPLIB
)/Source
/BasicMathFunctions
/arm_mult_f32.c
1074 SRC
+= $(DSPLIB
)/Source
/TransformFunctions
/arm_rfft_fast_f32.c
1075 SRC
+= $(DSPLIB
)/Source
/TransformFunctions
/arm_cfft_f32.c
1076 SRC
+= $(DSPLIB
)/Source
/TransformFunctions
/arm_rfft_fast_init_f32.c
1077 SRC
+= $(DSPLIB
)/Source
/TransformFunctions
/arm_cfft_radix8_f32.c
1078 SRC
+= $(DSPLIB
)/Source
/CommonTables
/arm_common_tables.c
1080 SRC
+= $(DSPLIB
)/Source
/ComplexMathFunctions
/arm_cmplx_mag_f32.c
1081 SRC
+= $(DSPLIB
)/Source
/StatisticsFunctions
/arm_max_f32.c
1083 SRC
+= $(wildcard $(DSPLIB
)/Source
/*/*.S
)
1088 ifneq ($(filter ONBOARDFLASH
,$(FEATURES
)),)
1090 drivers
/flash_m25p16.c \
1094 SRC
+= $(COMMON_SRC
)
1097 ifeq ($(TARGET
),$(filter $(TARGET
),$(F7_TARGETS
)))
1098 SRC
:= $(filter-out ${F7EXCLUDES}, $(SRC
))
1102 ifeq ($(TARGET
),$(filter $(TARGET
),$(SITL_TARGETS
)))
1103 SRC
:= $(filter-out ${SITLEXCLUDES}, $(SRC
))
1106 ifneq ($(filter SDCARD
,$(FEATURES
)),)
1109 drivers
/sdcard_standard.c \
1110 io
/asyncfatfs
/asyncfatfs.c \
1111 io
/asyncfatfs
/fat_standard.c
1114 ifneq ($(filter VCP
,$(FEATURES
)),)
1117 # end target specific make file checks
1120 # Search path and source files for the ST stdperiph library
1121 VPATH
:= $(VPATH
):$(STDPERIPH_DIR
)/src
1123 ###############################################################################
1124 # Things that might need changing to use different tools
1127 # Find out if ccache is installed on the system
1129 RESULT
= $(shell (which
$(CCACHE
) > /dev
/null
2>&1; echo
$$?
) )
1135 CROSS_CC
:= $(CCACHE
) $(ARM_SDK_PREFIX
)gcc
1136 CROSS_CXX
:= $(CCACHE
) $(ARM_SDK_PREFIX
)g
++
1137 OBJCOPY
:= $(ARM_SDK_PREFIX
)objcopy
1138 SIZE
:= $(ARM_SDK_PREFIX
)size
1144 ifneq ($(DEBUG
),GDB
)
1145 OPTIMISATION_BASE
:= -flto
-fuse-linker-plugin
-ffast-math
1149 ifeq ($(TARGET
),$(filter $(TARGET
),$(F1_TARGETS
)))
1150 OPTIMISE_DEFAULT
:= -Os
1152 LTO_FLAGS
:= $(OPTIMISATION_BASE
) $(OPTIMISE_DEFAULT
)
1154 else ifeq ($(TARGET
),$(filter $(TARGET
),$(SITL_TARGETS
)))
1155 OPTIMISE_DEFAULT
:= -Ofast
1156 OPTIMISE_SPEED
:= -Ofast
1157 OPTIMISE_SIZE
:= -Os
1159 LTO_FLAGS
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SPEED
)
1162 OPTIMISE_DEFAULT
:= -O2
1163 OPTIMISE_SPEED
:= -Ofast
1164 OPTIMISE_SIZE
:= -Os
1166 LTO_FLAGS
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SPEED
)
1170 CC_DEFAULT_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_DEFAULT
)
1171 CC_SPEED_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SPEED
)
1172 CC_SIZE_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SIZE
)
1175 OPTIMISE_DEFAULT
:= -Og
1177 CC_DEBUG_OPTIMISATION
:= $(OPTIMISE_DEFAULT
)
1179 LTO_FLAGS
:= $(OPTIMISE_DEFAULT
)
1182 DEBUG_FLAGS
= -ggdb3
-DDEBUG
1184 CFLAGS
+= $(ARCH_FLAGS
) \
1185 $(addprefix -D
,$(OPTIONS
)) \
1186 $(addprefix -I
,$(INCLUDE_DIRS
)) \
1189 -Wall
-Wextra
-Wunsafe-loop-optimizations
-Wdouble-promotion \
1190 -ffunction-sections \
1194 -DUSE_STDPERIPH_DRIVER \
1197 -D
'__FORKNAME__="$(FORKNAME)"' \
1198 -D
'__TARGET__="$(TARGET)"' \
1199 -D
'__REVISION__="$(REVISION)"' \
1205 ASFLAGS
= $(ARCH_FLAGS
) \
1206 -x assembler-with-cpp \
1207 $(addprefix -I
,$(INCLUDE_DIRS
)) \
1212 --specs
=nano.specs \
1219 -Wl
,-gc-sections
,-Map
,$(TARGET_MAP
) \
1220 -Wl
,-L
$(LINKER_DIR
) \
1222 -Wl
,--no-wchar-size-warning \
1226 ifeq ($(TARGET
),$(filter $(TARGET
),$(SITL_TARGETS
)))
1235 -Wl
,-gc-sections
,-Map
,$(TARGET_MAP
) \
1236 -Wl
,-L
$(LINKER_DIR
) \
1240 ifneq ($(filter SITL_STATIC
,$(OPTIONS
)),)
1247 ###############################################################################
1248 # No user-serviceable parts below
1249 ###############################################################################
1251 CPPCHECK
= cppcheck
$(CSOURCES
) --enable
=all --platform
=unix64 \
1252 --std
=c99
--inline-suppr
--quiet
--force \
1253 $(addprefix -I
,$(INCLUDE_DIRS
)) \
1254 -I
/usr
/include -I
/usr
/include/linux
1257 # Things we will build
1259 TARGET_BIN
= $(BIN_DIR
)/$(FORKNAME
)_
$(FC_VER
)_
$(TARGET
).bin
1260 TARGET_HEX
= $(BIN_DIR
)/$(FORKNAME
)_
$(FC_VER
)_
$(TARGET
).hex
1261 TARGET_ELF
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).elf
1262 TARGET_OBJS
= $(addsuffix .o
,$(addprefix $(OBJECT_DIR
)/$(TARGET
)/,$(basename $(SRC
))))
1263 TARGET_DEPS
= $(addsuffix .d
,$(addprefix $(OBJECT_DIR
)/$(TARGET
)/,$(basename $(SRC
))))
1264 TARGET_MAP
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).map
1267 CLEAN_ARTIFACTS
:= $(TARGET_BIN
)
1268 CLEAN_ARTIFACTS
+= $(TARGET_HEX
)
1269 CLEAN_ARTIFACTS
+= $(TARGET_ELF
) $(TARGET_OBJS
) $(TARGET_MAP
)
1271 # Make sure build date and revision is updated on every incremental build
1272 $(OBJECT_DIR
)/$(TARGET
)/build
/version.o
: $(SRC
)
1274 # List of buildable ELF files and their object dependencies.
1275 # It would be nice to compute these lists, but that seems to be just beyond make.
1277 $(TARGET_HEX
): $(TARGET_ELF
)
1278 $(V0
) $(OBJCOPY
) -O ihex
--set-start
0x8000000 $< $@
1280 $(TARGET_BIN
): $(TARGET_ELF
)
1281 $(V0
) $(OBJCOPY
) -O binary
$< $@
1283 $(TARGET_ELF
): $(TARGET_OBJS
)
1284 $(V1
) echo Linking
$(TARGET
)
1285 $(V1
) $(CROSS_CC
) -o
$@
$^
$(LDFLAGS
)
1286 $(V0
) $(SIZE
) $(TARGET_ELF
)
1289 ifneq ($(DEBUG
),GDB
)
1290 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.c
1291 $(V1
) mkdir
-p
$(dir $@
)
1292 $(V1
) $(if
$(findstring $(subst .
/src
/main
/,,$<),$(SPEED_OPTIMISED_SRC
)), \
1293 echo
"%% (speed optimised) $(notdir $<)" "$(STDOUT)" && \
1294 $(CROSS_CC
) -c
-o
$@
$(CFLAGS
) $(CC_SPEED_OPTIMISATION
) $<, \
1295 $(if
$(findstring $(subst .
/src
/main
/,,$<),$(SIZE_OPTIMISED_SRC
)), \
1296 echo
"%% (size optimised) $(notdir $<)" "$(STDOUT)" && \
1297 $(CROSS_CC
) -c
-o
$@
$(CFLAGS
) $(CC_SIZE_OPTIMISATION
) $<, \
1298 echo
"%% $(notdir $<)" "$(STDOUT)" && \
1299 $(CROSS_CC
) -c
-o
$@
$(CFLAGS
) $(CC_DEFAULT_OPTIMISATION
) $<))
1301 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.c
1302 $(V1
) mkdir
-p
$(dir $@
)
1303 $(V1
) echo
"%% $(notdir $<)" "$(STDOUT)" && \
1304 $(CROSS_CC
) -c
-o
$@
$(CFLAGS
) $(CC_DEBUG_OPTIMISATION
) $<
1308 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.s
1309 $(V1
) mkdir
-p
$(dir $@
)
1310 $(V1
) echo
"%% $(notdir $<)" "$(STDOUT)"
1311 $(V1
) $(CROSS_CC
) -c
-o
$@
$(ASFLAGS
) $<
1313 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.S
1314 $(V1
) mkdir
-p
$(dir $@
)
1315 $(V1
) echo
"%% $(notdir $<)" "$(STDOUT)"
1316 $(V1
) $(CROSS_CC
) -c
-o
$@
$(ASFLAGS
) $<
1319 ## all : Build all valid targets
1320 all: $(VALID_TARGETS
)
1322 ## official : Build all official (travis) targets
1323 official
: $(OFFICIAL_TARGETS
)
1325 ## targets-group-1 : build some targets
1326 targets-group-1
: $(GROUP_1_TARGETS
)
1328 ## targets-group-2 : build some targets
1329 targets-group-2
: $(GROUP_2_TARGETS
)
1331 ## targets-group-3 : build some targets
1332 targets-group-3
: $(GROUP_3_TARGETS
)
1334 ## targets-group-3 : build some targets
1335 targets-group-4
: $(GROUP_4_TARGETS
)
1337 ## targets-group-rest: build the rest of the targets (not listed in group 1, 2 or 3)
1338 targets-group-rest
: $(GROUP_OTHER_TARGETS
)
1343 echo
"Building $@" && \
1344 time
$(MAKE
) binary hex TARGET
=$@
&& \
1345 echo
"Building $@ succeeded."
1349 CLEAN_TARGETS
= $(addprefix clean_
,$(VALID_TARGETS
) )
1350 TARGETS_CLEAN
= $(addsuffix _clean
,$(VALID_TARGETS
) )
1352 ## clean : clean up temporary / machine-generated files
1354 $(V0
) echo
"Cleaning $(TARGET)"
1355 $(V0
) rm -f
$(CLEAN_ARTIFACTS
)
1356 $(V0
) rm -rf
$(OBJECT_DIR
)/$(TARGET
)
1357 $(V0
) echo
"Cleaning $(TARGET) succeeded."
1359 ## clean_test : clean up temporary / machine-generated files (tests)
1361 $(V0
) cd src
/test && $(MAKE
) clean || true
1363 ## clean_<TARGET> : clean up one specific target
1365 $(V0
) $(MAKE
) -j TARGET
=$(subst clean_
,,$@
) clean
1367 ## <TARGET>_clean : clean up one specific target (alias for above)
1369 $(V0
) $(MAKE
) -j TARGET
=$(subst _clean
,,$@
) clean
1371 ## clean_all : clean all valid targets
1372 clean_all
:$(CLEAN_TARGETS
)
1374 ## all_clean : clean all valid targets (alias for above)
1375 all_clean
:$(TARGETS_CLEAN
)
1378 flash_
$(TARGET
): $(TARGET_HEX
)
1379 $(V0
) stty
-F
$(SERIAL_DEVICE
) raw speed
115200 -crtscts cs8
-parenb
-cstopb
-ixon
1380 $(V0
) echo
-n
'R' >$(SERIAL_DEVICE
)
1381 $(V0
) stm32flash
-w
$(TARGET_HEX
) -v
-g
0x0 -b
115200 $(SERIAL_DEVICE
)
1383 ## flash : flash firmware (.hex) onto flight controller
1384 flash
: flash_
$(TARGET
)
1386 st-flash_
$(TARGET
): $(TARGET_BIN
)
1387 $(V0
) st-flash
--reset write
$< 0x08000000
1389 ## st-flash : flash firmware (.bin) onto flight controller
1390 st-flash
: st-flash_
$(TARGET
)
1393 $(V0
) $(MAKE
) -j
$(TARGET_BIN
)
1396 $(V0
) $(MAKE
) -j
$(TARGET_HEX
)
1398 unbrick_
$(TARGET
): $(TARGET_HEX
)
1399 $(V0
) stty
-F
$(SERIAL_DEVICE
) raw speed
115200 -crtscts cs8
-parenb
-cstopb
-ixon
1400 $(V0
) stm32flash
-w
$(TARGET_HEX
) -v
-g
0x0 -b
115200 $(SERIAL_DEVICE
)
1402 ## unbrick : unbrick flight controller
1403 unbrick
: unbrick_
$(TARGET
)
1405 ## cppcheck : run static analysis on C source code
1406 cppcheck
: $(CSOURCES
)
1409 cppcheck-result.xml
: $(CSOURCES
)
1410 $(V0
) $(CPPCHECK
) --xml-version
=2 2> cppcheck-result.xml
1422 ## version : print firmware version
1426 ## help : print this help message and exit
1427 help
: Makefile make
/tools.mk
1429 $(V0
) @echo
"Makefile for the $(FORKNAME) firmware"
1431 $(V0
) @echo
"Usage:"
1432 $(V0
) @echo
" make [V=<verbosity>] [TARGET=<target>] [OPTIONS=\"<options>\"]"
1434 $(V0
) @echo
" make <target> [V=<verbosity>] [OPTIONS=\"<options>\"]"
1436 $(V0
) @echo
"Valid TARGET values are: $(VALID_TARGETS)"
1438 $(V0
) @sed
-n
's/^## //p' $?
1440 ## targets : print a list of all valid target platforms (for consumption by scripts)
1442 $(V0
) @echo
"Valid targets: $(VALID_TARGETS)"
1443 $(V0
) @echo
"Target: $(TARGET)"
1444 $(V0
) @echo
"Base target: $(BASE_TARGET)"
1445 $(V0
) @echo
"targets-group-1: $(GROUP_1_TARGETS)"
1446 $(V0
) @echo
"targets-group-2: $(GROUP_2_TARGETS)"
1447 $(V0
) @echo
"targets-group-3: $(GROUP_3_TARGETS)"
1448 $(V0
) @echo
"targets-group-4: $(GROUP_4_TARGETS)"
1449 $(V0
) @echo
"targets-group-rest: $(GROUP_OTHER_TARGETS)"
1451 ## test : run the cleanflight test suite
1452 ## junittest : run the cleanflight test suite, producing Junit XML result files.
1454 $(V0
) cd src
/test && $(MAKE
) $@
1456 # rebuild everything when makefile changes
1457 $(TARGET_OBJS
) : Makefile
1459 # include auto-generated dependencies
1460 -include $(TARGET_DEPS
)