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
22 # Compile-time options
25 # compile for External Storage Bootloader support
28 # compile for target loaded into RAM
31 # reserve space for custom defaults
32 CUSTOM_DEFAULTS_EXTENDED ?
= no
35 # empty - ordinary build with all optimizations enabled
36 # INFO - ordinary build with debug symbols and all optimizations enabled
37 # GDB - debug build with minimum number of optimizations
40 # Insert the debugging hardfault debugger
41 # releases should not be built with this flag as it does not disable pwm output
44 # Serial port/Device for flashing
45 SERIAL_DEVICE ?
= $(firstword $(wildcard /dev
/ttyACM
*) $(firstword $(wildcard /dev
/ttyUSB
*) no-port-found
))
47 # 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 # pre-build sanity checks
80 include $(ROOT
)/make
/checks.mk
82 # configure some directories that are relative to wherever ROOT_DIR is located
83 TOOLS_DIR ?
= $(ROOT
)/tools
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
101 # silently ignore if the file is not present. Allows for target defaults.
102 -include $(ROOT
)/src
/main
/board
/$(BOARD
)/board.mk
105 include $(ROOT
)/make
/targets.mk
107 REVISION
:= norevision
108 ifeq ($(shell git diff
--shortstat
),)
109 REVISION
:= $(shell git log
-1 --format
="%h")
112 FC_VER_MAJOR
:= $(shell grep
" FC_VERSION_MAJOR" src
/main
/build
/version.h | awk
'{print $$3}' )
113 FC_VER_MINOR
:= $(shell grep
" FC_VERSION_MINOR" src
/main
/build
/version.h | awk
'{print $$3}' )
114 FC_VER_PATCH
:= $(shell grep
" FC_VERSION_PATCH" src
/main
/build
/version.h | awk
'{print $$3}' )
116 FC_VER
:= $(FC_VER_MAJOR
).
$(FC_VER_MINOR
).
$(FC_VER_PATCH
)
118 # Search path for sources
119 VPATH
:= $(SRC_DIR
):$(SRC_DIR
)/startup
120 FATFS_DIR
= $(ROOT
)/lib
/main
/FatFS
121 FATFS_SRC
= $(notdir $(wildcard $(FATFS_DIR
)/*.c
))
123 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
-gdwarf-5
-DDEBUG
140 OPTIMISATION_BASE
:= -flto
-fuse-linker-plugin
-ffast-math
-fmerge-all-constants
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 ($(TARGET_FLASH_SIZE
),)
159 ifneq ($(MCU_FLASH_SIZE
),)
160 TARGET_FLASH_SIZE
:= $(MCU_FLASH_SIZE
)
162 $(error MCU_FLASH_SIZE not configured for target
$(TARGET
))
166 DEVICE_FLAGS
:= $(DEVICE_FLAGS
) -DTARGET_FLASH_SIZE
=$(TARGET_FLASH_SIZE
)
168 ifneq ($(HSE_VALUE
),)
169 DEVICE_FLAGS
:= $(DEVICE_FLAGS
) -DHSE_VALUE
=$(HSE_VALUE
)
172 TARGET_DIR
= $(ROOT
)/src
/main
/target
/$(TARGET
)
173 TARGET_DIR_SRC
= $(notdir $(wildcard $(TARGET_DIR
)/*.c
))
177 ifeq ($(CUSTOM_DEFAULTS_EXTENDED
),yes
)
178 TARGET_FLAGS
+= -DUSE_CUSTOM_DEFAULTS
=
179 EXTRA_LD_FLAGS
+= -Wl
,--defsym
=USE_CUSTOM_DEFAULTS_EXTENDED
=1
182 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
183 $(ROOT
)/lib
/main
/MAVLink
185 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
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
198 RESULT
= $(shell (which
$(CCACHE
) > /dev
/null
2>&1; echo
$$?
) )
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 READELF
:= $(ARM_SDK_PREFIX
)readelf
210 SIZE
:= $(ARM_SDK_PREFIX
)size
211 DFUSE-PACK
:= src
/utils
/dfuse-pack.py
216 CC_DEBUG_OPTIMISATION
:= $(OPTIMISE_DEFAULT
)
217 CC_DEFAULT_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_DEFAULT
)
218 CC_SPEED_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SPEED
)
219 CC_SIZE_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SIZE
)
220 CC_NO_OPTIMISATION
:=
223 # Added after GCC version update, remove once the warnings have been fixed
227 EXTRA_WARNING_FLAGS
:= -Wold-style-definition
229 CFLAGS
+= $(ARCH_FLAGS
) \
230 $(addprefix -D
,$(OPTIONS
)) \
231 $(addprefix -I
,$(INCLUDE_DIRS
)) \
234 -Wall
-Wextra
-Werror
-Wpedantic
-Wunsafe-loop-optimizations
-Wdouble-promotion \
235 $(EXTRA_WARNING_FLAGS
) \
236 -ffunction-sections \
242 -DUSE_STDPERIPH_DRIVER \
245 -D
'__FORKNAME__="$(FORKNAME)"' \
246 -D
'__TARGET__="$(TARGET)"' \
247 -D
'__REVISION__="$(REVISION)"' \
252 ASFLAGS
= $(ARCH_FLAGS
) \
254 -x assembler-with-cpp \
255 $(addprefix -I
,$(INCLUDE_DIRS
)) \
268 -Wl
,-gc-sections
,-Map
,$(TARGET_MAP
) \
269 -Wl
,-L
$(LINKER_DIR
) \
271 -Wl
,--no-wchar-size-warning \
272 -Wl
,--print-memory-usage \
277 ###############################################################################
278 # No user-serviceable parts below
279 ###############################################################################
281 CPPCHECK
= cppcheck
$(CSOURCES
) --enable
=all --platform
=unix64 \
282 --std
=c99
--inline-suppr
--quiet
--force \
283 $(addprefix -I
,$(INCLUDE_DIRS
)) \
284 -I
/usr
/include -I
/usr
/include/linux
286 TARGET_BASENAME
= $(BIN_DIR
)/$(FORKNAME
)_
$(FC_VER
)_
$(TARGET
)
289 # Things we will build
291 TARGET_BIN
= $(TARGET_BASENAME
).bin
292 TARGET_HEX
= $(TARGET_BASENAME
).hex
293 TARGET_HEX_REV
= $(TARGET_BASENAME
)_
$(REVISION
).hex
294 TARGET_DFU
= $(TARGET_BASENAME
).dfu
295 TARGET_ZIP
= $(TARGET_BASENAME
).zip
296 TARGET_ELF
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).elf
297 TARGET_EXST_ELF
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
)_EXST.elf
298 TARGET_UNPATCHED_BIN
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
)_UNPATCHED.bin
299 TARGET_LST
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).lst
300 TARGET_OBJS
= $(addsuffix .o
,$(addprefix $(OBJECT_DIR
)/$(TARGET
)/,$(basename $(SRC
))))
301 TARGET_DEPS
= $(addsuffix .d
,$(addprefix $(OBJECT_DIR
)/$(TARGET
)/,$(basename $(SRC
))))
302 TARGET_MAP
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).map
304 TARGET_EXST_HASH_SECTION_FILE
= $(OBJECT_DIR
)/$(TARGET
)/exst_hash_section.bin
306 CLEAN_ARTIFACTS
:= $(TARGET_BIN
)
307 CLEAN_ARTIFACTS
+= $(TARGET_HEX_REV
) $(TARGET_HEX
)
308 CLEAN_ARTIFACTS
+= $(TARGET_ELF
) $(TARGET_OBJS
) $(TARGET_MAP
)
309 CLEAN_ARTIFACTS
+= $(TARGET_LST
)
310 CLEAN_ARTIFACTS
+= $(TARGET_DFU
)
312 # Make sure build date and revision is updated on every incremental build
313 $(OBJECT_DIR
)/$(TARGET
)/build
/version.o
: $(SRC
)
315 # List of buildable ELF files and their object dependencies.
316 # It would be nice to compute these lists, but that seems to be just beyond make.
318 $(TARGET_LST
): $(TARGET_ELF
)
319 $(V0
) $(OBJDUMP
) -S
--disassemble
$< > $@
322 $(TARGET_BIN
): $(TARGET_ELF
)
323 @echo
"Creating BIN $(TARGET_BIN)" "$(STDOUT)"
324 $(V1
) $(OBJCOPY
) -O binary
$< $@
326 $(TARGET_HEX
): $(TARGET_ELF
)
327 @echo
"Creating HEX $(TARGET_HEX)" "$(STDOUT)"
328 $(V1
) $(OBJCOPY
) -O ihex
--set-start
0x8000000 $< $@
330 $(TARGET_DFU
): $(TARGET_HEX
)
331 @echo
"Creating DFU $(TARGET_DFU)" "$(STDOUT)"
332 $(V1
) $(PYTHON
) $(DFUSE-PACK
) -i
$< $@
335 CLEAN_ARTIFACTS
+= $(TARGET_UNPATCHED_BIN
) $(TARGET_EXST_HASH_SECTION_FILE
) $(TARGET_EXST_ELF
)
337 $(TARGET_UNPATCHED_BIN
): $(TARGET_ELF
)
338 @echo
"Creating BIN (without checksum) $(TARGET_UNPATCHED_BIN)" "$(STDOUT)"
339 $(V1
) $(OBJCOPY
) -O binary
$< $@
341 $(TARGET_BIN
): $(TARGET_UNPATCHED_BIN
)
342 @echo
"Creating EXST $(TARGET_BIN)" "$(STDOUT)"
343 # Linker script should allow .bin generation from a .elf which results in a file that is the same length as the FIRMWARE_SIZE.
344 # These 'dd' commands will pad a short binary to length FIRMWARE_SIZE.
345 $(V1
) dd if
=/dev
/zero ibs
=1k count
=$(FIRMWARE_SIZE
) of
=$(TARGET_BIN
)
346 $(V1
) dd if
=$(TARGET_UNPATCHED_BIN
) of
=$(TARGET_BIN
) conv
=notrunc
348 @echo
"Generating MD5 hash of binary" "$(STDOUT)"
349 $(V1
) openssl dgst
-md5
$(TARGET_BIN
) > $(TARGET_UNPATCHED_BIN
).md5
351 @echo
"Patching MD5 hash into binary" "$(STDOUT)"
352 $(V1
) cat
$(TARGET_UNPATCHED_BIN
).md5 | awk
'{printf("%08x: %s",(1024*$(FIRMWARE_SIZE))-16,$$2);}' | xxd
-r
- $(TARGET_BIN
)
353 $(V1
) echo
$(FIRMWARE_SIZE
) | awk
'{printf("-s 0x%08x -l 16 -c 16 %s",(1024*$$1)-16,"$(TARGET_BIN)");}' | xargs xxd
355 # Note: From the objcopy manual "If you do not specify outfile, objcopy creates a temporary file and destructively renames the result with the name of infile"
356 # Due to this a temporary file must be created and removed, even though we're only extracting data from the input file.
357 # If this temporary file is NOT used the $(TARGET_ELF) is modified, and running make a second time will result in
358 # a) regeneration of $(TARGET_BIN), and
359 # b) the results of $(TARGET_BIN) will not be as expected.
360 @echo
"Extracting HASH section from unpatched EXST elf $(TARGET_ELF)" "$(STDOUT)"
361 $(OBJCOPY
) $(TARGET_ELF
) $(TARGET_EXST_ELF
).tmp
--dump-section .exst_hash
=$(TARGET_EXST_HASH_SECTION_FILE
) -j .exst_hash
362 rm $(TARGET_EXST_ELF
).tmp
364 @echo
"Patching MD5 hash into HASH section" "$(STDOUT)"
365 $(V1
) cat
$(TARGET_UNPATCHED_BIN
).md5 | awk
'{printf("%08x: %s",64-16,$$2);}' | xxd
-r
- $(TARGET_EXST_HASH_SECTION_FILE
)
367 # For some currently unknown reason, OBJCOPY, with only input/output files, will generate a file around 2GB for the H730 unless we remove an unused-section
368 # As a workaround drop the ._user_heap_stack section, which is only used during build to show errors if there's not enough space for the heap/stack.
369 # The issue can be seen with `readelf -S $(TARGET_EXST_ELF)' vs `readelf -S $(TARGET_ELF)`
370 $(V1
) @echo
"Patching updated HASH section into $(TARGET_EXST_ELF)" "$(STDOUT)"
371 $(OBJCOPY
) $(TARGET_ELF
) $(TARGET_EXST_ELF
) --remove-section ._user_heap_stack
--update-section .exst_hash
=$(TARGET_EXST_HASH_SECTION_FILE
)
373 $(V1
) $(READELF
) -S
$(TARGET_EXST_ELF
)
374 $(V1
) $(READELF
) -l
$(TARGET_EXST_ELF
)
376 $(TARGET_HEX
): $(TARGET_BIN
)
377 $(if
$(EXST_ADJUST_VMA
),,$(error
"EXST_ADJUST_VMA not specified"))
379 @echo
"Creating EXST HEX from patched EXST BIN $(TARGET_BIN), VMA Adjust $(EXST_ADJUST_VMA)" "$(STDOUT)"
380 $(V1
) $(OBJCOPY
) -I binary
-O ihex
--adjust-vma
=$(EXST_ADJUST_VMA
) $(TARGET_BIN
) $@
384 $(TARGET_ELF
): $(TARGET_OBJS
) $(LD_SCRIPT
) $(LD_SCRIPTS
)
385 @echo
"Linking $(TARGET)" "$(STDOUT)"
386 $(V1
) $(CROSS_CC
) -o
$@
$(filter-out %.
ld,$^
) $(LD_FLAGS
)
387 $(V1
) $(SIZE
) $(TARGET_ELF
)
391 ## compile_file takes two arguments: (1) optimisation description string and (2) optimisation compiler flag
393 echo
"%% ($(1)) $<" "$(STDOUT)" && \
394 $(CROSS_CC
) -c
-o
$@
$(CFLAGS
) $(2) $<
398 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.c
399 $(V1
) mkdir
-p
$(dir $@
)
400 $(V1
) $(if
$(findstring $<,$(NOT_OPTIMISED_SRC
)), \
401 $(call compile_file
,not optimised
, $(CC_NO_OPTIMISATION
)) \
403 $(call compile_file
,debug
,$(CC_DEBUG_OPTIMISATION
)) \
406 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.c
407 $(V1
) mkdir
-p
$(dir $@
)
408 $(V1
) $(if
$(findstring $<,$(NOT_OPTIMISED_SRC
)), \
409 $(call compile_file
,not optimised
,$(CC_NO_OPTIMISATION
)) \
411 $(if
$(findstring $(subst .
/src
/main
/,,$<),$(SPEED_OPTIMISED_SRC
)), \
412 $(call compile_file
,speed optimised
,$(CC_SPEED_OPTIMISATION
)) \
414 $(if
$(findstring $(subst .
/src
/main
/,,$<),$(SIZE_OPTIMISED_SRC
)), \
415 $(call compile_file
,size optimised
,$(CC_SIZE_OPTIMISATION
)) \
417 $(call compile_file
,optimised
,$(CC_DEFAULT_OPTIMISATION
)) \
424 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.s
425 $(V1
) mkdir
-p
$(dir $@
)
426 @echo
"%% $(notdir $<)" "$(STDOUT)"
427 $(V1
) $(CROSS_CC
) -c
-o
$@
$(ASFLAGS
) $<
429 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.S
430 $(V1
) mkdir
-p
$(dir $@
)
431 @echo
"%% $(notdir $<)" "$(STDOUT)"
432 $(V1
) $(CROSS_CC
) -c
-o
$@
$(ASFLAGS
) $<
435 ## all : Build all currently built targets
438 ## all_all : Build all targets (including legacy / unsupported)
439 all_all
: $(VALID_TARGETS
)
442 $(V0
) @echo
"Building $@" && \
443 $(MAKE
) hex TARGET
=$@
&& \
444 echo
"Building $@ succeeded."
449 TARGETS_CLEAN
= $(addsuffix _clean
,$(VALID_TARGETS
))
451 ## clean : clean up temporary / machine-generated files
453 @echo
"Cleaning $(TARGET)"
454 $(V0
) rm -f
$(CLEAN_ARTIFACTS
)
455 $(V0
) rm -rf
$(OBJECT_DIR
)/$(TARGET
)
456 @echo
"Cleaning $(TARGET) succeeded."
458 ## test_clean : clean up temporary / machine-generated files (tests)
463 $(V0
) cd src
/test && $(MAKE
) clean || true
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
: $(TARGETS_CLEAN
) test_clean
472 TARGETS_FLASH
= $(addsuffix _flash
,$(VALID_TARGETS
))
474 ## <TARGET>_flash : build and flash a target
476 $(V0
) $(MAKE
) hex TARGET
=$(subst _flash
,,$@
)
477 ifneq (,$(findstring /dev
/ttyUSB
,$(SERIAL_DEVICE
)))
478 $(V0
) $(MAKE
) tty_flash TARGET
=$(subst _flash
,,$@
)
480 $(V0
) $(MAKE
) dfu_flash TARGET
=$(subst _flash
,,$@
)
483 ## tty_flash : flash firmware (.hex) onto flight controller via a serial port
485 $(V0
) stty
-F
$(SERIAL_DEVICE
) raw speed
115200 -crtscts cs8
-parenb
-cstopb
-ixon
486 $(V0
) echo
-n
'R' > $(SERIAL_DEVICE
)
487 $(V0
) stm32flash
-w
$(TARGET_HEX
) -v
-g
0x0 -b
115200 $(SERIAL_DEVICE
)
489 ## dfu_flash : flash firmware (.bin) onto flight controller via a DFU mode
491 ifneq (no-port-found
,$(SERIAL_DEVICE
))
492 # potentially this is because the MCU already is in DFU mode, try anyway
493 $(V0
) echo
-n
'R' > $(SERIAL_DEVICE
)
496 $(V0
) $(MAKE
) $(TARGET_DFU
)
497 $(V0
) dfu-util
-a
0 -D
$(TARGET_DFU
) -s
:leave
499 st-flash_
$(TARGET
): $(TARGET_BIN
)
500 $(V0
) st-flash
--reset write
$< 0x08000000
502 ## st-flash : flash firmware (.bin) onto flight controller
503 st-flash
: st-flash_
$(TARGET
)
505 ifneq ($(OPENOCD_COMMAND
),)
506 openocd-gdb
: $(TARGET_ELF
)
507 $(V0
) $(OPENOCD_COMMAND
) & $(CROSS_GDB
) $(TARGET_ELF
) -ex
"target remote localhost:3333" -ex
"load"
510 TARGETS_ZIP
= $(addsuffix _zip
,$(VALID_TARGETS
))
512 ## <TARGET>_zip : build target and zip it (useful for posting to GitHub)
514 $(V0
) $(MAKE
) hex TARGET
=$(subst _zip
,,$@
)
515 $(V0
) $(MAKE
) zip TARGET
=$(subst _zip
,,$@
)
518 $(V0
) zip
$(TARGET_ZIP
) $(TARGET_HEX
)
521 $(V0
) $(MAKE
) -j
$(TARGET_BIN
)
524 $(V0
) $(MAKE
) -j
$(TARGET_HEX
)
526 TARGETS_REVISION
= $(addsuffix _rev
,$(VALID_TARGETS
))
527 ## <TARGET>_rev : build target and add revision to filename
529 $(V0
) $(MAKE
) hex_rev TARGET
=$(subst _rev
,,$@
)
532 $(V0
) mv
-f
$(TARGET_HEX
) $(TARGET_HEX_REV
)
534 all_rev
: $(addsuffix _rev
,$(CI_TARGETS
))
536 unbrick_
$(TARGET
): $(TARGET_HEX
)
537 $(V0
) stty
-F
$(SERIAL_DEVICE
) raw speed
115200 -crtscts cs8
-parenb
-cstopb
-ixon
538 $(V0
) stm32flash
-w
$(TARGET_HEX
) -v
-g
0x0 -b
115200 $(SERIAL_DEVICE
)
540 ## unbrick : unbrick flight controller
541 unbrick
: unbrick_
$(TARGET
)
543 ## cppcheck : run static analysis on C source code
544 cppcheck
: $(CSOURCES
)
547 cppcheck-result.xml
: $(CSOURCES
)
548 $(V0
) $(CPPCHECK
) --xml-version
=2 2> cppcheck-result.xml
557 ## version : print firmware version
561 ## help : print this help message and exit
562 help
: Makefile make
/tools.mk
564 @echo
"Makefile for the $(FORKNAME) firmware"
567 @echo
" make [V=<verbosity>] [TARGET=<target>] [OPTIONS=\"<options>\"]"
569 @echo
" make <target> [V=<verbosity>] [OPTIONS=\"<options>\"]"
571 @echo
"Valid TARGET values are: $(VALID_TARGETS)"
573 @sed
-n
's/^## //p' $?
575 ## targets : print a list of all valid target platforms (for consumption by scripts)
577 @echo
"Valid targets: $(VALID_TARGETS)"
578 @echo
"Built targets: $(CI_TARGETS)"
579 @echo
"Default target: $(TARGET)"
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
$${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-f4 : make all F4 targets
609 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F4 TARGETS
="$(VALID_TARGETS)" DO_BUILD
=1
612 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F4 TARGETS
="$(VALID_TARGETS)"
615 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F4 TARGETS
="$(CI_TARGETS)"
617 ## targets-f7 : make all F7 targets
619 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F7 TARGETS
="$(VALID_TARGETS)" DO_BUILD
=1
622 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F7 TARGETS
="$(VALID_TARGETS)"
625 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F7 TARGETS
="$(CI_TARGETS)"
627 ## test : run the Betaflight test suite
628 ## junittest : run the Betaflight test suite, producing Junit XML result files.
629 ## 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)
630 ## test-all: run the Betaflight test suite including all per-target expanded tests
631 test junittest test-all test-representative
:
632 $(V0
) cd src
/test && $(MAKE
) $@
634 ## test_help : print the help message for the test suite (including a list of the available tests)
636 $(V0
) cd src
/test && $(MAKE
) help
638 ## test_versions : print the compiler versions used for the test suite
640 $(V0
) cd src
/test && $(MAKE
) versions
642 ## test_% : run test 'test_%' from the test suite
644 $(V0
) cd src
/test && $(MAKE
) $@
647 # rebuild everything when makefile changes
648 $(TARGET_OBJS
): Makefile
$(TARGET_DIR
)/target.mk
$(wildcard make
/*)
650 # include auto-generated dependencies
651 -include $(TARGET_DEPS
)