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 # compile for External Storage Bootloader support
31 # empty - ordinary build with all optimizations enabled
32 # RELWITHDEBINFO - ordinary build with debug symbols and all optimizations enabled
33 # GDB - debug build with minimum number of optimizations
36 # Insert the debugging hardfault debugger
37 # releases should not be built with this flag as it does not disable pwm output
40 # Serial port/Device for flashing
41 SERIAL_DEVICE ?
= $(firstword $(wildcard /dev
/ttyACM
*) $(firstword $(wildcard /dev
/ttyUSB
*) no-port-found
))
43 # Flash size (KB). Some low-end chips actually have more flash than advertised, use this to override.
47 ###############################################################################
48 # Things that need to be maintained as the source changes
54 ROOT
:= $(patsubst %/,%,$(dir $(lastword
$(MAKEFILE_LIST
))))
55 SRC_DIR
:= $(ROOT
)/src
/main
56 OBJECT_DIR
:= $(ROOT
)/obj
/main
57 BIN_DIR
:= $(ROOT
)/obj
58 CMSIS_DIR
:= $(ROOT
)/lib
/main
/CMSIS
59 INCLUDE_DIRS
:= $(SRC_DIR
) \
60 $(ROOT
)/src
/main
/target \
61 $(ROOT
)/src
/main
/startup
62 LINKER_DIR
:= $(ROOT
)/src
/link
64 ## V : Set verbosity level based on the V= parameter
67 include $(ROOT
)/make
/build_verbosity.mk
69 # Build tools, so we all share the same versions
70 # import macros common to all supported build systems
71 include $(ROOT
)/make
/system-id.mk
73 # developer preferences, edit these at will, they'll be gitignored
74 -include $(ROOT
)/make
/local.mk
76 # configure some directories that are relative to wherever ROOT_DIR is located
78 TOOLS_DIR
:= $(ROOT
)/tools
80 BUILD_DIR
:= $(ROOT
)/build
81 DL_DIR
:= $(ROOT
)/downloads
85 # import macros that are OS specific
86 include $(ROOT
)/make
/$(OSFAMILY
).mk
88 # include the tools makefile
89 include $(ROOT
)/make
/tools.mk
91 # default xtal value for F4 targets
94 # used for turning on features like VCP and SDCARD
97 # used to disable features based on flash space shortage (larger number => more features disabled)
98 FEATURE_CUT_LEVEL_SUPPLIED
:= $(FEATURE_CUT_LEVEL
)
101 # The list of targets to build for 'pre-push'
102 PRE_PUSH_TARGET_LIST ?
= OMNIBUSF4 STM32F405 SPRACINGF7DUAL STM32F7X2 SITL test-representative
104 include $(ROOT
)/make
/targets.mk
106 REVISION
:= $(shell git log
-1 --format
="%h")
108 FC_VER_MAJOR
:= $(shell grep
" FC_VERSION_MAJOR" src
/main
/build
/version.h | awk
'{print $$3}' )
109 FC_VER_MINOR
:= $(shell grep
" FC_VERSION_MINOR" src
/main
/build
/version.h | awk
'{print $$3}' )
110 FC_VER_PATCH
:= $(shell grep
" FC_VERSION_PATCH" src
/main
/build
/version.h | awk
'{print $$3}' )
112 FC_VER
:= $(FC_VER_MAJOR
).
$(FC_VER_MINOR
).
$(FC_VER_PATCH
)
114 # Search path for sources
115 VPATH
:= $(SRC_DIR
):$(SRC_DIR
)/startup
116 USBFS_DIR
= $(ROOT
)/lib
/main
/STM32_USB-FS-Device_Driver
117 USBPERIPH_SRC
= $(notdir $(wildcard $(USBFS_DIR
)/src
/*.c
))
118 FATFS_DIR
= $(ROOT
)/lib
/main
/FatFS
119 FATFS_SRC
= $(notdir $(wildcard $(FATFS_DIR
)/*.c
))
121 CSOURCES
:= $(shell find
$(SRC_DIR
) -name
'*.c')
126 # Default Tool options - can be overridden in {mcu}.mk files.
129 OPTIMISE_DEFAULT
:= -Og
131 LTO_FLAGS
:= $(OPTIMISE_DEFAULT
)
132 DEBUG_FLAGS
= -ggdb3
-DDEBUG
137 OPTIMISATION_BASE
:= -flto
-fuse-linker-plugin
-ffast-math
138 OPTIMISE_DEFAULT
:= -O2
139 OPTIMISE_SPEED
:= -Ofast
142 LTO_FLAGS
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SPEED
)
145 VPATH
:= $(VPATH
):$(ROOT
)/make
/mcu
146 VPATH
:= $(VPATH
):$(ROOT
)/make
148 # start specific includes
149 include $(ROOT
)/make
/mcu
/$(TARGET_MCU
).mk
151 # openocd specific includes
152 include $(ROOT
)/make
/openocd.mk
154 # Configure default flash sizes for the targets (largest size specified gets hit first) if flash not specified already.
155 ifeq ($(FLASH_SIZE
),)
156 ifneq ($(TARGET_FLASH
),)
157 FLASH_SIZE
:= $(TARGET_FLASH
)
159 $(error FLASH_SIZE not configured for target
$(TARGET
))
163 DEVICE_FLAGS
:= $(DEVICE_FLAGS
) -DFLASH_SIZE
=$(FLASH_SIZE
)
165 ifneq ($(HSE_VALUE
),)
166 DEVICE_FLAGS
:= $(DEVICE_FLAGS
) -DHSE_VALUE
=$(HSE_VALUE
)
169 ifneq ($(FEATURE_CUT_LEVEL_SUPPLIED
),)
170 DEVICE_FLAGS
:= $(DEVICE_FLAGS
) -DFEATURE_CUT_LEVEL
=$(FEATURE_CUT_LEVEL_SUPPLIED
)
171 else ifneq ($(FEATURE_CUT_LEVEL
),)
172 DEVICE_FLAGS
:= $(DEVICE_FLAGS
) -DFEATURE_CUT_LEVEL
=$(FEATURE_CUT_LEVEL
)
175 TARGET_DIR
= $(ROOT
)/src
/main
/target
/$(BASE_TARGET
)
176 TARGET_DIR_SRC
= $(notdir $(wildcard $(TARGET_DIR
)/*.c
))
179 TARGET_FLAGS
:= -DOPBL
$(TARGET_FLAGS
)
180 .DEFAULT_GOAL
:= binary
185 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
186 $(ROOT
)/lib
/main
/MAVLink
188 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
191 VPATH
:= $(VPATH
):$(TARGET_DIR
)
193 include $(ROOT
)/make
/source.mk
195 ###############################################################################
196 # Things that might need changing to use different tools
199 # Find out if ccache is installed on the system
201 RESULT
= $(shell (which
$(CCACHE
) > /dev
/null
2>&1; echo
$$?
) )
207 CROSS_CC
:= $(CCACHE
) $(ARM_SDK_PREFIX
)gcc
208 CROSS_CXX
:= $(CCACHE
) $(ARM_SDK_PREFIX
)g
++
209 CROSS_GDB
:= $(ARM_SDK_PREFIX
)gdb
210 OBJCOPY
:= $(ARM_SDK_PREFIX
)objcopy
211 OBJDUMP
:= $(ARM_SDK_PREFIX
)objdump
212 SIZE
:= $(ARM_SDK_PREFIX
)size
217 CC_DEBUG_OPTIMISATION
:= $(OPTIMISE_DEFAULT
)
218 CC_DEFAULT_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_DEFAULT
)
219 CC_SPEED_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SPEED
)
220 CC_SIZE_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SIZE
)
221 CC_NO_OPTIMISATION
:=
223 CFLAGS
+= $(ARCH_FLAGS
) \
224 $(addprefix -D
,$(OPTIONS
)) \
225 $(addprefix -I
,$(INCLUDE_DIRS
)) \
228 -Wall
-Wextra
-Wunsafe-loop-optimizations
-Wdouble-promotion \
229 -ffunction-sections \
235 -DUSE_STDPERIPH_DRIVER \
238 -D
'__FORKNAME__="$(FORKNAME)"' \
239 -D
'__TARGET__="$(TARGET)"' \
240 -D
'__REVISION__="$(REVISION)"' \
245 ASFLAGS
= $(ARCH_FLAGS
) \
247 -x assembler-with-cpp \
248 $(addprefix -I
,$(INCLUDE_DIRS
)) \
261 -Wl
,-gc-sections
,-Map
,$(TARGET_MAP
) \
262 -Wl
,-L
$(LINKER_DIR
) \
264 -Wl
,--no-wchar-size-warning \
265 -Wl
,--print-memory-usage \
269 ###############################################################################
270 # No user-serviceable parts below
271 ###############################################################################
273 CPPCHECK
= cppcheck
$(CSOURCES
) --enable
=all --platform
=unix64 \
274 --std
=c99
--inline-suppr
--quiet
--force \
275 $(addprefix -I
,$(INCLUDE_DIRS
)) \
276 -I
/usr
/include -I
/usr
/include/linux
279 # Things we will build
281 TARGET_S19
= $(BIN_DIR
)/$(FORKNAME
)_
$(FC_VER
)_
$(TARGET
).s19
282 TARGET_BIN
= $(BIN_DIR
)/$(FORKNAME
)_
$(FC_VER
)_
$(TARGET
).bin
283 TARGET_HEX
= $(BIN_DIR
)/$(FORKNAME
)_
$(FC_VER
)_
$(TARGET
).hex
284 TARGET_ELF
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).elf
285 TARGET_EXST_ELF
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
)_EXST.elf
286 TARGET_UNPATCHED_BIN
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
)_UNPATCHED.bin
287 TARGET_LST
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).lst
288 TARGET_OBJS
= $(addsuffix .o
,$(addprefix $(OBJECT_DIR
)/$(TARGET
)/,$(basename $(SRC
))))
289 TARGET_DEPS
= $(addsuffix .d
,$(addprefix $(OBJECT_DIR
)/$(TARGET
)/,$(basename $(SRC
))))
290 TARGET_MAP
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).map
292 TARGET_EXST_HASH_SECTION_FILE
= $(OBJECT_DIR
)/$(TARGET
)/exst_hash_section.bin
294 CLEAN_ARTIFACTS
:= $(TARGET_BIN
)
295 CLEAN_ARTIFACTS
+= $(TARGET_HEX
)
296 CLEAN_ARTIFACTS
+= $(TARGET_ELF
) $(TARGET_OBJS
) $(TARGET_MAP
)
297 CLEAN_ARTIFACTS
+= $(TARGET_LST
)
299 # Make sure build date and revision is updated on every incremental build
300 $(OBJECT_DIR
)/$(TARGET
)/build
/version.o
: $(SRC
)
302 # List of buildable ELF files and their object dependencies.
303 # It would be nice to compute these lists, but that seems to be just beyond make.
305 $(TARGET_LST
): $(TARGET_ELF
)
306 $(V0
) $(OBJDUMP
) -S
--disassemble
$< > $@
309 $(TARGET_S19
): $(TARGET_ELF
)
310 @echo
"Creating srec/S19 $(TARGET_S19)" "$(STDOUT)"
311 $(V1
) $(OBJCOPY
) --output-target
=srec
$(TARGET_S19
)
314 $(TARGET_BIN
): $(TARGET_ELF
)
315 @echo
"Creating BIN $(TARGET_BIN)" "$(STDOUT)"
316 $(V1
) $(OBJCOPY
) -O binary
$< $@
318 $(TARGET_HEX
): $(TARGET_ELF
)
319 @echo
"Creating HEX $(TARGET_HEX)" "$(STDOUT)"
320 $(V1
) $(OBJCOPY
) -O ihex
--set-start
0x8000000 $< $@
323 CLEAN_ARTIFACTS
+= $(TARGET_UNPATCHED_BIN
) $(TARGET_EXST_HASH_SECTION_FILE
) $(TARGET_EXST_ELF
)
325 $(TARGET_UNPATCHED_BIN
): $(TARGET_ELF
)
326 @echo
"Creating BIN (without checksum) $(TARGET_UNPATCHED_BIN)" "$(STDOUT)"
327 $(V1
) $(OBJCOPY
) -O binary
$< $@
329 $(TARGET_BIN
): $(TARGET_UNPATCHED_BIN
)
330 @echo
"Creating EXST $(TARGET_BIN)" "$(STDOUT)"
331 # Linker script should allow .bin generation from a .elf which results in a file that is the same length as the FIRMWARE_SIZE.
332 # These 'dd' commands will pad a short binary to length FIRMWARE_SIZE.
333 $(V1
) dd if
=/dev
/zero ibs
=1k count
=$(FIRMWARE_SIZE
) of
=$(TARGET_BIN
)
334 $(V1
) dd if
=$(TARGET_UNPATCHED_BIN
) of
=$(TARGET_BIN
) conv
=notrunc
336 @echo
"Generating MD5 hash of binary" "$(STDOUT)"
337 $(V1
) openssl dgst
-md5
$(TARGET_BIN
) > $(TARGET_UNPATCHED_BIN
).md5
339 @echo
"Patching MD5 hash into binary" "$(STDOUT)"
340 $(V1
) cat
$(TARGET_UNPATCHED_BIN
).md5 | awk
'{printf("%08x: %s",(1024*$(FIRMWARE_SIZE))-16,$$2);}' | xxd
-r
- $(TARGET_BIN
)
341 $(V1
) echo
$(FIRMWARE_SIZE
) | awk
'{printf("-s 0x%08x -l 16 -c 16 %s",(1024*$$1)-16,"$(TARGET_BIN)");}' | xargs xxd
343 @echo
"Patching MD5 hash into exst elf" "$(STDOUT)"
344 $(OBJCOPY
) $(TARGET_ELF
) --dump-section .exst_hash
=$(TARGET_EXST_HASH_SECTION_FILE
)
345 $(V1
) cat
$(TARGET_UNPATCHED_BIN
).md5 | awk
'{printf("%08x: %s",64-16,$$2);}' | xxd
-r
- $(TARGET_EXST_HASH_SECTION_FILE
)
346 $(OBJCOPY
) $(TARGET_ELF
) $(TARGET_EXST_ELF
) --update-section .exst_hash
=$(TARGET_EXST_HASH_SECTION_FILE
)
348 $(TARGET_HEX
): $(TARGET_BIN
)
349 @echo
"Creating EXST HEX from patched EXST ELF $(TARGET_HEX)" "$(STDOUT)"
350 $(V1
) $(OBJCOPY
) -O ihex
--set-start
0x8000000 $(TARGET_EXST_ELF
) $@
354 $(TARGET_ELF
): $(TARGET_OBJS
) $(LD_SCRIPT
)
355 @echo
"Linking $(TARGET)" "$(STDOUT)"
356 $(V1
) $(CROSS_CC
) -o
$@
$(filter-out %.
ld,$^
) $(LD_FLAGS
)
357 $(V1
) $(SIZE
) $(TARGET_ELF
)
361 ## compile_file takes two arguments: (1) optimisation description string and (2) optimisation compiler flag
363 echo
"%% ($(1)) $<" "$(STDOUT)" && \
364 $(CROSS_CC
) -c
-o
$@
$(CFLAGS
) $(2) $<
368 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.c
369 $(V1
) mkdir
-p
$(dir $@
)
370 $(V1
) $(if
$(findstring $<,$(NOT_OPTIMISED_SRC
)), \
371 $(call compile_file
,not optimised
, $(CC_NO_OPTIMISATION
)) \
373 $(call compile_file
,debug
,$(CC_DEBUG_OPTIMISATION
)) \
376 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.c
377 $(V1
) mkdir
-p
$(dir $@
)
378 $(V1
) $(if
$(findstring $<,$(NOT_OPTIMISED_SRC
)), \
379 $(call compile_file
,not optimised
,$(CC_NO_OPTIMISATION
)) \
381 $(if
$(findstring $(subst .
/src
/main
/,,$<),$(SPEED_OPTIMISED_SRC
)), \
382 $(call compile_file
,speed optimised
,$(CC_SPEED_OPTIMISATION
)) \
384 $(if
$(findstring $(subst .
/src
/main
/,,$<),$(SIZE_OPTIMISED_SRC
)), \
385 $(call compile_file
,size optimised
,$(CC_SIZE_OPTIMISATION
)) \
387 $(call compile_file
,optimised
,$(CC_DEFAULT_OPTIMISATION
)) \
394 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.s
395 $(V1
) mkdir
-p
$(dir $@
)
396 @echo
"%% $(notdir $<)" "$(STDOUT)"
397 $(V1
) $(CROSS_CC
) -c
-o
$@
$(ASFLAGS
) $<
399 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.S
400 $(V1
) mkdir
-p
$(dir $@
)
401 @echo
"%% $(notdir $<)" "$(STDOUT)"
402 $(V1
) $(CROSS_CC
) -c
-o
$@
$(ASFLAGS
) $<
405 ## all : Build all targets (excluding unsupported)
406 all: $(SUPPORTED_TARGETS
)
408 ## all_with_unsupported : Build all targets (including unsupported)
409 all_with_unsupported
: $(VALID_TARGETS
)
411 ## unsupported : Build unsupported targets
412 unsupported
: $(UNSUPPORTED_TARGETS
)
414 ## pre-push : The minimum verification that should be run before pushing, to check if CI has a chance of succeeding
416 $(MAKE
) $(addprefix clean_
,$(PRE_PUSH_TARGET_LIST
)) $(PRE_PUSH_TARGET_LIST
) EXTRA_FLAGS
=-Werror
418 ## official : Build all official (travis) targets
419 official
: $(OFFICIAL_TARGETS
)
421 ## targets-group-1 : build some targets
422 targets-group-1
: $(GROUP_1_TARGETS
)
424 ## targets-group-2 : build some targets
425 targets-group-2
: $(GROUP_2_TARGETS
)
427 ## targets-group-3 : build some targets
428 targets-group-3
: $(GROUP_3_TARGETS
)
430 ## targets-group-3 : build some targets
431 targets-group-4
: $(GROUP_4_TARGETS
)
433 ## targets-group-rest: build the rest of the targets (not listed in group 1, 2 or 3)
434 targets-group-rest
: $(GROUP_OTHER_TARGETS
)
437 $(V0
) @echo
"Building $@" && \
438 $(MAKE
) binary hex TARGET
=$@
&& \
439 echo
"Building $@ succeeded."
444 CLEAN_TARGETS
= $(addprefix clean_
,$(VALID_TARGETS
) )
445 TARGETS_CLEAN
= $(addsuffix _clean
,$(VALID_TARGETS
) )
447 ## clean : clean up temporary / machine-generated files
449 @echo
"Cleaning $(TARGET)"
450 $(V0
) rm -f
$(CLEAN_ARTIFACTS
)
451 $(V0
) rm -rf
$(OBJECT_DIR
)/$(TARGET
)
452 @echo
"Cleaning $(TARGET) succeeded."
454 ## clean_test : clean up temporary / machine-generated files (tests)
459 $(V0
) cd src
/test && $(MAKE
) clean || true
461 ## clean_<TARGET> : clean up one specific target
463 $(V0
) $(MAKE
) -j TARGET
=$(subst clean_
,,$@
) clean
465 ## <TARGET>_clean : clean up one specific target (alias for above)
467 $(V0
) $(MAKE
) -j TARGET
=$(subst _clean
,,$@
) clean
469 ## clean_all : clean all valid targets
470 clean_all
: $(CLEAN_TARGETS
)
472 ## all_clean : clean all valid targets (alias for above)
473 all_clean
: $(TARGETS_CLEAN
)
475 FLASH_TARGETS
= $(addprefix flash_
,$(VALID_TARGETS
) )
477 ## flash_<TARGET> : build and flash a target
479 ifneq (,$(findstring /dev
/ttyUSB
,$(SERIAL_DEVICE
)))
480 $(V0
) $(MAKE
) -j hex TARGET
=$(subst flash_
,,$@
)
481 $(V0
) $(MAKE
) tty_flash TARGET
=$(subst flash_
,,$@
)
483 $(V0
) $(MAKE
) -j binary TARGET
=$(subst flash_
,,$@
)
484 $(V0
) $(MAKE
) dfu_flash TARGET
=$(subst flash_
,,$@
)
487 ## tty_flash : flash firmware (.hex) onto flight controller via a serial port
489 $(V0
) stty
-F
$(SERIAL_DEVICE
) raw speed
115200 -crtscts cs8
-parenb
-cstopb
-ixon
490 $(V0
) echo
-n
'R' > $(SERIAL_DEVICE
)
491 $(V0
) stm32flash
-w
$(TARGET_HEX
) -v
-g
0x0 -b
115200 $(SERIAL_DEVICE
)
493 ## dfu_flash : flash firmware (.bin) onto flight controller via a DFU mode
495 ifneq (no-port-found
,$(SERIAL_DEVICE
))
496 # potentially this is because the MCU already is in DFU mode, try anyway
497 $(V0
) echo
-n
'R' > $(SERIAL_DEVICE
)
500 $(V0
) dfu-util
-a
0 -D
$(TARGET_BIN
) -s
0x08000000:leave
502 st-flash_
$(TARGET
): $(TARGET_BIN
)
503 $(V0
) st-flash
--reset write
$< 0x08000000
505 ## st-flash : flash firmware (.bin) onto flight controller
506 st-flash
: st-flash_
$(TARGET
)
508 ifneq ($(OPENOCD_COMMAND
),)
509 openocd-gdb
: $(TARGET_ELF
)
510 $(V0
) $(OPENOCD_COMMAND
) & $(CROSS_GDB
) $(TARGET_ELF
) -ex
"target remote localhost:3333" -ex
"load"
514 $(V0
) $(MAKE
) -j
$(TARGET_BIN
)
517 $(V0
) $(MAKE
) -j
$(TARGET_S19
)
520 $(V0
) $(MAKE
) -j
$(TARGET_HEX
)
522 unbrick_
$(TARGET
): $(TARGET_HEX
)
523 $(V0
) stty
-F
$(SERIAL_DEVICE
) raw speed
115200 -crtscts cs8
-parenb
-cstopb
-ixon
524 $(V0
) stm32flash
-w
$(TARGET_HEX
) -v
-g
0x0 -b
115200 $(SERIAL_DEVICE
)
526 ## unbrick : unbrick flight controller
527 unbrick
: unbrick_
$(TARGET
)
529 ## cppcheck : run static analysis on C source code
530 cppcheck
: $(CSOURCES
)
533 cppcheck-result.xml
: $(CSOURCES
)
534 $(V0
) $(CPPCHECK
) --xml-version
=2 2> cppcheck-result.xml
546 ## version : print firmware version
550 ## help : print this help message and exit
551 help
: Makefile make
/tools.mk
553 @echo
"Makefile for the $(FORKNAME) firmware"
556 @echo
" make [V=<verbosity>] [TARGET=<target>] [OPTIONS=\"<options>\"]"
558 @echo
" make <target> [V=<verbosity>] [OPTIONS=\"<options>\"]"
560 @echo
"Valid TARGET values are: $(VALID_TARGETS)"
562 @sed
-n
's/^## //p' $?
564 ## targets : print a list of all valid target platforms (for consumption by scripts)
566 @echo
"Valid targets: $(VALID_TARGETS)"
567 @echo
"Supported targets: $(SUPPORTED_TARGETS)"
568 @echo
"Unsupported targets: $(UNSUPPORTED_TARGETS)"
569 @echo
"Target: $(TARGET)"
570 @echo
"Base target: $(BASE_TARGET)"
571 @echo
"targets-group-1: $(GROUP_1_TARGETS)"
572 @echo
"targets-group-2: $(GROUP_2_TARGETS)"
573 @echo
"targets-group-3: $(GROUP_3_TARGETS)"
574 @echo
"targets-group-4: $(GROUP_4_TARGETS)"
575 @echo
"targets-group-rest: $(GROUP_OTHER_TARGETS)"
577 @echo
"targets-group-1: $(words $(GROUP_1_TARGETS)) targets"
578 @echo
"targets-group-2: $(words $(GROUP_2_TARGETS)) targets"
579 @echo
"targets-group-3: $(words $(GROUP_3_TARGETS)) targets"
580 @echo
"targets-group-4: $(words $(GROUP_4_TARGETS)) targets"
581 @echo
"targets-group-rest: $(words $(GROUP_OTHER_TARGETS)) targets"
582 @echo
"total in all groups $(words $(SUPPORTED_TARGETS)) targets"
584 ## target-mcu : print the MCU type of the target
588 ## targets-by-mcu : make all targets that have a MCU_TYPE mcu
590 $(V1
) for target in
$(VALID_TARGETS
); do \
591 TARGET_MCU_TYPE
=$$($(MAKE
) -s TARGET
=$${target} target-mcu
); \
592 if
[ "$${TARGET_MCU_TYPE}" = "$${MCU_TYPE}" ]; then \
593 if
[ "$${DO_BUILD}" = 1 ]; then \
594 echo
"Building target $${target}..."; \
595 $(MAKE
) TARGET
=$${target}; \
596 if
[ $$?
-ne
0 ]; then \
597 echo
"Building target $${target} failed, aborting."; \
601 echo
-n
"$${target} "; \
607 ## targets-f3 : make all F3 targets
609 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F3 DO_BUILD
=1
612 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F3
614 ## targets-f4 : make all F4 targets
616 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F4 DO_BUILD
=1
619 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F4
621 ## targets-f7 : make all F7 targets
623 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F7 DO_BUILD
=1
626 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F7
628 ## test : run the Betaflight test suite
629 ## junittest : run the Betaflight test suite, producing Junit XML result files.
630 ## test-representative: run a representative subset of the Betaflight test suite (i.e. run all tests, but run each expanded test only for one target)
631 ## test-all: run the Betaflight test suite including all per-target expanded tests
632 test junittest test-all test-representative
:
633 $(V0
) cd src
/test && $(MAKE
) $@
635 ## test_help : print the help message for the test suite (including a list of the available tests)
637 $(V0
) cd src
/test && $(MAKE
) help
639 ## test_% : run test 'test_%' from the test suite
641 $(V0
) cd src
/test && $(MAKE
) $@
644 check-target-independence
:
645 $(V1
) for test_target in
$(VALID_TARGETS
); do \
646 FOUND
=$$(grep
-rE
"\W$${test_target}(\W.*)?$$" src
/main | grep
-vE
"(//)|(/\*).*\W$${test_target}(\W.*)?$$" | grep
-vE
"^src/main/target"); \
647 if
[ "$${FOUND}" != "" ]; then \
648 echo
"Target dependencies for target '$${test_target}' found:"; \
654 check-fastram-usage-correctness
:
655 $(V1
) NON_TRIVIALLY_INITIALIZED
=$$(grep
-Ern
"\W?FAST_RAM_ZERO_INIT\W.*=.*" src
/main
/ | grep
-Ev
"=\s*(false|NULL|0(\.0*f?)?)\s*[,;]"); \
656 if
[ "$${NON_TRIVIALLY_INITIALIZED}" != "" ]; then \
657 echo
"Non-trivially initialized FAST_RAM_ZERO_INIT variables found, use FAST_RAM instead:"; \
658 echo
"$${NON_TRIVIALLY_INITIALIZED}"; \
661 TRIVIALLY_INITIALIZED
=$$(grep
-Ern
"\W?FAST_RAM\W.*;" src
/main
/ | grep
-v
"="); \
662 EXPLICITLY_TRIVIALLY_INITIALIZED
=$$(grep
-Ern
"\W?FAST_RAM\W.*;" src
/main
/ | grep
-E
"=\s*(false|NULL|0(\.0*f?)?)\s*[,;]"); \
663 if
[ "$${TRIVIALLY_INITIALIZED}$${EXPLICITLY_TRIVIALLY_INITIALIZED}" != "" ]; then \
664 echo
"Trivially initialized FAST_RAM variables found, use FAST_RAM_ZERO_INIT instead to save FLASH:"; \
665 echo
"$${TRIVIALLY_INITIALIZED}\n$${EXPLICITLY_TRIVIALLY_INITIALIZED}"; \
669 check-platform-included
:
670 $(V1
) PLATFORM_NOT_INCLUDED
=$$(find src
/main
-type d
-name target
-prune
-o
-type f
-name \
*.c
-exec grep
-L
"^#include \"platform.h\"" {} \
;); \
671 if
[ "$$(echo $${PLATFORM_NOT_INCLUDED} | grep -v -e '^$$' | wc -l)" -ne
0 ]; then \
672 echo
"The following compilation units do not include the required target specific configuration provided by 'platform.h':"; \
673 echo
"$${PLATFORM_NOT_INCLUDED}"; \
677 # rebuild everything when makefile changes
678 $(TARGET_OBJS
): Makefile
$(TARGET_DIR
)/target.mk
$(wildcard make
/*)
681 # include auto-generated dependencies
682 -include $(TARGET_DEPS
)