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
30 # compile for target loaded into RAM
34 # empty - ordinary build with all optimizations enabled
35 # RELWITHDEBINFO - ordinary build with debug symbols and all optimizations enabled
36 # GDB - debug build with minimum number of optimizations
39 # Insert the debugging hardfault debugger
40 # releases should not be built with this flag as it does not disable pwm output
43 # Serial port/Device for flashing
44 SERIAL_DEVICE ?
= $(firstword $(wildcard /dev
/ttyACM
*) $(firstword $(wildcard /dev
/ttyUSB
*) no-port-found
))
46 # Flash size (KB). Some low-end chips actually have more flash than advertised, use this to override.
50 ###############################################################################
51 # Things that need to be maintained as the source changes
57 ROOT
:= $(patsubst %/,%,$(dir $(lastword
$(MAKEFILE_LIST
))))
58 SRC_DIR
:= $(ROOT
)/src
/main
59 OBJECT_DIR
:= $(ROOT
)/obj
/main
60 BIN_DIR
:= $(ROOT
)/obj
61 CMSIS_DIR
:= $(ROOT
)/lib
/main
/CMSIS
62 INCLUDE_DIRS
:= $(SRC_DIR
) \
63 $(ROOT
)/src
/main
/target \
64 $(ROOT
)/src
/main
/startup
65 LINKER_DIR
:= $(ROOT
)/src
/link
67 ## V : Set verbosity level based on the V= parameter
70 include $(ROOT
)/make
/build_verbosity.mk
72 # Build tools, so we all share the same versions
73 # import macros common to all supported build systems
74 include $(ROOT
)/make
/system-id.mk
76 # developer preferences, edit these at will, they'll be gitignored
77 -include $(ROOT
)/make
/local.mk
79 # configure some directories that are relative to wherever ROOT_DIR is located
81 TOOLS_DIR
:= $(ROOT
)/tools
83 BUILD_DIR
:= $(ROOT
)/build
84 DL_DIR
:= $(ROOT
)/downloads
88 # import macros that are OS specific
89 include $(ROOT
)/make
/$(OSFAMILY
).mk
91 # include the tools makefile
92 include $(ROOT
)/make
/tools.mk
94 # default xtal value for F4 targets
97 # used for turning on features like VCP and SDCARD
100 # used to disable features based on flash space shortage (larger number => more features disabled)
101 FEATURE_CUT_LEVEL_SUPPLIED
:= $(FEATURE_CUT_LEVEL
)
104 # The list of targets to build for 'pre-push'
105 PRE_PUSH_TARGET_LIST ?
= OMNIBUSF4 STM32F405 SPRACINGF7DUAL STM32F7X2 SITL test-representative
107 include $(ROOT
)/make
/targets.mk
109 REVISION
:= $(shell git log
-1 --format
="%h")
111 FC_VER_MAJOR
:= $(shell grep
" FC_VERSION_MAJOR" src
/main
/build
/version.h | awk
'{print $$3}' )
112 FC_VER_MINOR
:= $(shell grep
" FC_VERSION_MINOR" src
/main
/build
/version.h | awk
'{print $$3}' )
113 FC_VER_PATCH
:= $(shell grep
" FC_VERSION_PATCH" src
/main
/build
/version.h | awk
'{print $$3}' )
115 FC_VER
:= $(FC_VER_MAJOR
).
$(FC_VER_MINOR
).
$(FC_VER_PATCH
)
117 # Search path for sources
118 VPATH
:= $(SRC_DIR
):$(SRC_DIR
)/startup
119 USBFS_DIR
= $(ROOT
)/lib
/main
/STM32_USB-FS-Device_Driver
120 USBPERIPH_SRC
= $(notdir $(wildcard $(USBFS_DIR
)/src
/*.c
))
121 FATFS_DIR
= $(ROOT
)/lib
/main
/FatFS
122 FATFS_SRC
= $(notdir $(wildcard $(FATFS_DIR
)/*.c
))
124 CSOURCES
:= $(shell find
$(SRC_DIR
) -name
'*.c')
129 # Default Tool options - can be overridden in {mcu}.mk files.
132 OPTIMISE_DEFAULT
:= -Og
134 LTO_FLAGS
:= $(OPTIMISE_DEFAULT
)
135 DEBUG_FLAGS
= -ggdb3
-DDEBUG
140 OPTIMISATION_BASE
:= -flto
-fuse-linker-plugin
-ffast-math
141 OPTIMISE_DEFAULT
:= -O2
142 OPTIMISE_SPEED
:= -Ofast
145 LTO_FLAGS
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SPEED
)
148 VPATH
:= $(VPATH
):$(ROOT
)/make
/mcu
149 VPATH
:= $(VPATH
):$(ROOT
)/make
151 # start specific includes
152 include $(ROOT
)/make
/mcu
/$(TARGET_MCU
).mk
154 # openocd specific includes
155 include $(ROOT
)/make
/openocd.mk
157 # Configure default flash sizes for the targets (largest size specified gets hit first) if flash not specified already.
158 ifeq ($(FLASH_SIZE
),)
159 ifneq ($(TARGET_FLASH
),)
160 FLASH_SIZE
:= $(TARGET_FLASH
)
162 $(error FLASH_SIZE not configured for target
$(TARGET
))
166 DEVICE_FLAGS
:= $(DEVICE_FLAGS
) -DFLASH_SIZE
=$(FLASH_SIZE
)
168 ifneq ($(HSE_VALUE
),)
169 DEVICE_FLAGS
:= $(DEVICE_FLAGS
) -DHSE_VALUE
=$(HSE_VALUE
)
172 ifneq ($(FEATURE_CUT_LEVEL_SUPPLIED
),)
173 DEVICE_FLAGS
:= $(DEVICE_FLAGS
) -DFEATURE_CUT_LEVEL
=$(FEATURE_CUT_LEVEL_SUPPLIED
)
174 else ifneq ($(FEATURE_CUT_LEVEL
),)
175 DEVICE_FLAGS
:= $(DEVICE_FLAGS
) -DFEATURE_CUT_LEVEL
=$(FEATURE_CUT_LEVEL
)
178 TARGET_DIR
= $(ROOT
)/src
/main
/target
/$(BASE_TARGET
)
179 TARGET_DIR_SRC
= $(notdir $(wildcard $(TARGET_DIR
)/*.c
))
182 TARGET_FLAGS
:= -DOPBL
$(TARGET_FLAGS
)
183 .DEFAULT_GOAL
:= binary
188 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
189 $(ROOT
)/lib
/main
/MAVLink
191 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
194 VPATH
:= $(VPATH
):$(TARGET_DIR
)
196 include $(ROOT
)/make
/source.mk
198 ###############################################################################
199 # Things that might need changing to use different tools
202 # Find out if ccache is installed on the system
204 RESULT
= $(shell (which
$(CCACHE
) > /dev
/null
2>&1; echo
$$?
) )
210 CROSS_CC
:= $(CCACHE
) $(ARM_SDK_PREFIX
)gcc
211 CROSS_CXX
:= $(CCACHE
) $(ARM_SDK_PREFIX
)g
++
212 CROSS_GDB
:= $(ARM_SDK_PREFIX
)gdb
213 OBJCOPY
:= $(ARM_SDK_PREFIX
)objcopy
214 OBJDUMP
:= $(ARM_SDK_PREFIX
)objdump
215 SIZE
:= $(ARM_SDK_PREFIX
)size
220 CC_DEBUG_OPTIMISATION
:= $(OPTIMISE_DEFAULT
)
221 CC_DEFAULT_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_DEFAULT
)
222 CC_SPEED_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SPEED
)
223 CC_SIZE_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SIZE
)
224 CC_NO_OPTIMISATION
:=
226 CFLAGS
+= $(ARCH_FLAGS
) \
227 $(addprefix -D
,$(OPTIONS
)) \
228 $(addprefix -I
,$(INCLUDE_DIRS
)) \
231 -Wall
-Wextra
-Wunsafe-loop-optimizations
-Wdouble-promotion \
232 -ffunction-sections \
238 -DUSE_STDPERIPH_DRIVER \
241 -D
'__FORKNAME__="$(FORKNAME)"' \
242 -D
'__TARGET__="$(TARGET)"' \
243 -D
'__REVISION__="$(REVISION)"' \
248 ASFLAGS
= $(ARCH_FLAGS
) \
250 -x assembler-with-cpp \
251 $(addprefix -I
,$(INCLUDE_DIRS
)) \
264 -Wl
,-gc-sections
,-Map
,$(TARGET_MAP
) \
265 -Wl
,-L
$(LINKER_DIR
) \
267 -Wl
,--no-wchar-size-warning \
268 -Wl
,--print-memory-usage \
272 ###############################################################################
273 # No user-serviceable parts below
274 ###############################################################################
276 CPPCHECK
= cppcheck
$(CSOURCES
) --enable
=all --platform
=unix64 \
277 --std
=c99
--inline-suppr
--quiet
--force \
278 $(addprefix -I
,$(INCLUDE_DIRS
)) \
279 -I
/usr
/include -I
/usr
/include/linux
282 # Things we will build
284 TARGET_S19
= $(BIN_DIR
)/$(FORKNAME
)_
$(FC_VER
)_
$(TARGET
).s19
285 TARGET_BIN
= $(BIN_DIR
)/$(FORKNAME
)_
$(FC_VER
)_
$(TARGET
).bin
286 TARGET_HEX
= $(BIN_DIR
)/$(FORKNAME
)_
$(FC_VER
)_
$(TARGET
).hex
287 TARGET_ELF
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).elf
288 TARGET_EXST_ELF
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
)_EXST.elf
289 TARGET_UNPATCHED_BIN
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
)_UNPATCHED.bin
290 TARGET_LST
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).lst
291 TARGET_OBJS
= $(addsuffix .o
,$(addprefix $(OBJECT_DIR
)/$(TARGET
)/,$(basename $(SRC
))))
292 TARGET_DEPS
= $(addsuffix .d
,$(addprefix $(OBJECT_DIR
)/$(TARGET
)/,$(basename $(SRC
))))
293 TARGET_MAP
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).map
295 TARGET_EXST_HASH_SECTION_FILE
= $(OBJECT_DIR
)/$(TARGET
)/exst_hash_section.bin
297 CLEAN_ARTIFACTS
:= $(TARGET_BIN
)
298 CLEAN_ARTIFACTS
+= $(TARGET_HEX
)
299 CLEAN_ARTIFACTS
+= $(TARGET_ELF
) $(TARGET_OBJS
) $(TARGET_MAP
)
300 CLEAN_ARTIFACTS
+= $(TARGET_LST
)
302 # Make sure build date and revision is updated on every incremental build
303 $(OBJECT_DIR
)/$(TARGET
)/build
/version.o
: $(SRC
)
305 # List of buildable ELF files and their object dependencies.
306 # It would be nice to compute these lists, but that seems to be just beyond make.
308 $(TARGET_LST
): $(TARGET_ELF
)
309 $(V0
) $(OBJDUMP
) -S
--disassemble
$< > $@
312 $(TARGET_S19
): $(TARGET_ELF
)
313 @echo
"Creating srec/S19 $(TARGET_S19)" "$(STDOUT)"
314 $(V1
) $(OBJCOPY
) --output-target
=srec
$(TARGET_S19
)
317 $(TARGET_BIN
): $(TARGET_ELF
)
318 @echo
"Creating BIN $(TARGET_BIN)" "$(STDOUT)"
319 $(V1
) $(OBJCOPY
) -O binary
$< $@
321 $(TARGET_HEX
): $(TARGET_ELF
)
322 @echo
"Creating HEX $(TARGET_HEX)" "$(STDOUT)"
323 $(V1
) $(OBJCOPY
) -O ihex
--set-start
0x8000000 $< $@
326 CLEAN_ARTIFACTS
+= $(TARGET_UNPATCHED_BIN
) $(TARGET_EXST_HASH_SECTION_FILE
) $(TARGET_EXST_ELF
)
328 $(TARGET_UNPATCHED_BIN
): $(TARGET_ELF
)
329 @echo
"Creating BIN (without checksum) $(TARGET_UNPATCHED_BIN)" "$(STDOUT)"
330 $(V1
) $(OBJCOPY
) -O binary
$< $@
332 $(TARGET_BIN
): $(TARGET_UNPATCHED_BIN
)
333 @echo
"Creating EXST $(TARGET_BIN)" "$(STDOUT)"
334 # Linker script should allow .bin generation from a .elf which results in a file that is the same length as the FIRMWARE_SIZE.
335 # These 'dd' commands will pad a short binary to length FIRMWARE_SIZE.
336 $(V1
) dd if
=/dev
/zero ibs
=1k count
=$(FIRMWARE_SIZE
) of
=$(TARGET_BIN
)
337 $(V1
) dd if
=$(TARGET_UNPATCHED_BIN
) of
=$(TARGET_BIN
) conv
=notrunc
339 @echo
"Generating MD5 hash of binary" "$(STDOUT)"
340 $(V1
) openssl dgst
-md5
$(TARGET_BIN
) > $(TARGET_UNPATCHED_BIN
).md5
342 @echo
"Patching MD5 hash into binary" "$(STDOUT)"
343 $(V1
) cat
$(TARGET_UNPATCHED_BIN
).md5 | awk
'{printf("%08x: %s",(1024*$(FIRMWARE_SIZE))-16,$$2);}' | xxd
-r
- $(TARGET_BIN
)
344 $(V1
) echo
$(FIRMWARE_SIZE
) | awk
'{printf("-s 0x%08x -l 16 -c 16 %s",(1024*$$1)-16,"$(TARGET_BIN)");}' | xargs xxd
346 @echo
"Patching MD5 hash into exst elf" "$(STDOUT)"
347 $(OBJCOPY
) $(TARGET_ELF
) --dump-section .exst_hash
=$(TARGET_EXST_HASH_SECTION_FILE
)
348 $(V1
) cat
$(TARGET_UNPATCHED_BIN
).md5 | awk
'{printf("%08x: %s",64-16,$$2);}' | xxd
-r
- $(TARGET_EXST_HASH_SECTION_FILE
)
349 $(OBJCOPY
) $(TARGET_ELF
) $(TARGET_EXST_ELF
) --update-section .exst_hash
=$(TARGET_EXST_HASH_SECTION_FILE
)
351 $(TARGET_HEX
): $(TARGET_BIN
)
352 @echo
"Creating EXST HEX from patched EXST ELF $(TARGET_HEX)" "$(STDOUT)"
353 $(V1
) $(OBJCOPY
) -O ihex
--set-start
0x8000000 $(TARGET_EXST_ELF
) $@
357 $(TARGET_ELF
): $(TARGET_OBJS
) $(LD_SCRIPT
)
358 @echo
"Linking $(TARGET)" "$(STDOUT)"
359 $(V1
) $(CROSS_CC
) -o
$@
$(filter-out %.
ld,$^
) $(LD_FLAGS
)
360 $(V1
) $(SIZE
) $(TARGET_ELF
)
364 ## compile_file takes two arguments: (1) optimisation description string and (2) optimisation compiler flag
366 echo
"%% ($(1)) $<" "$(STDOUT)" && \
367 $(CROSS_CC
) -c
-o
$@
$(CFLAGS
) $(2) $<
371 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.c
372 $(V1
) mkdir
-p
$(dir $@
)
373 $(V1
) $(if
$(findstring $<,$(NOT_OPTIMISED_SRC
)), \
374 $(call compile_file
,not optimised
, $(CC_NO_OPTIMISATION
)) \
376 $(call compile_file
,debug
,$(CC_DEBUG_OPTIMISATION
)) \
379 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.c
380 $(V1
) mkdir
-p
$(dir $@
)
381 $(V1
) $(if
$(findstring $<,$(NOT_OPTIMISED_SRC
)), \
382 $(call compile_file
,not optimised
,$(CC_NO_OPTIMISATION
)) \
384 $(if
$(findstring $(subst .
/src
/main
/,,$<),$(SPEED_OPTIMISED_SRC
)), \
385 $(call compile_file
,speed optimised
,$(CC_SPEED_OPTIMISATION
)) \
387 $(if
$(findstring $(subst .
/src
/main
/,,$<),$(SIZE_OPTIMISED_SRC
)), \
388 $(call compile_file
,size optimised
,$(CC_SIZE_OPTIMISATION
)) \
390 $(call compile_file
,optimised
,$(CC_DEFAULT_OPTIMISATION
)) \
397 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.s
398 $(V1
) mkdir
-p
$(dir $@
)
399 @echo
"%% $(notdir $<)" "$(STDOUT)"
400 $(V1
) $(CROSS_CC
) -c
-o
$@
$(ASFLAGS
) $<
402 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.S
403 $(V1
) mkdir
-p
$(dir $@
)
404 @echo
"%% $(notdir $<)" "$(STDOUT)"
405 $(V1
) $(CROSS_CC
) -c
-o
$@
$(ASFLAGS
) $<
408 ## all : Build all targets (excluding unsupported)
409 all: $(SUPPORTED_TARGETS
)
411 ## all_with_unsupported : Build all targets (including unsupported)
412 all_with_unsupported
: $(VALID_TARGETS
)
414 ## unsupported : Build unsupported targets
415 unsupported
: $(UNSUPPORTED_TARGETS
)
417 ## pre-push : The minimum verification that should be run before pushing, to check if CI has a chance of succeeding
419 $(MAKE
) $(addsuffix _clean
,$(PRE_PUSH_TARGET_LIST
)) $(PRE_PUSH_TARGET_LIST
) EXTRA_FLAGS
=-Werror
421 ## official : Build all official (travis) targets
422 official
: $(OFFICIAL_TARGETS
)
424 ## targets-group-1 : build some targets
425 targets-group-1
: $(GROUP_1_TARGETS
)
427 ## targets-group-2 : build some targets
428 targets-group-2
: $(GROUP_2_TARGETS
)
430 ## targets-group-3 : build some targets
431 targets-group-3
: $(GROUP_3_TARGETS
)
433 ## targets-group-3 : build some targets
434 targets-group-4
: $(GROUP_4_TARGETS
)
436 ## targets-group-rest: build the rest of the targets (not listed in group 1, 2 or 3)
437 targets-group-rest
: $(GROUP_OTHER_TARGETS
)
440 $(V0
) @echo
"Building $@" && \
441 $(MAKE
) binary hex TARGET
=$@
&& \
442 echo
"Building $@ succeeded."
447 TARGETS_CLEAN
= $(addsuffix _clean
,$(VALID_TARGETS
) )
449 ## clean : clean up temporary / machine-generated files
451 @echo
"Cleaning $(TARGET)"
452 $(V0
) rm -f
$(CLEAN_ARTIFACTS
)
453 $(V0
) rm -rf
$(OBJECT_DIR
)/$(TARGET
)
454 @echo
"Cleaning $(TARGET) succeeded."
456 ## test_clean : clean up temporary / machine-generated files (tests)
461 $(V0
) cd src
/test && $(MAKE
) clean || true
463 ## <TARGET>_clean : clean up one specific target (alias for above)
465 $(V0
) $(MAKE
) -j TARGET
=$(subst _clean
,,$@
) clean
467 ## clean_all : clean all valid targets
468 clean_all
: $(TARGETS_CLEAN
) test_clean
470 TARGETS_FLASH
= $(addsuffix _flash
,$(VALID_TARGETS
) )
472 ## <TARGET>_flash : build and flash a target
474 $(V0
) $(MAKE
) binary hex TARGET
=$(subst _flash
,,$@
)
475 ifneq (,$(findstring /dev
/ttyUSB
,$(SERIAL_DEVICE
)))
476 $(V0
) $(MAKE
) tty_flash TARGET
=$(subst _flash
,,$@
)
478 $(V0
) $(MAKE
) dfu_flash TARGET
=$(subst _flash
,,$@
)
481 ## tty_flash : flash firmware (.hex) onto flight controller via a serial port
483 $(V0
) stty
-F
$(SERIAL_DEVICE
) raw speed
115200 -crtscts cs8
-parenb
-cstopb
-ixon
484 $(V0
) echo
-n
'R' > $(SERIAL_DEVICE
)
485 $(V0
) stm32flash
-w
$(TARGET_HEX
) -v
-g
0x0 -b
115200 $(SERIAL_DEVICE
)
487 ## dfu_flash : flash firmware (.bin) onto flight controller via a DFU mode
489 ifneq (no-port-found
,$(SERIAL_DEVICE
))
490 # potentially this is because the MCU already is in DFU mode, try anyway
491 $(V0
) echo
-n
'R' > $(SERIAL_DEVICE
)
494 $(V0
) dfu-util
-a
0 -D
$(TARGET_BIN
) -s
0x08000000:leave
496 st-flash_
$(TARGET
): $(TARGET_BIN
)
497 $(V0
) st-flash
--reset write
$< 0x08000000
499 ## st-flash : flash firmware (.bin) onto flight controller
500 st-flash
: st-flash_
$(TARGET
)
502 ifneq ($(OPENOCD_COMMAND
),)
503 openocd-gdb
: $(TARGET_ELF
)
504 $(V0
) $(OPENOCD_COMMAND
) & $(CROSS_GDB
) $(TARGET_ELF
) -ex
"target remote localhost:3333" -ex
"load"
508 $(V0
) $(MAKE
) -j
$(TARGET_BIN
)
511 $(V0
) $(MAKE
) -j
$(TARGET_S19
)
514 $(V0
) $(MAKE
) -j
$(TARGET_HEX
)
516 unbrick_
$(TARGET
): $(TARGET_HEX
)
517 $(V0
) stty
-F
$(SERIAL_DEVICE
) raw speed
115200 -crtscts cs8
-parenb
-cstopb
-ixon
518 $(V0
) stm32flash
-w
$(TARGET_HEX
) -v
-g
0x0 -b
115200 $(SERIAL_DEVICE
)
520 ## unbrick : unbrick flight controller
521 unbrick
: unbrick_
$(TARGET
)
523 ## cppcheck : run static analysis on C source code
524 cppcheck
: $(CSOURCES
)
527 cppcheck-result.xml
: $(CSOURCES
)
528 $(V0
) $(CPPCHECK
) --xml-version
=2 2> cppcheck-result.xml
540 ## version : print firmware version
544 ## help : print this help message and exit
545 help
: Makefile make
/tools.mk
547 @echo
"Makefile for the $(FORKNAME) firmware"
550 @echo
" make [V=<verbosity>] [TARGET=<target>] [OPTIONS=\"<options>\"]"
552 @echo
" make <target> [V=<verbosity>] [OPTIONS=\"<options>\"]"
554 @echo
"Valid TARGET values are: $(VALID_TARGETS)"
556 @sed
-n
's/^## //p' $?
558 ## targets : print a list of all valid target platforms (for consumption by scripts)
560 @echo
"Valid targets: $(VALID_TARGETS)"
561 @echo
"Supported targets: $(SUPPORTED_TARGETS)"
562 @echo
"Unsupported targets: $(UNSUPPORTED_TARGETS)"
563 @echo
"Target: $(TARGET)"
564 @echo
"Base target: $(BASE_TARGET)"
565 @echo
"targets-group-1: $(GROUP_1_TARGETS)"
566 @echo
"targets-group-2: $(GROUP_2_TARGETS)"
567 @echo
"targets-group-3: $(GROUP_3_TARGETS)"
568 @echo
"targets-group-4: $(GROUP_4_TARGETS)"
569 @echo
"targets-group-rest: $(GROUP_OTHER_TARGETS)"
571 @echo
"targets-group-1: $(words $(GROUP_1_TARGETS)) targets"
572 @echo
"targets-group-2: $(words $(GROUP_2_TARGETS)) targets"
573 @echo
"targets-group-3: $(words $(GROUP_3_TARGETS)) targets"
574 @echo
"targets-group-4: $(words $(GROUP_4_TARGETS)) targets"
575 @echo
"targets-group-rest: $(words $(GROUP_OTHER_TARGETS)) targets"
576 @echo
"total in all groups $(words $(SUPPORTED_TARGETS)) targets"
578 ## target-mcu : print the MCU type of the target
582 ## targets-by-mcu : make all targets that have a MCU_TYPE mcu
584 $(V1
) for target in
$(VALID_TARGETS
); do \
585 TARGET_MCU_TYPE
=$$($(MAKE
) -s TARGET
=$${target} target-mcu
); \
586 if
[ "$${TARGET_MCU_TYPE}" = "$${MCU_TYPE}" ]; then \
587 if
[ "$${DO_BUILD}" = 1 ]; then \
588 echo
"Building target $${target}..."; \
589 $(MAKE
) TARGET
=$${target}; \
590 if
[ $$?
-ne
0 ]; then \
591 echo
"Building target $${target} failed, aborting."; \
595 echo
-n
"$${target} "; \
601 ## targets-f3 : make all F3 targets
603 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F3 DO_BUILD
=1
606 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F3
608 ## targets-f4 : make all F4 targets
610 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F4 DO_BUILD
=1
613 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F4
615 ## targets-f7 : make all F7 targets
617 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F7 DO_BUILD
=1
620 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F7
622 ## test : run the Betaflight test suite
623 ## junittest : run the Betaflight test suite, producing Junit XML result files.
624 ## 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)
625 ## test-all: run the Betaflight test suite including all per-target expanded tests
626 test junittest test-all test-representative
:
627 $(V0
) cd src
/test && $(MAKE
) $@
629 ## test_help : print the help message for the test suite (including a list of the available tests)
631 $(V0
) cd src
/test && $(MAKE
) help
633 ## test_% : run test 'test_%' from the test suite
635 $(V0
) cd src
/test && $(MAKE
) $@
638 check-target-independence
:
639 $(V1
) for test_target in
$(VALID_TARGETS
); do \
640 FOUND
=$$(grep
-rE
"\W$${test_target}(\W.*)?$$" src
/main | grep
-vE
"(//)|(/\*).*\W$${test_target}(\W.*)?$$" | grep
-vE
"^src/main/target"); \
641 if
[ "$${FOUND}" != "" ]; then \
642 echo
"Target dependencies for target '$${test_target}' found:"; \
648 check-fastram-usage-correctness
:
649 $(V1
) NON_TRIVIALLY_INITIALIZED
=$$(grep
-Ern
"\W?FAST_RAM_ZERO_INIT\W.*=.*" src
/main
/ | grep
-Ev
"=\s*(false|NULL|0(\.0*f?)?)\s*[,;]"); \
650 if
[ "$${NON_TRIVIALLY_INITIALIZED}" != "" ]; then \
651 echo
"Non-trivially initialized FAST_RAM_ZERO_INIT variables found, use FAST_RAM instead:"; \
652 echo
"$${NON_TRIVIALLY_INITIALIZED}"; \
655 TRIVIALLY_INITIALIZED
=$$(grep
-Ern
"\W?FAST_RAM\W.*;" src
/main
/ | grep
-v
"="); \
656 EXPLICITLY_TRIVIALLY_INITIALIZED
=$$(grep
-Ern
"\W?FAST_RAM\W.*;" src
/main
/ | grep
-E
"=\s*(false|NULL|0(\.0*f?)?)\s*[,;]"); \
657 if
[ "$${TRIVIALLY_INITIALIZED}$${EXPLICITLY_TRIVIALLY_INITIALIZED}" != "" ]; then \
658 echo
"Trivially initialized FAST_RAM variables found, use FAST_RAM_ZERO_INIT instead to save FLASH:"; \
659 echo
"$${TRIVIALLY_INITIALIZED}\n$${EXPLICITLY_TRIVIALLY_INITIALIZED}"; \
663 check-platform-included
:
664 $(V1
) PLATFORM_NOT_INCLUDED
=$$(find src
/main
-type d
-name target
-prune
-o
-type f
-name \
*.c
-exec grep
-L
"^#include \"platform.h\"" {} \
;); \
665 if
[ "$$(echo $${PLATFORM_NOT_INCLUDED} | grep -v -e '^$$' | wc -l)" -ne
0 ]; then \
666 echo
"The following compilation units do not include the required target specific configuration provided by 'platform.h':"; \
667 echo
"$${PLATFORM_NOT_INCLUDED}"; \
671 # rebuild everything when makefile changes
672 $(TARGET_OBJS
): Makefile
$(TARGET_DIR
)/target.mk
$(wildcard make
/*)
674 # include auto-generated dependencies
675 -include $(TARGET_DEPS
)