Merge pull request #1853 from martinbudden/bf_blackbox_gyro_scaling_fix
[betaflight.git] / Makefile
blobf0a3ba2eb8abcde34d0e2ed3e6f510d28065cbb5
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 ?= NAZE
21 # Compile-time options
22 OPTIONS ?=
24 # compile for OpenPilot BootLoader support
25 OPBL ?= no
27 # Debugger optons, must be empty or GDB
28 DEBUG ?=
30 # Insert the debugging hardfault debugger
31 # releases should not be built with this flag as it does not disable pwm output
32 DEBUG_HARDFAULTS ?=
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.
38 FLASH_SIZE ?=
40 ## V : Set verbosity level based on the V= parameter
41 ## V=0 Low
42 ## V=1 High
43 export AT := @
45 ifndef V
46 export V0 :=
47 export V1 := $(AT)
48 export STDOUT :=
49 else ifeq ($(V), 0)
50 export V0 := $(AT)
51 export V1 := $(AT)
52 export STDOUT:= "> /dev/null"
53 export MAKE := $(MAKE) --no-print-directory
54 else ifeq ($(V), 1)
55 export V0 :=
56 export V1 :=
57 export STDOUT :=
58 endif
60 ###############################################################################
61 # Things that need to be maintained as the source changes
64 FORKNAME = betaflight
66 # Working directories
67 ROOT := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
68 SRC_DIR = $(ROOT)/src/main
69 OBJECT_DIR = $(ROOT)/obj/main
70 BIN_DIR = $(ROOT)/obj
71 CMSIS_DIR = $(ROOT)/lib/main/CMSIS
72 INCLUDE_DIRS = $(SRC_DIR) \
73 $(ROOT)/src/main/target
74 LINKER_DIR = $(ROOT)/src/main/target/link
76 # Build tools, so we all share the same versions
77 # import macros common to all supported build systems
78 include $(ROOT)/make/system-id.mk
79 # developer preferences, edit these at will, they'll be gitignored
80 include $(ROOT)/make/local.mk
82 # configure some directories that are relative to wherever ROOT_DIR is located
83 TOOLS_DIR := $(ROOT)/tools
84 BUILD_DIR := $(ROOT)/build
85 DL_DIR := $(ROOT)/downloads
87 export RM := rm
89 # import macros that are OS specific
90 include $(ROOT)/make/$(OSFAMILY).mk
92 # include the tools makefile
93 include $(ROOT)/make/tools.mk
95 # default xtal value for F4 targets
96 HSE_VALUE = 8000000
98 # used for turning on features like VCP and SDCARD
99 FEATURES =
101 SAMPLE_TARGETS = ALIENFLIGHTF3 ALIENFLIGHTF4 ANYFCF7 BETAFLIGHTF3 BLUEJAYF4 CC3D FURYF4 NAZE REVO SIRINFPV SPARKY SPRACINGF3 SPRACINGF3EVO STM32F3DISCOVERY
102 ALT_TARGETS = $(sort $(filter-out target, $(basename $(notdir $(wildcard $(ROOT)/src/main/target/*/*.mk)))))
103 OPBL_TARGETS = $(filter %_OPBL, $(ALT_TARGETS))
105 #VALID_TARGETS = $(F1_TARGETS) $(F3_TARGETS) $(F4_TARGETS)
106 VALID_TARGETS = $(dir $(wildcard $(ROOT)/src/main/target/*/target.mk))
107 VALID_TARGETS := $(subst /,, $(subst ./src/main/target/,, $(VALID_TARGETS)))
108 VALID_TARGETS := $(VALID_TARGETS) $(ALT_TARGETS)
109 VALID_TARGETS := $(sort $(VALID_TARGETS))
111 ifeq ($(filter $(TARGET),$(ALT_TARGETS)), $(TARGET))
112 BASE_TARGET := $(firstword $(subst /,, $(subst ./src/main/target/,, $(dir $(wildcard $(ROOT)/src/main/target/*/$(TARGET).mk)))))
113 -include $(ROOT)/src/main/target/$(BASE_TARGET)/$(TARGET).mk
114 else
115 BASE_TARGET := $(TARGET)
116 endif
118 ifeq ($(filter $(TARGET),$(OPBL_TARGETS)), $(TARGET))
119 OPBL = yes
120 endif
122 # silently ignore if the file is not present. Allows for target specific.
123 -include $(ROOT)/src/main/target/$(BASE_TARGET)/target.mk
125 F4_TARGETS = $(F405_TARGETS) $(F411_TARGETS)
126 F7_TARGETS = $(F7X5XE_TARGETS) $(F7X5XG_TARGETS) $(F7X5XI_TARGETS) $(F7X6XG_TARGETS)
128 ifeq ($(filter $(TARGET),$(VALID_TARGETS)),)
129 $(error Target '$(TARGET)' is not valid, must be one of $(VALID_TARGETS). Have you prepared a valid target.mk?)
130 endif
132 ifeq ($(filter $(TARGET),$(F1_TARGETS) $(F3_TARGETS) $(F4_TARGETS) $(F7_TARGETS)),)
133 $(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?)
134 endif
136 128K_TARGETS = $(F1_TARGETS)
137 256K_TARGETS = $(F3_TARGETS)
138 512K_TARGETS = $(F411_TARGETS) $(F7X5XE_TARGETS)
139 1024K_TARGETS = $(F405_TARGETS) $(F7X5XG_TARGETS) $(F7X6XG_TARGETS)
140 2048K_TARGETS = $(F7X5XI_TARGETS)
142 # Configure default flash sizes for the targets (largest size specified gets hit first) if flash not specified already.
143 ifeq ($(FLASH_SIZE),)
144 ifeq ($(TARGET),$(filter $(TARGET),$(2048K_TARGETS)))
145 FLASH_SIZE = 2048
146 else ifeq ($(TARGET),$(filter $(TARGET),$(1024K_TARGETS)))
147 FLASH_SIZE = 1024
148 else ifeq ($(TARGET),$(filter $(TARGET),$(512K_TARGETS)))
149 FLASH_SIZE = 512
150 else ifeq ($(TARGET),$(filter $(TARGET),$(256K_TARGETS)))
151 FLASH_SIZE = 256
152 else ifeq ($(TARGET),$(filter $(TARGET),$(128K_TARGETS)))
153 FLASH_SIZE = 128
154 else
155 $(error FLASH_SIZE not configured for target $(TARGET))
156 endif
157 endif
159 # note that there is no hardfault debugging startup file assembly handler for other platforms
160 ifeq ($(DEBUG_HARDFAULTS),F3)
161 CFLAGS += -DDEBUG_HARDFAULTS
162 STM32F30x_COMMON_SRC = startup_stm32f3_debug_hardfault_handler.S
163 else
164 STM32F30x_COMMON_SRC = startup_stm32f30x_md_gcc.S
165 endif
167 ifeq ($(DEBUG_HARDFAULTS),F7)
168 CFLAGS += -DDEBUG_HARDFAULTS
169 endif
171 REVISION := $(shell git log -1 --format="%h")
173 FC_VER_MAJOR := $(shell grep " FC_VERSION_MAJOR" src/main/build/version.h | awk '{print $$3}' )
174 FC_VER_MINOR := $(shell grep " FC_VERSION_MINOR" src/main/build/version.h | awk '{print $$3}' )
175 FC_VER_PATCH := $(shell grep " FC_VERSION_PATCH" src/main/build/version.h | awk '{print $$3}' )
177 FC_VER := $(FC_VER_MAJOR).$(FC_VER_MINOR).$(FC_VER_PATCH)
179 # Search path for sources
180 VPATH := $(SRC_DIR):$(SRC_DIR)/startup
181 USBFS_DIR = $(ROOT)/lib/main/STM32_USB-FS-Device_Driver
182 USBPERIPH_SRC = $(notdir $(wildcard $(USBFS_DIR)/src/*.c))
183 FATFS_DIR = $(ROOT)/lib/main/FatFS
184 FATFS_SRC = $(notdir $(wildcard $(FATFS_DIR)/*.c))
186 CSOURCES := $(shell find $(SRC_DIR) -name '*.c')
188 ifeq ($(TARGET),$(filter $(TARGET),$(F3_TARGETS)))
189 # F3 TARGETS
191 STDPERIPH_DIR = $(ROOT)/lib/main/STM32F30x_StdPeriph_Driver
192 STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/src/*.c))
193 EXCLUDES = stm32f30x_crc.c \
194 stm32f30x_can.c
196 STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC))
197 DEVICE_STDPERIPH_SRC = $(STDPERIPH_SRC)
199 VPATH := $(VPATH):$(CMSIS_DIR)/CM1/CoreSupport:$(CMSIS_DIR)/CM1/DeviceSupport/ST/STM32F30x
200 CMSIS_SRC = $(notdir $(wildcard $(CMSIS_DIR)/CM1/CoreSupport/*.c \
201 $(CMSIS_DIR)/CM1/DeviceSupport/ST/STM32F30x/*.c))
203 INCLUDE_DIRS := $(INCLUDE_DIRS) \
204 $(STDPERIPH_DIR)/inc \
205 $(CMSIS_DIR)/CM1/CoreSupport \
206 $(CMSIS_DIR)/CM1/DeviceSupport/ST/STM32F30x
208 ifneq ($(filter VCP, $(FEATURES)),)
209 INCLUDE_DIRS := $(INCLUDE_DIRS) \
210 $(USBFS_DIR)/inc \
211 $(ROOT)/src/main/vcp
213 VPATH := $(VPATH):$(USBFS_DIR)/src
215 DEVICE_STDPERIPH_SRC := $(DEVICE_STDPERIPH_SRC)\
216 $(USBPERIPH_SRC)
217 endif
219 ifneq ($(filter SDCARD, $(FEATURES)),)
220 INCLUDE_DIRS := $(INCLUDE_DIRS) \
221 $(FATFS_DIR) \
223 VPATH := $(VPATH):$(FATFS_DIR)
224 endif
226 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f303_$(FLASH_SIZE)k.ld
228 ARCH_FLAGS = -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -Wdouble-promotion
229 DEVICE_FLAGS = -DSTM32F303xC -DSTM32F303
230 # End F3 targets
232 # Start F4 targets
233 else ifeq ($(TARGET),$(filter $(TARGET), $(F4_TARGETS)))
235 #STDPERIPH
236 STDPERIPH_DIR = $(ROOT)/lib/main/STM32F4xx_StdPeriph_Driver
237 STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/src/*.c))
238 EXCLUDES = stm32f4xx_crc.c \
239 stm32f4xx_can.c \
240 stm32f4xx_fmc.c \
241 stm32f4xx_sai.c \
242 stm32f4xx_cec.c \
243 stm32f4xx_dsi.c \
244 stm32f4xx_flash_ramfunc.c \
245 stm32f4xx_fmpi2c.c \
246 stm32f4xx_lptim.c \
247 stm32f4xx_qspi.c \
248 stm32f4xx_spdifrx.c \
249 stm32f4xx_cryp.c \
250 stm32f4xx_cryp_aes.c \
251 stm32f4xx_hash_md5.c \
252 stm32f4xx_cryp_des.c \
253 stm32f4xx_rtc.c \
254 stm32f4xx_hash.c \
255 stm32f4xx_dbgmcu.c \
256 stm32f4xx_cryp_tdes.c \
257 stm32f4xx_hash_sha1.c
260 ifeq ($(TARGET),$(filter $(TARGET), $(F411_TARGETS)))
261 EXCLUDES += stm32f4xx_fsmc.c
262 endif
264 STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC))
266 #USB
267 USBCORE_DIR = $(ROOT)/lib/main/STM32_USB_Device_Library/Core
268 USBCORE_SRC = $(notdir $(wildcard $(USBCORE_DIR)/src/*.c))
269 USBOTG_DIR = $(ROOT)/lib/main/STM32_USB_OTG_Driver
270 USBOTG_SRC = $(notdir $(wildcard $(USBOTG_DIR)/src/*.c))
271 EXCLUDES = usb_bsp_template.c \
272 usb_conf_template.c \
273 usb_hcd_int.c \
274 usb_hcd.c \
275 usb_otg.c
277 USBOTG_SRC := $(filter-out ${EXCLUDES}, $(USBOTG_SRC))
278 USBCDC_DIR = $(ROOT)/lib/main/STM32_USB_Device_Library/Class/cdc
279 USBCDC_SRC = $(notdir $(wildcard $(USBCDC_DIR)/src/*.c))
280 EXCLUDES = usbd_cdc_if_template.c
281 USBCDC_SRC := $(filter-out ${EXCLUDES}, $(USBCDC_SRC))
282 VPATH := $(VPATH):$(USBOTG_DIR)/src:$(USBCORE_DIR)/src:$(USBCDC_DIR)/src
284 DEVICE_STDPERIPH_SRC := $(STDPERIPH_SRC) \
285 $(USBOTG_SRC) \
286 $(USBCORE_SRC) \
287 $(USBCDC_SRC)
289 #CMSIS
290 VPATH := $(VPATH):$(CMSIS_DIR)/CM4/CoreSupport:$(CMSIS_DIR)/CM4/DeviceSupport/ST/STM32F4xx
291 CMSIS_SRC = $(notdir $(wildcard $(CMSIS_DIR)/CM4/CoreSupport/*.c \
292 $(CMSIS_DIR)/CM4/DeviceSupport/ST/STM32F4xx/*.c))
293 INCLUDE_DIRS := $(INCLUDE_DIRS) \
294 $(STDPERIPH_DIR)/inc \
295 $(USBOTG_DIR)/inc \
296 $(USBCORE_DIR)/inc \
297 $(USBCDC_DIR)/inc \
298 $(USBFS_DIR)/inc \
299 $(CMSIS_DIR)/CM4/CoreSupport \
300 $(CMSIS_DIR)/CM4/DeviceSupport/ST/STM32F4xx \
301 $(ROOT)/src/main/vcpf4
303 ifneq ($(filter SDCARD,$(FEATURES)),)
304 INCLUDE_DIRS := $(INCLUDE_DIRS) \
305 $(FATFS_DIR)
306 VPATH := $(VPATH):$(FATFS_DIR)
307 endif
309 #Flags
310 ARCH_FLAGS = -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -Wdouble-promotion
312 ifeq ($(TARGET),$(filter $(TARGET),$(F411_TARGETS)))
313 DEVICE_FLAGS = -DSTM32F411xE
314 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f411.ld
315 else ifeq ($(TARGET),$(filter $(TARGET),$(F405_TARGETS)))
316 DEVICE_FLAGS = -DSTM32F40_41xxx
317 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f405.ld
318 else
319 $(error Unknown MCU for F4 target)
320 endif
321 DEVICE_FLAGS += -DHSE_VALUE=$(HSE_VALUE)
323 # End F4 targets
325 # Start F7 targets
326 else ifeq ($(TARGET),$(filter $(TARGET), $(F7_TARGETS)))
328 #STDPERIPH
329 STDPERIPH_DIR = $(ROOT)/lib/main/STM32F7xx_HAL_Driver
330 STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/Src/*.c))
331 EXCLUDES = stm32f7xx_hal_timebase_rtc_wakeup_template.c \
332 stm32f7xx_hal_timebase_rtc_alarm_template.c \
333 stm32f7xx_hal_timebase_tim_template.c
335 STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC))
337 #USB
338 USBCORE_DIR = $(ROOT)/lib/main/Middlewares/ST/STM32_USB_Device_Library/Core
339 USBCORE_SRC = $(notdir $(wildcard $(USBCORE_DIR)/Src/*.c))
340 EXCLUDES = usbd_conf_template.c
341 USBCORE_SRC := $(filter-out ${EXCLUDES}, $(USBCORE_SRC))
343 USBCDC_DIR = $(ROOT)/lib/main/Middlewares/ST/STM32_USB_Device_Library/Class/CDC
344 USBCDC_SRC = $(notdir $(wildcard $(USBCDC_DIR)/Src/*.c))
345 EXCLUDES = usbd_cdc_if_template.c
346 USBCDC_SRC := $(filter-out ${EXCLUDES}, $(USBCDC_SRC))
348 VPATH := $(VPATH):$(USBCDC_DIR)/Src:$(USBCORE_DIR)/Src
350 DEVICE_STDPERIPH_SRC := $(STDPERIPH_SRC) \
351 $(USBCORE_SRC) \
352 $(USBCDC_SRC)
354 #CMSIS
355 VPATH := $(VPATH):$(CMSIS_DIR)/CM7/Include:$(CMSIS_DIR)/CM7/Device/ST/STM32F7xx
356 VPATH := $(VPATH):$(STDPERIPH_DIR)/Src
357 CMSIS_SRC = $(notdir $(wildcard $(CMSIS_DIR)/CM7/Include/*.c \
358 $(CMSIS_DIR)/CM7/Device/ST/STM32F7xx/*.c))
359 INCLUDE_DIRS := $(INCLUDE_DIRS) \
360 $(STDPERIPH_DIR)/Inc \
361 $(USBCORE_DIR)/Inc \
362 $(USBCDC_DIR)/Inc \
363 $(CMSIS_DIR)/CM7/Include \
364 $(CMSIS_DIR)/CM7/Device/ST/STM32F7xx/Include \
365 $(ROOT)/src/main/vcp_hal
367 ifneq ($(filter SDCARD,$(FEATURES)),)
368 INCLUDE_DIRS := $(INCLUDE_DIRS) \
369 $(FATFS_DIR)
370 VPATH := $(VPATH):$(FATFS_DIR)
371 endif
373 #Flags
374 ARCH_FLAGS = -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -fsingle-precision-constant -Wdouble-promotion
376 ifeq ($(TARGET),$(filter $(TARGET),$(F7X5XG_TARGETS)))
377 DEVICE_FLAGS = -DSTM32F745xx -DUSE_HAL_DRIVER -D__FPU_PRESENT
378 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f745.ld
379 else ifeq ($(TARGET),$(filter $(TARGET),$(F7X6XG_TARGETS)))
380 DEVICE_FLAGS = -DSTM32F746xx -DUSE_HAL_DRIVER -D__FPU_PRESENT
381 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f746.ld
382 else
383 $(error Unknown MCU for F7 target)
384 endif
385 DEVICE_FLAGS += -DHSE_VALUE=$(HSE_VALUE)
387 TARGET_FLAGS = -D$(TARGET)
389 # End F7 targets
391 # Start F1 targets
392 else
394 STDPERIPH_DIR = $(ROOT)/lib/main/STM32F10x_StdPeriph_Driver
395 STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/src/*.c))
396 EXCLUDES = stm32f10x_crc.c \
397 stm32f10x_cec.c \
398 stm32f10x_can.c
400 STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC))
402 # Search path and source files for the CMSIS sources
403 VPATH := $(VPATH):$(CMSIS_DIR)/CM3/CoreSupport:$(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x
404 CMSIS_SRC = $(notdir $(wildcard $(CMSIS_DIR)/CM3/CoreSupport/*.c \
405 $(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x/*.c))
407 INCLUDE_DIRS := $(INCLUDE_DIRS) \
408 $(STDPERIPH_DIR)/inc \
409 $(CMSIS_DIR)/CM3/CoreSupport \
410 $(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x \
412 DEVICE_STDPERIPH_SRC = $(STDPERIPH_SRC)
414 ifneq ($(filter VCP, $(FEATURES)),)
415 INCLUDE_DIRS := $(INCLUDE_DIRS) \
416 $(USBFS_DIR)/inc \
417 $(ROOT)/src/main/vcp
419 VPATH := $(VPATH):$(USBFS_DIR)/src
421 DEVICE_STDPERIPH_SRC := $(DEVICE_STDPERIPH_SRC) \
422 $(USBPERIPH_SRC)
424 endif
426 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f103_$(FLASH_SIZE)k.ld
427 ARCH_FLAGS = -mthumb -mcpu=cortex-m3
429 ifeq ($(DEVICE_FLAGS),)
430 DEVICE_FLAGS = -DSTM32F10X_MD
431 endif
432 DEVICE_FLAGS += -DSTM32F10X
434 endif
436 # End F1 targets
438 ifneq ($(BASE_TARGET), $(TARGET))
439 TARGET_FLAGS := $(TARGET_FLAGS) -D$(BASE_TARGET)
440 endif
442 ifneq ($(FLASH_SIZE),)
443 DEVICE_FLAGS := $(DEVICE_FLAGS) -DFLASH_SIZE=$(FLASH_SIZE)
444 endif
446 ifneq ($(HSE_VALUE),)
447 DEVICE_FLAGS := $(DEVICE_FLAGS) -DHSE_VALUE=$(HSE_VALUE)
448 endif
450 TARGET_DIR = $(ROOT)/src/main/target/$(BASE_TARGET)
451 TARGET_DIR_SRC = $(notdir $(wildcard $(TARGET_DIR)/*.c))
453 ifeq ($(OPBL),yes)
454 TARGET_FLAGS := -DOPBL $(TARGET_FLAGS)
455 ifeq ($(TARGET), $(filter $(TARGET),$(F405_TARGETS)))
456 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f405_opbl.ld
457 else ifeq ($(TARGET), $(filter $(TARGET),$(F411_TARGETS)))
458 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f411_opbl.ld
459 else ifeq ($(TARGET), $(filter $(TARGET),$(F3_TARGETS)))
460 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f303_$(FLASH_SIZE)k_opbl.ld
461 else ifeq ($(TARGET), $(filter $(TARGET),$(F1_TARGETS)))
462 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f103_$(FLASH_SIZE)k_opbl.ld
463 endif
464 .DEFAULT_GOAL := binary
465 else
466 .DEFAULT_GOAL := hex
467 endif
469 INCLUDE_DIRS := $(INCLUDE_DIRS) \
470 $(ROOT)/lib/main/MAVLink
472 INCLUDE_DIRS := $(INCLUDE_DIRS) \
473 $(TARGET_DIR)
475 VPATH := $(VPATH):$(TARGET_DIR)
477 COMMON_SRC = \
478 build/build_config.c \
479 build/debug.c \
480 build/version.c \
481 $(TARGET_DIR_SRC) \
482 main.c \
483 common/encoding.c \
484 common/filter.c \
485 common/maths.c \
486 common/printf.c \
487 common/streambuf.c \
488 common/typeconversion.c \
489 config/config_eeprom.c \
490 config/feature.c \
491 config/parameter_group.c \
492 drivers/adc.c \
493 drivers/buf_writer.c \
494 drivers/bus_i2c_soft.c \
495 drivers/bus_spi.c \
496 drivers/bus_spi_soft.c \
497 drivers/display.c \
498 drivers/exti.c \
499 drivers/gyro_sync.c \
500 drivers/io.c \
501 drivers/light_led.c \
502 drivers/resource.c \
503 drivers/rx_nrf24l01.c \
504 drivers/rx_spi.c \
505 drivers/rx_xn297.c \
506 drivers/pwm_esc_detect.c \
507 drivers/pwm_output.c \
508 drivers/pwm_rx.c \
509 drivers/rcc.c \
510 drivers/serial.c \
511 drivers/serial_uart.c \
512 drivers/sound_beeper.c \
513 drivers/stack_check.c \
514 drivers/system.c \
515 drivers/timer.c \
516 fc/config.c \
517 fc/fc_tasks.c \
518 fc/fc_msp.c \
519 fc/mw.c \
520 fc/rc_controls.c \
521 fc/rc_curves.c \
522 fc/runtime_config.c \
523 flight/altitudehold.c \
524 flight/failsafe.c \
525 flight/imu.c \
526 flight/mixer.c \
527 flight/pid.c \
528 flight/servos.c \
529 io/beeper.c \
530 io/serial.c \
531 io/serial_4way.c \
532 io/serial_4way_avrootloader.c \
533 io/serial_4way_stk500v2.c \
534 io/serial_cli.c \
535 io/statusindicator.c \
536 msp/msp_serial.c \
537 rx/ibus.c \
538 rx/jetiexbus.c \
539 rx/msp.c \
540 rx/nrf24_cx10.c \
541 rx/nrf24_inav.c \
542 rx/nrf24_h8_3d.c \
543 rx/nrf24_syma.c \
544 rx/nrf24_v202.c \
545 rx/pwm.c \
546 rx/rx.c \
547 rx/rx_spi.c \
548 rx/crsf.c \
549 rx/sbus.c \
550 rx/spektrum.c \
551 rx/sumd.c \
552 rx/sumh.c \
553 rx/xbus.c \
554 scheduler/scheduler.c \
555 sensors/acceleration.c \
556 sensors/battery.c \
557 sensors/boardalignment.c \
558 sensors/compass.c \
559 sensors/gyro.c \
560 sensors/initialisation.c \
561 $(CMSIS_SRC) \
562 $(DEVICE_STDPERIPH_SRC)
564 HIGHEND_SRC = \
565 blackbox/blackbox.c \
566 blackbox/blackbox_io.c \
567 cms/cms.c \
568 cms/cms_menu_blackbox.c \
569 cms/cms_menu_builtin.c \
570 cms/cms_menu_imu.c \
571 cms/cms_menu_ledstrip.c \
572 cms/cms_menu_misc.c \
573 cms/cms_menu_osd.c \
574 cms/cms_menu_vtx.c \
575 common/colorconversion.c \
576 drivers/display_ug2864hsweg01.c \
577 drivers/light_ws2811strip.c \
578 drivers/serial_escserial.c \
579 drivers/serial_softserial.c \
580 drivers/sonar_hcsr04.c \
581 flight/gtune.c \
582 flight/navigation.c \
583 flight/gps_conversion.c \
584 io/dashboard.c \
585 io/displayport_max7456.c \
586 io/displayport_msp.c \
587 io/displayport_oled.c \
588 io/gps.c \
589 io/ledstrip.c \
590 io/osd.c \
591 sensors/sonar.c \
592 sensors/barometer.c \
593 telemetry/telemetry.c \
594 telemetry/crsf.c \
595 telemetry/frsky.c \
596 telemetry/hott.c \
597 telemetry/smartport.c \
598 telemetry/ltm.c \
599 telemetry/mavlink.c \
600 sensors/esc_sensor.c \
602 SPEED_OPTIMISED_SRC := ""
603 SIZE_OPTIMISED_SRC := ""
605 ifeq ($(TARGET),$(filter $(TARGET),$(F3_TARGETS)))
606 SPEED_OPTIMISED_SRC := $(SPEED_OPTIMISED_SRC) \
607 common/encoding.c \
608 common/filter.c \
609 common/maths.c \
610 common/typeconversion.c \
611 drivers/adc.c \
612 drivers/buf_writer.c \
613 drivers/bus_i2c_soft.c \
614 drivers/bus_spi.c \
615 drivers/bus_spi_soft.c \
616 drivers/exti.c \
617 drivers/gyro_sync.c \
618 drivers/io.c \
619 drivers/light_led.c \
620 drivers/resource.c \
621 drivers/rx_nrf24l01.c \
622 drivers/rx_spi.c \
623 drivers/rx_xn297.c \
624 drivers/pwm_output.c \
625 drivers/pwm_rx.c \
626 drivers/rcc.c \
627 drivers/serial.c \
628 drivers/serial_uart.c \
629 drivers/sound_beeper.c \
630 drivers/stack_check.c \
631 drivers/system.c \
632 drivers/timer.c \
633 fc/fc_tasks.c \
634 fc/mw.c \
635 fc/rc_controls.c \
636 fc/rc_curves.c \
637 fc/runtime_config.c \
638 flight/altitudehold.c \
639 flight/failsafe.c \
640 flight/imu.c \
641 flight/mixer.c \
642 flight/pid.c \
643 flight/servos.c \
644 io/beeper.c \
645 io/serial.c \
646 io/statusindicator.c \
647 rx/ibus.c \
648 rx/jetiexbus.c \
649 rx/msp.c \
650 rx/nrf24_cx10.c \
651 rx/nrf24_inav.c \
652 rx/nrf24_h8_3d.c \
653 rx/nrf24_syma.c \
654 rx/nrf24_v202.c \
655 rx/pwm.c \
656 rx/rx.c \
657 rx/rx_spi.c \
658 rx/crsf.c \
659 rx/sbus.c \
660 rx/spektrum.c \
661 rx/sumd.c \
662 rx/sumh.c \
663 rx/xbus.c \
664 scheduler/scheduler.c \
665 sensors/acceleration.c \
666 sensors/boardalignment.c \
667 sensors/gyro.c \
668 $(CMSIS_SRC) \
669 $(DEVICE_STDPERIPH_SRC) \
670 blackbox/blackbox.c \
671 blackbox/blackbox_io.c \
672 drivers/display_ug2864hsweg01.c \
673 drivers/light_ws2811strip.c \
674 drivers/serial_softserial.c \
675 io/dashboard.c \
676 io/displayport_max7456.c \
677 io/displayport_msp.c \
678 io/displayport_oled.c \
679 io/ledstrip.c \
680 io/osd.c \
681 telemetry/telemetry.c \
682 telemetry/crsf.c \
683 telemetry/frsky.c \
684 telemetry/hott.c \
685 telemetry/smartport.c \
686 telemetry/ltm.c \
687 telemetry/mavlink.c \
688 telemetry/esc_telemetry.c \
690 SIZE_OPTIMISED_SRC := $(SIZE_OPTIMISED_SRC) \
691 drivers/serial_escserial.c \
692 io/serial_cli.c \
693 io/serial_4way.c \
694 io/serial_4way_avrootloader.c \
695 io/serial_4way_stk500v2.c \
696 msp/msp_serial.c \
697 cms/cms.c \
698 cms/cms_menu_blackbox.c \
699 cms/cms_menu_builtin.c \
700 cms/cms_menu_imu.c \
701 cms/cms_menu_ledstrip.c \
702 cms/cms_menu_misc.c \
703 cms/cms_menu_osd.c \
704 cms/cms_menu_vtx.c
705 endif #F3
707 ifeq ($(TARGET),$(filter $(TARGET),$(F4_TARGETS)))
708 VCP_SRC = \
709 vcpf4/stm32f4xx_it.c \
710 vcpf4/usb_bsp.c \
711 vcpf4/usbd_desc.c \
712 vcpf4/usbd_usr.c \
713 vcpf4/usbd_cdc_vcp.c \
714 drivers/serial_usb_vcp.c
715 else ifeq ($(TARGET),$(filter $(TARGET),$(F7_TARGETS)))
716 VCP_SRC = \
717 vcp_hal/usbd_desc.c \
718 vcp_hal/usbd_conf.c \
719 vcp_hal/usbd_cdc_interface.c \
720 drivers/serial_usb_vcp_hal.c
721 else
722 VCP_SRC = \
723 vcp/hw_config.c \
724 vcp/stm32_it.c \
725 vcp/usb_desc.c \
726 vcp/usb_endp.c \
727 vcp/usb_istr.c \
728 vcp/usb_prop.c \
729 vcp/usb_pwr.c \
730 drivers/serial_usb_vcp.c \
731 drivers/usb_io.c
732 endif
734 STM32F10x_COMMON_SRC = \
735 startup_stm32f10x_md_gcc.S \
736 drivers/adc_stm32f10x.c \
737 drivers/bus_i2c_stm32f10x.c \
738 drivers/dma.c \
739 drivers/gpio_stm32f10x.c \
740 drivers/inverter.c \
741 drivers/light_ws2811strip_stm32f10x.c \
742 drivers/serial_uart_stm32f10x.c \
743 drivers/system_stm32f10x.c \
744 drivers/timer_stm32f10x.c
746 STM32F30x_COMMON_SRC = \
747 startup_stm32f30x_md_gcc.S \
748 target/system_stm32f30x.c \
749 drivers/adc_stm32f30x.c \
750 drivers/bus_i2c_stm32f30x.c \
751 drivers/dma.c \
752 drivers/gpio_stm32f30x.c \
753 drivers/light_ws2811strip_stm32f30x.c \
754 drivers/pwm_output_stm32f3xx.c \
755 drivers/serial_uart_stm32f30x.c \
756 drivers/system_stm32f30x.c \
757 drivers/timer_stm32f30x.c
759 STM32F4xx_COMMON_SRC = \
760 startup_stm32f40xx.s \
761 target/system_stm32f4xx.c \
762 drivers/accgyro_mpu.c \
763 drivers/adc_stm32f4xx.c \
764 drivers/bus_i2c_stm32f10x.c \
765 drivers/dma_stm32f4xx.c \
766 drivers/gpio_stm32f4xx.c \
767 drivers/inverter.c \
768 drivers/light_ws2811strip_stm32f4xx.c \
769 drivers/pwm_output_stm32f4xx.c \
770 drivers/serial_uart_stm32f4xx.c \
771 drivers/system_stm32f4xx.c \
772 drivers/timer_stm32f4xx.c
774 STM32F7xx_COMMON_SRC = \
775 startup_stm32f745xx.s \
776 target/system_stm32f7xx.c \
777 drivers/accgyro_mpu.c \
778 drivers/adc_stm32f7xx.c \
779 drivers/bus_i2c_hal.c \
780 drivers/dma_stm32f7xx.c \
781 drivers/gpio_stm32f7xx.c \
782 drivers/inverter.c \
783 drivers/bus_spi_hal.c \
784 drivers/pwm_output_stm32f7xx.c \
785 drivers/timer_hal.c \
786 drivers/timer_stm32f7xx.c \
787 drivers/pwm_output_hal.c \
788 drivers/system_stm32f7xx.c \
789 drivers/serial_uart_stm32f7xx.c \
790 drivers/serial_uart_hal.c
792 F7EXCLUDES = drivers/bus_spi.c \
793 drivers/bus_i2c.c \
794 drivers/timer.c \
795 drivers/pwm_output.c \
796 drivers/serial_uart.c
798 # check if target.mk supplied
799 ifeq ($(TARGET),$(filter $(TARGET),$(F4_TARGETS)))
800 TARGET_SRC := $(STM32F4xx_COMMON_SRC) $(TARGET_SRC)
801 else ifeq ($(TARGET),$(filter $(TARGET),$(F7_TARGETS)))
802 TARGET_SRC := $(STM32F7xx_COMMON_SRC) $(TARGET_SRC)
803 else ifeq ($(TARGET),$(filter $(TARGET),$(F3_TARGETS)))
804 TARGET_SRC := $(STM32F30x_COMMON_SRC) $(TARGET_SRC)
805 else ifeq ($(TARGET),$(filter $(TARGET),$(F1_TARGETS)))
806 TARGET_SRC := $(STM32F10x_COMMON_SRC) $(TARGET_SRC)
807 endif
809 ifneq ($(filter ONBOARDFLASH,$(FEATURES)),)
810 TARGET_SRC += \
811 drivers/flash_m25p16.c \
812 io/flashfs.c
813 endif
815 ifeq ($(TARGET),$(filter $(TARGET),$(F7_TARGETS) $(F4_TARGETS) $(F3_TARGETS)))
816 TARGET_SRC += $(HIGHEND_SRC)
817 else ifneq ($(filter HIGHEND,$(FEATURES)),)
818 TARGET_SRC += $(HIGHEND_SRC)
819 endif
821 TARGET_SRC += $(COMMON_SRC)
822 #excludes
823 ifeq ($(TARGET),$(filter $(TARGET),$(F7_TARGETS)))
824 TARGET_SRC := $(filter-out ${F7EXCLUDES}, $(TARGET_SRC))
825 endif
827 ifneq ($(filter SDCARD,$(FEATURES)),)
828 TARGET_SRC += \
829 drivers/sdcard.c \
830 drivers/sdcard_standard.c \
831 io/asyncfatfs/asyncfatfs.c \
832 io/asyncfatfs/fat_standard.c
833 endif
835 ifneq ($(filter VCP,$(FEATURES)),)
836 TARGET_SRC += $(VCP_SRC)
837 endif
838 # end target specific make file checks
841 # Search path and source files for the ST stdperiph library
842 VPATH := $(VPATH):$(STDPERIPH_DIR)/src
844 ###############################################################################
845 # Things that might need changing to use different tools
848 # Find out if ccache is installed on the system
849 CCACHE := ccache
850 RESULT = $(shell (which $(CCACHE) > /dev/null 2>&1; echo $$?) )
851 ifneq ($(RESULT),0)
852 CCACHE :=
853 endif
855 # Tool names
856 CROSS_CC := $(CCACHE) $(ARM_SDK_PREFIX)gcc
857 CROSS_CXX := $(CCACHE) $(ARM_SDK_PREFIX)g++
858 OBJCOPY := $(ARM_SDK_PREFIX)objcopy
859 SIZE := $(ARM_SDK_PREFIX)size
862 # Tool options.
865 ifneq ($(DEBUG),GDB)
866 OPTIMISATION_BASE := -flto -fuse-linker-plugin -ffast-math
867 OPTIMISE_SPEED := ""
868 OPTIMISE_SIZE := ""
870 ifeq ($(TARGET),$(filter $(TARGET),$(F1_TARGETS)))
871 OPTIMISE_DEFAULT := -Os
873 LTO_FLAGS := $(OPTIMISATION_BASE) $(OPTIMISE_DEFAULT)
875 else ifeq ($(TARGET),$(filter $(TARGET),$(F3_TARGETS)))
876 OPTIMISE_DEFAULT := -O2
877 OPTIMISE_SPEED := -Ofast
878 OPTIMISE_SIZE := -Os
880 LTO_FLAGS := $(OPTIMISATION_BASE) $(OPTIMISE_SPEED)
882 else
883 OPTIMISE_DEFAULT := -Ofast
885 LTO_FLAGS := $(OPTIMISATION_BASE) $(OPTIMISE_DEFAULT)
887 endif #TARGETS
889 CC_DEFAULT_OPTIMISATION := $(OPTIMISATION_BASE) $(OPTIMISE_DEFAULT)
890 CC_SPEED_OPTIMISATION := $(OPTIMISATION_BASE) $(OPTIMISE_SPEED)
891 CC_SIZE_OPTIMISATION := $(OPTIMISATION_BASE) $(OPTIMISE_SIZE)
893 else #DEBUG
894 OPTIMISE_DEFAULT := -O0
896 CC_DEBUG_OPTIMISATION := $(OPTIMISE_DEFAULT)
898 LTO_FLAGS := $(OPTIMISE_DEFAULT)
899 endif #DEBUG
901 DEBUG_FLAGS = -ggdb3 -DDEBUG
903 CFLAGS += $(ARCH_FLAGS) \
904 $(addprefix -D,$(OPTIONS)) \
905 $(addprefix -I,$(INCLUDE_DIRS)) \
906 $(DEBUG_FLAGS) \
907 -std=gnu99 \
908 -Wall -Wextra -Wunsafe-loop-optimizations -Wdouble-promotion \
909 -ffunction-sections \
910 -fdata-sections \
911 -pedantic \
912 $(DEVICE_FLAGS) \
913 -DUSE_STDPERIPH_DRIVER \
914 -D$(TARGET) \
915 $(TARGET_FLAGS) \
916 -D'__FORKNAME__="$(FORKNAME)"' \
917 -D'__TARGET__="$(TARGET)"' \
918 -D'__REVISION__="$(REVISION)"' \
919 -save-temps=obj \
920 -MMD -MP
922 ASFLAGS = $(ARCH_FLAGS) \
923 -x assembler-with-cpp \
924 $(addprefix -I,$(INCLUDE_DIRS)) \
925 -MMD -MP
927 LDFLAGS = -lm \
928 -nostartfiles \
929 --specs=nano.specs \
930 -lc \
931 -lnosys \
932 $(ARCH_FLAGS) \
933 $(LTO_FLAGS) \
934 $(DEBUG_FLAGS) \
935 -static \
936 -Wl,-gc-sections,-Map,$(TARGET_MAP) \
937 -Wl,-L$(LINKER_DIR) \
938 -Wl,--cref \
939 -Wl,--no-wchar-size-warning \
940 -T$(LD_SCRIPT)
942 ###############################################################################
943 # No user-serviceable parts below
944 ###############################################################################
946 CPPCHECK = cppcheck $(CSOURCES) --enable=all --platform=unix64 \
947 --std=c99 --inline-suppr --quiet --force \
948 $(addprefix -I,$(INCLUDE_DIRS)) \
949 -I/usr/include -I/usr/include/linux
952 # Things we will build
954 TARGET_BIN = $(BIN_DIR)/$(FORKNAME)_$(FC_VER)_$(TARGET).bin
955 TARGET_HEX = $(BIN_DIR)/$(FORKNAME)_$(FC_VER)_$(TARGET).hex
956 TARGET_ELF = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET).elf
957 TARGET_OBJS = $(addsuffix .o,$(addprefix $(OBJECT_DIR)/$(TARGET)/,$(basename $(TARGET_SRC))))
958 TARGET_DEPS = $(addsuffix .d,$(addprefix $(OBJECT_DIR)/$(TARGET)/,$(basename $(TARGET_SRC))))
959 TARGET_MAP = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET).map
962 CLEAN_ARTIFACTS := $(TARGET_BIN)
963 CLEAN_ARTIFACTS += $(TARGET_HEX)
964 CLEAN_ARTIFACTS += $(TARGET_ELF) $(TARGET_OBJS) $(TARGET_MAP)
966 # Make sure build date and revision is updated on every incremental build
967 $(OBJECT_DIR)/$(TARGET)/build/version.o : $(TARGET_SRC)
969 # List of buildable ELF files and their object dependencies.
970 # It would be nice to compute these lists, but that seems to be just beyond make.
972 $(TARGET_HEX): $(TARGET_ELF)
973 $(V0) $(OBJCOPY) -O ihex --set-start 0x8000000 $< $@
975 $(TARGET_BIN): $(TARGET_ELF)
976 $(V0) $(OBJCOPY) -O binary $< $@
978 $(TARGET_ELF): $(TARGET_OBJS)
979 $(V1) echo Linking $(TARGET)
980 $(V1) $(CROSS_CC) -o $@ $^ $(LDFLAGS)
981 $(V0) $(SIZE) $(TARGET_ELF)
983 # Compile
984 ifneq ($(DEBUG),GDB)
985 $(OBJECT_DIR)/$(TARGET)/%.o: %.c
986 $(V1) mkdir -p $(dir $@)
987 $(V1) $(if $(findstring $(subst ./src/main/,,$<),$(SPEED_OPTIMISED_SRC)), \
988 echo "%% (speed optimised) $(notdir $<)" "$(STDOUT)" && \
989 $(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_SPEED_OPTIMISATION) $<, \
990 $(if $(findstring $(subst ./src/main/,,$<),$(SIZE_OPTIMISED_SRC)), \
991 echo "%% (size optimised) $(notdir $<)" "$(STDOUT)" && \
992 $(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_SIZE_OPTIMISATION) $<, \
993 echo "%% $(notdir $<)" "$(STDOUT)" && \
994 $(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_DEFAULT_OPTIMISATION) $<))
995 else
996 $(OBJECT_DIR)/$(TARGET)/%.o: %.c
997 $(V1) mkdir -p $(dir $@)
998 $(V1) echo "%% $(notdir $<)" "$(STDOUT)" && \
999 $(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_DEBUG_OPTIMISATION) $<
1000 endif
1002 # Assemble
1003 $(OBJECT_DIR)/$(TARGET)/%.o: %.s
1004 $(V1) mkdir -p $(dir $@)
1005 $(V1) echo "%% $(notdir $<)" "$(STDOUT)"
1006 $(V1) $(CROSS_CC) -c -o $@ $(ASFLAGS) $<
1008 $(OBJECT_DIR)/$(TARGET)/%.o: %.S
1009 $(V1) mkdir -p $(dir $@)
1010 $(V1) echo "%% $(notdir $<)" "$(STDOUT)"
1011 $(V1) $(CROSS_CC) -c -o $@ $(ASFLAGS) $<
1013 ## sample : Build all sample (travis) targets
1014 sample: $(SAMPLE_TARGETS)
1016 ## all : Build all valid targets
1017 all: $(VALID_TARGETS)
1019 $(VALID_TARGETS):
1020 $(V0) echo "" && \
1021 echo "Building $@" && \
1022 $(MAKE) binary hex TARGET=$@ && \
1023 echo "Building $@ succeeded."
1027 CLEAN_TARGETS = $(addprefix clean_,$(VALID_TARGETS) )
1028 TARGETS_CLEAN = $(addsuffix _clean,$(VALID_TARGETS) )
1030 ## clean : clean up temporary / machine-generated files
1031 clean:
1032 $(V0) echo "Cleaning $(TARGET)"
1033 $(V0) rm -f $(CLEAN_ARTIFACTS)
1034 $(V0) rm -rf $(OBJECT_DIR)/$(TARGET)
1035 $(V0) echo "Cleaning $(TARGET) succeeded."
1037 ## clean_test : clean up temporary / machine-generated files (tests)
1038 clean_test:
1039 $(V0) cd src/test && $(MAKE) clean || true
1041 ## clean_<TARGET> : clean up one specific target
1042 $(CLEAN_TARGETS) :
1043 $(V0) $(MAKE) -j TARGET=$(subst clean_,,$@) clean
1045 ## <TARGET>_clean : clean up one specific target (alias for above)
1046 $(TARGETS_CLEAN) :
1047 $(V0) $(MAKE) -j TARGET=$(subst _clean,,$@) clean
1049 ## clean_all : clean all valid targets
1050 clean_all:$(CLEAN_TARGETS)
1052 ## all_clean : clean all valid targets (alias for above)
1053 all_clean:$(TARGETS_CLEAN)
1056 flash_$(TARGET): $(TARGET_HEX)
1057 $(V0) stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
1058 $(V0) echo -n 'R' >$(SERIAL_DEVICE)
1059 $(V0) stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
1061 ## flash : flash firmware (.hex) onto flight controller
1062 flash: flash_$(TARGET)
1064 st-flash_$(TARGET): $(TARGET_BIN)
1065 $(V0) st-flash --reset write $< 0x08000000
1067 ## st-flash : flash firmware (.bin) onto flight controller
1068 st-flash: st-flash_$(TARGET)
1070 binary:
1071 $(V0) $(MAKE) -j $(TARGET_BIN)
1073 hex:
1074 $(V0) $(MAKE) -j $(TARGET_HEX)
1076 unbrick_$(TARGET): $(TARGET_HEX)
1077 $(V0) stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
1078 $(V0) stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
1080 ## unbrick : unbrick flight controller
1081 unbrick: unbrick_$(TARGET)
1083 ## cppcheck : run static analysis on C source code
1084 cppcheck: $(CSOURCES)
1085 $(V0) $(CPPCHECK)
1087 cppcheck-result.xml: $(CSOURCES)
1088 $(V0) $(CPPCHECK) --xml-version=2 2> cppcheck-result.xml
1090 # mkdirs
1091 $(DL_DIR):
1092 mkdir -p $@
1094 $(TOOLS_DIR):
1095 mkdir -p $@
1097 $(BUILD_DIR):
1098 mkdir -p $@
1100 ## help : print this help message and exit
1101 help: Makefile make/tools.mk
1102 $(V0) @echo ""
1103 $(V0) @echo "Makefile for the $(FORKNAME) firmware"
1104 $(V0) @echo ""
1105 $(V0) @echo "Usage:"
1106 $(V0) @echo " make [V=<verbosity>] [TARGET=<target>] [OPTIONS=\"<options>\"]"
1107 $(V0) @echo "Or:"
1108 $(V0) @echo " make <target> [V=<verbosity>] [OPTIONS=\"<options>\"]"
1109 $(V0) @echo ""
1110 $(V0) @echo "Valid TARGET values are: $(VALID_TARGETS)"
1111 $(V0) @echo ""
1112 $(V0) @sed -n 's/^## //p' $?
1114 ## targets : print a list of all valid target platforms (for consumption by scripts)
1115 targets:
1116 $(V0) @echo "Valid targets: $(VALID_TARGETS)"
1117 $(V0) @echo "Target: $(TARGET)"
1118 $(V0) @echo "Base target: $(BASE_TARGET)"
1120 ## test : run the cleanflight test suite
1121 ## junittest : run the cleanflight test suite, producing Junit XML result files.
1122 test junittest:
1123 $(V0) cd src/test && $(MAKE) $@
1125 # rebuild everything when makefile changes
1126 $(TARGET_OBJS) : Makefile
1128 # include auto-generated dependencies
1129 -include $(TARGET_DEPS)