Fixed burst Dshot for pins that have no DMA available.
[betaflight.git] / Makefile
blobde84e31b92e75aa8fe9d63ed4e04a282ab3ab579
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
19 TARGET ?= BETAFLIGHTF3
21 # Compile-time options
22 OPTIONS ?=
24 # compile for OpenPilot BootLoader support
25 OPBL ?= no
27 # Debugger optons:
28 # empty - ordinary build with all optimizations enabled
29 # RELWITHDEBINFO - ordinary build with debug symbols and all optimizations enabled
30 # GDB - debug build with minimum number of optimizations
31 DEBUG ?=
33 # Insert the debugging hardfault debugger
34 # releases should not be built with this flag as it does not disable pwm output
35 DEBUG_HARDFAULTS ?=
37 # Serial port/Device for flashing
38 SERIAL_DEVICE ?= $(firstword $(wildcard /dev/ttyUSB*) no-port-found)
40 # Flash size (KB). Some low-end chips actually have more flash than advertised, use this to override.
41 FLASH_SIZE ?=
44 ###############################################################################
45 # Things that need to be maintained as the source changes
48 FORKNAME = betaflight
50 # Working directories
51 ROOT := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
52 SRC_DIR := $(ROOT)/src/main
53 OBJECT_DIR := $(ROOT)/obj/main
54 BIN_DIR := $(ROOT)/obj
55 CMSIS_DIR := $(ROOT)/lib/main/CMSIS
56 INCLUDE_DIRS := $(SRC_DIR) \
57 $(ROOT)/src/main/target \
58 $(ROOT)/src/main/startup
59 LINKER_DIR := $(ROOT)/src/main/target/link
61 ## V : Set verbosity level based on the V= parameter
62 ## V=0 Low
63 ## V=1 High
64 include $(ROOT)/make/build_verbosity.mk
66 # Build tools, so we all share the same versions
67 # import macros common to all supported build systems
68 include $(ROOT)/make/system-id.mk
70 # developer preferences, edit these at will, they'll be gitignored
71 -include $(ROOT)/make/local.mk
73 # configure some directories that are relative to wherever ROOT_DIR is located
74 ifndef TOOLS_DIR
75 TOOLS_DIR := $(ROOT)/tools
76 endif
77 BUILD_DIR := $(ROOT)/build
78 DL_DIR := $(ROOT)/downloads
80 export RM := rm
82 # import macros that are OS specific
83 include $(ROOT)/make/$(OSFAMILY).mk
85 # include the tools makefile
86 include $(ROOT)/make/tools.mk
88 # default xtal value for F4 targets
89 HSE_VALUE ?= 8000000
91 # used for turning on features like VCP and SDCARD
92 FEATURES =
94 # used to disable features based on flash space shortage (larger number => more features disabled)
95 FEATURE_CUT_LEVEL_SUPPLIED := $(FEATURE_CUT_LEVEL)
96 FEATURE_CUT_LEVEL =
98 # The list of targets to build for 'pre-push'
99 PRE_PUSH_TARGET_LIST ?= BETAFLIGHTF3 OMNIBUSF4 SPRACINGF7DUAL SITL test-representative
101 include $(ROOT)/make/targets.mk
103 REVISION := $(shell git log -1 --format="%h")
105 FC_VER_MAJOR := $(shell grep " FC_VERSION_MAJOR" src/main/build/version.h | awk '{print $$3}' )
106 FC_VER_MINOR := $(shell grep " FC_VERSION_MINOR" src/main/build/version.h | awk '{print $$3}' )
107 FC_VER_PATCH := $(shell grep " FC_VERSION_PATCH" src/main/build/version.h | awk '{print $$3}' )
109 FC_VER := $(FC_VER_MAJOR).$(FC_VER_MINOR).$(FC_VER_PATCH)
111 # Search path for sources
112 VPATH := $(SRC_DIR):$(SRC_DIR)/startup
113 USBFS_DIR = $(ROOT)/lib/main/STM32_USB-FS-Device_Driver
114 USBPERIPH_SRC = $(notdir $(wildcard $(USBFS_DIR)/src/*.c))
115 FATFS_DIR = $(ROOT)/lib/main/FatFS
116 FATFS_SRC = $(notdir $(wildcard $(FATFS_DIR)/*.c))
118 CSOURCES := $(shell find $(SRC_DIR) -name '*.c')
120 LD_FLAGS :=
123 # Default Tool options - can be overridden in {mcu}.mk files.
125 ifeq ($(DEBUG),GDB)
126 OPTIMISE_DEFAULT := -Og
128 LTO_FLAGS := $(OPTIMISE_DEFAULT)
129 DEBUG_FLAGS = -ggdb3 -DDEBUG
130 else
131 ifeq ($(DEBUG),INFO)
132 DEBUG_FLAGS = -ggdb3
133 endif
134 OPTIMISATION_BASE := -flto -fuse-linker-plugin -ffast-math
135 OPTIMISE_DEFAULT := -O2
136 OPTIMISE_SPEED := -Ofast
137 OPTIMISE_SIZE := -Os
139 LTO_FLAGS := $(OPTIMISATION_BASE) $(OPTIMISE_SPEED)
140 endif
142 VPATH := $(VPATH):$(ROOT)/make/mcu
143 VPATH := $(VPATH):$(ROOT)/make
145 # start specific includes
146 include $(ROOT)/make/mcu/$(TARGET_MCU).mk
148 # openocd specific includes
149 include $(ROOT)/make/openocd.mk
151 # Configure default flash sizes for the targets (largest size specified gets hit first) if flash not specified already.
152 ifeq ($(FLASH_SIZE),)
153 ifneq ($(TARGET_FLASH),)
154 FLASH_SIZE := $(TARGET_FLASH)
155 else
156 $(error FLASH_SIZE not configured for target $(TARGET))
157 endif
158 endif
160 DEVICE_FLAGS := $(DEVICE_FLAGS) -DFLASH_SIZE=$(FLASH_SIZE)
162 ifneq ($(HSE_VALUE),)
163 DEVICE_FLAGS := $(DEVICE_FLAGS) -DHSE_VALUE=$(HSE_VALUE)
164 endif
166 ifneq ($(FEATURE_CUT_LEVEL_SUPPLIED),)
167 DEVICE_FLAGS := $(DEVICE_FLAGS) -DFEATURE_CUT_LEVEL=$(FEATURE_CUT_LEVEL_SUPPLIED)
168 else ifneq ($(FEATURE_CUT_LEVEL),)
169 DEVICE_FLAGS := $(DEVICE_FLAGS) -DFEATURE_CUT_LEVEL=$(FEATURE_CUT_LEVEL)
170 endif
172 TARGET_DIR = $(ROOT)/src/main/target/$(BASE_TARGET)
173 TARGET_DIR_SRC = $(notdir $(wildcard $(TARGET_DIR)/*.c))
175 ifeq ($(OPBL),yes)
176 TARGET_FLAGS := -DOPBL $(TARGET_FLAGS)
177 .DEFAULT_GOAL := binary
178 else
179 .DEFAULT_GOAL := hex
180 endif
182 INCLUDE_DIRS := $(INCLUDE_DIRS) \
183 $(ROOT)/lib/main/MAVLink
185 INCLUDE_DIRS := $(INCLUDE_DIRS) \
186 $(TARGET_DIR)
188 VPATH := $(VPATH):$(TARGET_DIR)
190 include $(ROOT)/make/source.mk
192 ###############################################################################
193 # Things that might need changing to use different tools
196 # Find out if ccache is installed on the system
197 CCACHE := ccache
198 RESULT = $(shell (which $(CCACHE) > /dev/null 2>&1; echo $$?) )
199 ifneq ($(RESULT),0)
200 CCACHE :=
201 endif
203 # Tool names
204 CROSS_CC := $(CCACHE) $(ARM_SDK_PREFIX)gcc
205 CROSS_CXX := $(CCACHE) $(ARM_SDK_PREFIX)g++
206 CROSS_GDB := $(ARM_SDK_PREFIX)gdb
207 OBJCOPY := $(ARM_SDK_PREFIX)objcopy
208 OBJDUMP := $(ARM_SDK_PREFIX)objdump
209 SIZE := $(ARM_SDK_PREFIX)size
212 # Tool options.
214 CC_DEBUG_OPTIMISATION := $(OPTIMISE_DEFAULT)
215 CC_DEFAULT_OPTIMISATION := $(OPTIMISATION_BASE) $(OPTIMISE_DEFAULT)
216 CC_SPEED_OPTIMISATION := $(OPTIMISATION_BASE) $(OPTIMISE_SPEED)
217 CC_SIZE_OPTIMISATION := $(OPTIMISATION_BASE) $(OPTIMISE_SIZE)
218 CC_NO_OPTIMISATION :=
220 CFLAGS += $(ARCH_FLAGS) \
221 $(addprefix -D,$(OPTIONS)) \
222 $(addprefix -I,$(INCLUDE_DIRS)) \
223 $(DEBUG_FLAGS) \
224 -std=gnu11 \
225 -Wall -Wextra -Wunsafe-loop-optimizations -Wdouble-promotion \
226 -ffunction-sections \
227 -fdata-sections \
228 -fno-common \
229 -pedantic \
230 $(DEVICE_FLAGS) \
231 -D_GNU_SOURCE \
232 -DUSE_STDPERIPH_DRIVER \
233 -D$(TARGET) \
234 $(TARGET_FLAGS) \
235 -D'__FORKNAME__="$(FORKNAME)"' \
236 -D'__TARGET__="$(TARGET)"' \
237 -D'__REVISION__="$(REVISION)"' \
238 -save-temps=obj \
239 -MMD -MP \
240 $(EXTRA_FLAGS)
242 ASFLAGS = $(ARCH_FLAGS) \
243 $(DEBUG_FLAGS) \
244 -x assembler-with-cpp \
245 $(addprefix -I,$(INCLUDE_DIRS)) \
246 -MMD -MP
248 ifeq ($(LD_FLAGS),)
249 LD_FLAGS = -lm \
250 -nostartfiles \
251 --specs=nano.specs \
252 -lc \
253 -lnosys \
254 $(ARCH_FLAGS) \
255 $(LTO_FLAGS) \
256 $(DEBUG_FLAGS) \
257 -static \
258 -Wl,-gc-sections,-Map,$(TARGET_MAP) \
259 -Wl,-L$(LINKER_DIR) \
260 -Wl,--cref \
261 -Wl,--no-wchar-size-warning \
262 -Wl,--print-memory-usage \
263 -T$(LD_SCRIPT)
264 endif
266 ###############################################################################
267 # No user-serviceable parts below
268 ###############################################################################
270 CPPCHECK = cppcheck $(CSOURCES) --enable=all --platform=unix64 \
271 --std=c99 --inline-suppr --quiet --force \
272 $(addprefix -I,$(INCLUDE_DIRS)) \
273 -I/usr/include -I/usr/include/linux
276 # Things we will build
278 TARGET_BIN = $(BIN_DIR)/$(FORKNAME)_$(FC_VER)_$(TARGET).bin
279 TARGET_HEX = $(BIN_DIR)/$(FORKNAME)_$(FC_VER)_$(TARGET).hex
280 TARGET_ELF = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET).elf
281 TARGET_LST = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET).lst
282 TARGET_OBJS = $(addsuffix .o,$(addprefix $(OBJECT_DIR)/$(TARGET)/,$(basename $(SRC))))
283 TARGET_DEPS = $(addsuffix .d,$(addprefix $(OBJECT_DIR)/$(TARGET)/,$(basename $(SRC))))
284 TARGET_MAP = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET).map
287 CLEAN_ARTIFACTS := $(TARGET_BIN)
288 CLEAN_ARTIFACTS += $(TARGET_HEX)
289 CLEAN_ARTIFACTS += $(TARGET_ELF) $(TARGET_OBJS) $(TARGET_MAP)
290 CLEAN_ARTIFACTS += $(TARGET_LST)
292 # Make sure build date and revision is updated on every incremental build
293 $(OBJECT_DIR)/$(TARGET)/build/version.o : $(SRC)
295 # List of buildable ELF files and their object dependencies.
296 # It would be nice to compute these lists, but that seems to be just beyond make.
298 $(TARGET_LST): $(TARGET_ELF)
299 $(V0) $(OBJDUMP) -S --disassemble $< > $@
301 $(TARGET_HEX): $(TARGET_ELF)
302 @echo "Creating HEX $(TARGET_HEX)" "$(STDOUT)"
303 $(V1) $(OBJCOPY) -O ihex --set-start 0x8000000 $< $@
305 $(TARGET_BIN): $(TARGET_ELF)
306 @echo "Creating BIN $(TARGET_BIN)" "$(STDOUT)"
307 $(V1) $(OBJCOPY) -O binary $< $@
309 $(TARGET_ELF): $(TARGET_OBJS) $(LD_SCRIPT)
310 @echo "Linking $(TARGET)" "$(STDOUT)"
311 $(V1) $(CROSS_CC) -o $@ $(filter-out %.ld,$^) $(LD_FLAGS)
312 $(V1) $(SIZE) $(TARGET_ELF)
314 # Compile
315 ifeq ($(DEBUG),GDB)
316 $(OBJECT_DIR)/$(TARGET)/%.o: %.c
317 $(V1) mkdir -p $(dir $@)
318 $(V1) $(if $(findstring $<,$(NOT_OPTIMISED_SRC)), \
319 echo "%% (not optimised) $<" "$(STDOUT)" && \
320 $(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_NO_OPTIMISATION) $< \
322 echo "%% (debug) $<" "$(STDOUT)" && \
323 $(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_DEBUG_OPTIMISATION) $< \
325 else
326 $(OBJECT_DIR)/$(TARGET)/%.o: %.c
327 $(V1) mkdir -p $(dir $@)
328 $(V1) $(if $(findstring $<,$(NOT_OPTIMISED_SRC)), \
329 echo "%% (not optimised) $<" "$(STDOUT)" && \
330 $(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_NO_OPTIMISATION) $< \
332 $(if $(findstring $(subst ./src/main/,,$<),$(SPEED_OPTIMISED_SRC)), \
333 echo "%% (speed optimised) $<" "$(STDOUT)" && \
334 $(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_SPEED_OPTIMISATION) $< \
336 $(if $(findstring $(subst ./src/main/,,$<),$(SIZE_OPTIMISED_SRC)), \
337 echo "%% (size optimised) $<" "$(STDOUT)" && \
338 $(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_SIZE_OPTIMISATION) $< \
340 echo "%% (optimised) $<" "$(STDOUT)" && \
341 $(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_DEFAULT_OPTIMISATION) $< \
345 endif
347 # Assemble
348 $(OBJECT_DIR)/$(TARGET)/%.o: %.s
349 $(V1) mkdir -p $(dir $@)
350 @echo "%% $(notdir $<)" "$(STDOUT)"
351 $(V1) $(CROSS_CC) -c -o $@ $(ASFLAGS) $<
353 $(OBJECT_DIR)/$(TARGET)/%.o: %.S
354 $(V1) mkdir -p $(dir $@)
355 @echo "%% $(notdir $<)" "$(STDOUT)"
356 $(V1) $(CROSS_CC) -c -o $@ $(ASFLAGS) $<
359 ## all : Build all targets (excluding unsupported)
360 all: $(SUPPORTED_TARGETS)
362 ## all_with_unsupported : Build all targets (including unsupported)
363 all_with_unsupported: $(VALID_TARGETS)
365 ## unsupported : Build unsupported targets
366 unsupported: $(UNSUPPORTED_TARGETS)
368 ## pre-push : The minimum verification that should be run before pushing, to check if CI has a chance of succeeding
369 pre-push:
370 $(MAKE) $(addprefix clean_,$(PRE_PUSH_TARGET_LIST)) $(PRE_PUSH_TARGET_LIST) EXTRA_FLAGS=-Werror
372 ## official : Build all official (travis) targets
373 official: $(OFFICIAL_TARGETS)
375 ## targets-group-1 : build some targets
376 targets-group-1: $(GROUP_1_TARGETS)
378 ## targets-group-2 : build some targets
379 targets-group-2: $(GROUP_2_TARGETS)
381 ## targets-group-3 : build some targets
382 targets-group-3: $(GROUP_3_TARGETS)
384 ## targets-group-3 : build some targets
385 targets-group-4: $(GROUP_4_TARGETS)
387 ## targets-group-rest: build the rest of the targets (not listed in group 1, 2 or 3)
388 targets-group-rest: $(GROUP_OTHER_TARGETS)
390 $(VALID_TARGETS):
391 $(V0) @echo "Building $@" && \
392 $(MAKE) binary hex TARGET=$@ && \
393 echo "Building $@ succeeded."
395 $(NOBUILD_TARGETS):
396 $(MAKE) TARGET=$@
398 CLEAN_TARGETS = $(addprefix clean_,$(VALID_TARGETS) )
399 TARGETS_CLEAN = $(addsuffix _clean,$(VALID_TARGETS) )
401 ## clean : clean up temporary / machine-generated files
402 clean:
403 @echo "Cleaning $(TARGET)"
404 $(V0) rm -f $(CLEAN_ARTIFACTS)
405 $(V0) rm -rf $(OBJECT_DIR)/$(TARGET)
406 @echo "Cleaning $(TARGET) succeeded."
408 ## clean_test : clean up temporary / machine-generated files (tests)
409 clean_test-%:
410 $(MAKE) clean_test
412 clean_test:
413 $(V0) cd src/test && $(MAKE) clean || true
415 ## clean_<TARGET> : clean up one specific target
416 $(CLEAN_TARGETS):
417 $(V0) $(MAKE) -j TARGET=$(subst clean_,,$@) clean
419 ## <TARGET>_clean : clean up one specific target (alias for above)
420 $(TARGETS_CLEAN):
421 $(V0) $(MAKE) -j TARGET=$(subst _clean,,$@) clean
423 ## clean_all : clean all valid targets
424 clean_all: $(CLEAN_TARGETS)
426 ## all_clean : clean all valid targets (alias for above)
427 all_clean: $(TARGETS_CLEAN)
430 flash_$(TARGET): $(TARGET_HEX)
431 $(V0) stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
432 $(V0) echo -n 'R' >$(SERIAL_DEVICE)
433 $(V0) stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
435 ## flash : flash firmware (.hex) onto flight controller
436 flash: flash_$(TARGET)
438 st-flash_$(TARGET): $(TARGET_BIN)
439 $(V0) st-flash --reset write $< 0x08000000
441 ## st-flash : flash firmware (.bin) onto flight controller
442 st-flash: st-flash_$(TARGET)
444 ifneq ($(OPENOCD_COMMAND),)
445 openocd-gdb: $(TARGET_ELF)
446 $(V0) $(OPENOCD_COMMAND) & $(CROSS_GDB) $(TARGET_ELF) -ex "target remote localhost:3333" -ex "load"
447 endif
449 binary:
450 $(V0) $(MAKE) -j $(TARGET_BIN)
452 hex:
453 $(V0) $(MAKE) -j $(TARGET_HEX)
455 unbrick_$(TARGET): $(TARGET_HEX)
456 $(V0) stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
457 $(V0) stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
459 ## unbrick : unbrick flight controller
460 unbrick: unbrick_$(TARGET)
462 ## cppcheck : run static analysis on C source code
463 cppcheck: $(CSOURCES)
464 $(V0) $(CPPCHECK)
466 cppcheck-result.xml: $(CSOURCES)
467 $(V0) $(CPPCHECK) --xml-version=2 2> cppcheck-result.xml
469 # mkdirs
470 $(DL_DIR):
471 mkdir -p $@
473 $(TOOLS_DIR):
474 mkdir -p $@
476 $(BUILD_DIR):
477 mkdir -p $@
479 ## version : print firmware version
480 version:
481 @echo $(FC_VER)
483 ## help : print this help message and exit
484 help: Makefile make/tools.mk
485 @echo ""
486 @echo "Makefile for the $(FORKNAME) firmware"
487 @echo ""
488 @echo "Usage:"
489 @echo " make [V=<verbosity>] [TARGET=<target>] [OPTIONS=\"<options>\"]"
490 @echo "Or:"
491 @echo " make <target> [V=<verbosity>] [OPTIONS=\"<options>\"]"
492 @echo ""
493 @echo "Valid TARGET values are: $(VALID_TARGETS)"
494 @echo ""
495 @sed -n 's/^## //p' $?
497 ## targets : print a list of all valid target platforms (for consumption by scripts)
498 targets:
499 @echo "Valid targets: $(VALID_TARGETS)"
500 @echo "Supported targets: $(SUPPORTED_TARGETS)"
501 @echo "Unsupported targets: $(UNSUPPORTED_TARGETS)"
502 @echo "Target: $(TARGET)"
503 @echo "Base target: $(BASE_TARGET)"
504 @echo "targets-group-1: $(GROUP_1_TARGETS)"
505 @echo "targets-group-2: $(GROUP_2_TARGETS)"
506 @echo "targets-group-3: $(GROUP_3_TARGETS)"
507 @echo "targets-group-4: $(GROUP_4_TARGETS)"
508 @echo "targets-group-rest: $(GROUP_OTHER_TARGETS)"
510 @echo "targets-group-1: $(words $(GROUP_1_TARGETS)) targets"
511 @echo "targets-group-2: $(words $(GROUP_2_TARGETS)) targets"
512 @echo "targets-group-3: $(words $(GROUP_3_TARGETS)) targets"
513 @echo "targets-group-4: $(words $(GROUP_4_TARGETS)) targets"
514 @echo "targets-group-rest: $(words $(GROUP_OTHER_TARGETS)) targets"
515 @echo "total in all groups $(words $(SUPPORTED_TARGETS)) targets"
517 ## target-mcu : print the MCU type of the target
518 target-mcu:
519 @echo $(TARGET_MCU)
521 ## targets-by-mcu : make all targets that have a MCU_TYPE mcu
522 targets-by-mcu:
523 $(V1) for target in $(VALID_TARGETS); do \
524 TARGET_MCU_TYPE=$$($(MAKE) -s TARGET=$${target} target-mcu); \
525 if [ "$${TARGET_MCU_TYPE}" = "$${MCU_TYPE}" ]; then \
526 if [ "$${DO_BUILD}" = 1 ]; then \
527 echo "Building target $${target}..."; \
528 $(MAKE) TARGET=$${target}; \
529 if [ $$? -ne 0 ]; then \
530 echo "Building target $${target} failed, aborting."; \
531 exit 1; \
532 fi; \
533 else \
534 echo -n "$${target} "; \
535 fi; \
536 fi; \
537 done
538 @echo
540 ## targets-f3 : make all F3 targets
541 targets-f3:
542 $(V1) $(MAKE) -s targets-by-mcu MCU_TYPE=STM32F3 DO_BUILD=1
544 targets-f3-print:
545 $(V1) $(MAKE) -s targets-by-mcu MCU_TYPE=STM32F3
547 ## targets-f4 : make all F4 targets
548 targets-f4:
549 $(V1) $(MAKE) -s targets-by-mcu MCU_TYPE=STM32F4 DO_BUILD=1
551 targets-f4-print:
552 $(V1) $(MAKE) -s targets-by-mcu MCU_TYPE=STM32F4
554 ## targets-f7 : make all F7 targets
555 targets-f7:
556 $(V1) $(MAKE) -s targets-by-mcu MCU_TYPE=STM32F7 DO_BUILD=1
558 targets-f7-print:
559 $(V1) $(MAKE) -s targets-by-mcu MCU_TYPE=STM32F7
561 ## test : run the Betaflight test suite
562 ## junittest : run the Betaflight test suite, producing Junit XML result files.
563 ## 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)
564 ## test-all: run the Betaflight test suite including all per-target expanded tests
565 test junittest test-all test-representative:
566 $(V0) cd src/test && $(MAKE) $@
568 ## test_help : print the help message for the test suite (including a list of the available tests)
569 test_help:
570 $(V0) cd src/test && $(MAKE) help
572 ## test_% : run test 'test_%' from the test suite
573 test_%:
574 $(V0) cd src/test && $(MAKE) $@
577 check-target-independence:
578 $(V1) for test_target in $(VALID_TARGETS); do \
579 FOUND=$$(grep -rE "\W$${test_target}(\W.*)?$$" src/main | grep -vE "(//)|(/\*).*\W$${test_target}(\W.*)?$$" | grep -vE "^src/main/target"); \
580 if [ "$${FOUND}" != "" ]; then \
581 echo "Target dependencies for target '$${test_target}' found:"; \
582 echo "$${FOUND}"; \
583 exit 1; \
584 fi; \
585 done
587 check-fastram-usage-correctness:
588 $(V1) NON_TRIVIALLY_INITIALIZED=$$(grep -Ern "\W?FAST_RAM_ZERO_INIT\W.*=.*" src/main/ | grep -Ev "=\s*(false|NULL|0(\.0*f?)?)\s*[,;]"); \
589 if [ "$${NON_TRIVIALLY_INITIALIZED}" != "" ]; then \
590 echo "Non-trivially initialized FAST_RAM_ZERO_INIT variables found, use FAST_RAM instead:"; \
591 echo "$${NON_TRIVIALLY_INITIALIZED}"; \
592 exit 1; \
593 fi; \
594 TRIVIALLY_INITIALIZED=$$(grep -Ern "\W?FAST_RAM\W.*;" src/main/ | grep -v "="); \
595 EXPLICITLY_TRIVIALLY_INITIALIZED=$$(grep -Ern "\W?FAST_RAM\W.*;" src/main/ | grep -E "=\s*(false|NULL|0(\.0*f?)?)\s*[,;]"); \
596 if [ "$${TRIVIALLY_INITIALIZED}$${EXPLICITLY_TRIVIALLY_INITIALIZED}" != "" ]; then \
597 echo "Trivially initialized FAST_RAM variables found, use FAST_RAM_ZERO_INIT instead to save FLASH:"; \
598 echo "$${TRIVIALLY_INITIALIZED}\n$${EXPLICITLY_TRIVIALLY_INITIALIZED}"; \
599 exit 1; \
602 check-platform-included:
603 $(V1) PLATFORM_NOT_INCLUDED=$$(find src/main -type d -name target -prune -o -type f -name \*.c -exec grep -L "^#include \"platform.h\"" {} \;); \
604 if [ "$$(echo $${PLATFORM_NOT_INCLUDED} | grep -v -e '^$$' | wc -l)" -ne 0 ]; then \
605 echo "The following compilation units do not include the required target specific configuration provided by 'platform.h':"; \
606 echo "$${PLATFORM_NOT_INCLUDED}"; \
607 exit 1; \
610 # rebuild everything when makefile changes
611 $(TARGET_OBJS): Makefile $(TARGET_DIR)/target.mk $(wildcard make/*)
614 # include auto-generated dependencies
615 -include $(TARGET_DEPS)