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 cleanflight firmware.
10 # Invoke this with 'make help' to see the list of supported targets.
13 ###############################################################################
16 # Things that the user might override on the commandline
19 # The target to build, see VALID_TARGETS below
22 # Compile-time options
25 # compile for OpenPilot BootLoader support
28 # Debugger optons, must be empty or GDB
31 # Serial port/Device for flashing
32 SERIAL_DEVICE ?
= $(firstword $(wildcard /dev
/ttyUSB
*) no-port-found
)
34 # Flash size (KB). Some low-end chips actually have more flash than advertised, use this to override.
37 ###############################################################################
38 # Things that need to be maintained as the source changes
43 CC3D_TARGETS
= CC3D CC3D_OPBL
45 VALID_TARGETS
= NAZE NAZE32PRO OLIMEXINO STM32F3DISCOVERY CHEBUZZF3
$(CC3D_TARGETS
) CJMCU EUSTM32F103RC SPRACINGF3 PORT103R SPARKY ALIENFLIGHTF1 ALIENFLIGHTF3 COLIBRI_RACE LUX_RACE MOTOLAB RMDO IRCFUSIONF3 AFROMINI SPRACINGF3MINI
47 # Valid targets for OP VCP support
48 VCP_VALID_TARGETS
= $(CC3D_TARGETS
)
50 # Valid targets for OP BootLoader support
51 OPBL_VALID_TARGETS
= CC3D_OPBL
54 128K_TARGETS
= ALIENFLIGHTF1
$(CC3D_TARGETS
) NAZE OLIMEXINO RMDO AFROMINI
55 256K_TARGETS
= EUSTM32F103RC PORT103R STM32F3DISCOVERY CHEBUZZF3 NAZE32PRO SPRACINGF3 IRCFUSIONF3 SPARKY ALIENFLIGHTF3 COLIBRI_RACE LUX_RACE MOTOLAB SPRACINGF3MINI
57 F3_TARGETS
= STM32F3DISCOVERY CHEBUZZF3 NAZE32PRO SPRACINGF3 IRCFUSIONF3 SPARKY ALIENFLIGHTF3 COLIBRI_RACE LUX_RACE MOTOLAB RMDO SPRACINGF3MINI
60 # Configure default flash sizes for the targets
62 ifeq ($(TARGET
),$(filter $(TARGET
),$(64K_TARGETS
)))
64 else ifeq ($(TARGET
),$(filter $(TARGET
),$(128K_TARGETS
)))
66 else ifeq ($(TARGET
),$(filter $(TARGET
),$(256K_TARGETS
)))
69 $(error FLASH_SIZE not configured for target
$(TARGET
))
73 REVISION
= $(shell git log
-1 --format
="%h")
75 FC_VER_MAJOR
:= $(shell grep
" FC_VERSION_MAJOR" src
/main
/version.h | awk
'{print $$3}' )
76 FC_VER_MINOR
:= $(shell grep
" FC_VERSION_MINOR" src
/main
/version.h | awk
'{print $$3}' )
77 FC_VER_PATCH
:= $(shell grep
" FC_VERSION_PATCH" src
/main
/version.h | awk
'{print $$3}' )
79 FC_VER
:= $(FC_VER_MAJOR
).
$(FC_VER_MINOR
).
$(FC_VER_PATCH
)
82 ROOT
:= $(patsubst %/,%,$(dir $(lastword
$(MAKEFILE_LIST
))))
83 SRC_DIR
= $(ROOT
)/src
/main
84 OBJECT_DIR
= $(ROOT
)/obj
/main
86 CMSIS_DIR
= $(ROOT
)/lib
/main
/CMSIS
87 INCLUDE_DIRS
= $(SRC_DIR
)
88 LINKER_DIR
= $(ROOT
)/src
/main
/target
90 # Search path for sources
91 VPATH
:= $(SRC_DIR
):$(SRC_DIR
)/startup
92 USBFS_DIR
= $(ROOT
)/lib
/main
/STM32_USB-FS-Device_Driver
93 USBPERIPH_SRC
= $(notdir $(wildcard $(USBFS_DIR
)/src
/*.c
))
94 FATFS_DIR
= $(ROOT
)/lib
/main
/FatFS
95 FATFS_SRC
= $(notdir $(wildcard $(FATFS_DIR
)/*.c
))
97 ifeq ($(TARGET
),$(filter $(TARGET
),$(F3_TARGETS
)))
99 CSOURCES
:= $(shell find
$(SRC_DIR
) -name
'*.c')
101 STDPERIPH_DIR
= $(ROOT
)/lib
/main
/STM32F30x_StdPeriph_Driver
103 STDPERIPH_SRC
= $(notdir $(wildcard $(STDPERIPH_DIR
)/src
/*.c
))
105 EXCLUDES
= stm32f30x_crc.c \
108 STDPERIPH_SRC
:= $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC
))
110 DEVICE_STDPERIPH_SRC
= \
114 VPATH
:= $(VPATH
):$(CMSIS_DIR
)/CM1
/CoreSupport
:$(CMSIS_DIR
)/CM1
/DeviceSupport
/ST
/STM32F30x
115 CMSIS_SRC
= $(notdir $(wildcard $(CMSIS_DIR
)/CM1
/CoreSupport
/*.c \
116 $(CMSIS_DIR
)/CM1
/DeviceSupport
/ST
/STM32F30x
/*.c
))
118 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
119 $(STDPERIPH_DIR
)/inc \
120 $(CMSIS_DIR
)/CM1
/CoreSupport \
121 $(CMSIS_DIR
)/CM1
/DeviceSupport
/ST
/STM32F30x
123 ifneq ($(TARGET
),$(filter $(TARGET
),SPRACINGF3 IRCFUSIONF3
))
124 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
128 VPATH
:= $(VPATH
):$(USBFS_DIR
)/src
130 DEVICE_STDPERIPH_SRC
:= $(DEVICE_STDPERIPH_SRC
)\
135 ifeq ($(TARGET
),SPRACINGF3MINI
)
136 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
139 VPATH
:= $(VPATH
):$(FATFS_DIR
)
142 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f303_
$(FLASH_SIZE
)k.
ld
144 ARCH_FLAGS
= -mthumb
-mcpu
=cortex-m4
-mfloat-abi
=hard
-mfpu
=fpv4-sp-d16
-fsingle-precision-constant
-Wdouble-promotion
145 DEVICE_FLAGS
= -DSTM32F303xC
-DSTM32F303
146 TARGET_FLAGS
= -D
$(TARGET
)
147 ifeq ($(TARGET
),CHEBUZZF3
)
148 # CHEBUZZ is a VARIANT of STM32F3DISCOVERY
149 TARGET_FLAGS
:= $(TARGET_FLAGS
) -DSTM32F3DISCOVERY
152 ifeq ($(TARGET
),$(filter $(TARGET
),RMDO IRCFUSIONF3
))
153 # RMDO and IRCFUSIONF3 are a VARIANT of SPRACINGF3
154 TARGET_FLAGS
:= $(TARGET_FLAGS
) -DSPRACINGF3
157 else ifeq ($(TARGET
),$(filter $(TARGET
),EUSTM32F103RC PORT103R
))
160 STDPERIPH_DIR
= $(ROOT
)/lib
/main
/STM32F10x_StdPeriph_Driver
162 STDPERIPH_SRC
= $(notdir $(wildcard $(STDPERIPH_DIR
)/src
/*.c
))
164 EXCLUDES
= stm32f10x_crc.c \
168 STDPERIPH_SRC
:= $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC
))
170 # Search path and source files for the CMSIS sources
171 VPATH
:= $(VPATH
):$(CMSIS_DIR
)/CM3
/CoreSupport
:$(CMSIS_DIR
)/CM3
/DeviceSupport
/ST
/STM32F10x
172 CMSIS_SRC
= $(notdir $(wildcard $(CMSIS_DIR
)/CM3
/CoreSupport
/*.c \
173 $(CMSIS_DIR
)/CM3
/DeviceSupport
/ST
/STM32F10x
/*.c
))
175 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
176 $(STDPERIPH_DIR
)/inc \
177 $(CMSIS_DIR
)/CM3
/CoreSupport \
178 $(CMSIS_DIR
)/CM3
/DeviceSupport
/ST
/STM32F10x \
180 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f103_
$(FLASH_SIZE
)k.
ld
182 ARCH_FLAGS
= -mthumb
-mcpu
=cortex-m3
183 TARGET_FLAGS
= -D
$(TARGET
) -pedantic
184 DEVICE_FLAGS
= -DSTM32F10X_HD
-DSTM32F10X
186 DEVICE_STDPERIPH_SRC
= $(STDPERIPH_SRC
)
190 STDPERIPH_DIR
= $(ROOT
)/lib
/main
/STM32F10x_StdPeriph_Driver
192 STDPERIPH_SRC
= $(notdir $(wildcard $(STDPERIPH_DIR
)/src
/*.c
))
194 EXCLUDES
= stm32f10x_crc.c \
198 STDPERIPH_SRC
:= $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC
))
200 # Search path and source files for the CMSIS sources
201 VPATH
:= $(VPATH
):$(CMSIS_DIR
)/CM3
/CoreSupport
:$(CMSIS_DIR
)/CM3
/DeviceSupport
/ST
/STM32F10x
202 CMSIS_SRC
= $(notdir $(wildcard $(CMSIS_DIR
)/CM3
/CoreSupport
/*.c \
203 $(CMSIS_DIR
)/CM3
/DeviceSupport
/ST
/STM32F10x
/*.c
))
205 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
206 $(STDPERIPH_DIR
)/inc \
207 $(CMSIS_DIR
)/CM3
/CoreSupport \
208 $(CMSIS_DIR
)/CM3
/DeviceSupport
/ST
/STM32F10x \
210 DEVICE_STDPERIPH_SRC
= $(STDPERIPH_SRC
)
212 ifeq ($(TARGET
),$(filter $(TARGET
), $(VCP_VALID_TARGETS
)))
213 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
217 VPATH
:= $(VPATH
):$(USBFS_DIR
)/src
219 DEVICE_STDPERIPH_SRC
:= $(DEVICE_STDPERIPH_SRC
) \
224 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f103_
$(FLASH_SIZE
)k.
ld
226 ARCH_FLAGS
= -mthumb
-mcpu
=cortex-m3
227 TARGET_FLAGS
= -D
$(TARGET
) -pedantic
228 DEVICE_FLAGS
= -DSTM32F10X_MD
-DSTM32F10X
232 ifneq ($(FLASH_SIZE
),)
233 DEVICE_FLAGS
:= $(DEVICE_FLAGS
) -DFLASH_SIZE
=$(FLASH_SIZE
)
236 TARGET_DIR
= $(ROOT
)/src
/main
/target
/$(TARGET
)
237 TARGET_SRC
= $(notdir $(wildcard $(TARGET_DIR
)/*.c
))
239 ifeq ($(TARGET
),ALIENFLIGHTF1
)
240 # ALIENFLIGHTF1 is a VARIANT of NAZE
241 TARGET_FLAGS
:= $(TARGET_FLAGS
) -DNAZE
-DALIENFLIGHT
242 TARGET_DIR
= $(ROOT
)/src
/main
/target
/NAZE
245 ifeq ($(TARGET
),$(filter $(TARGET
), $(CC3D_TARGETS
)))
246 TARGET_FLAGS
:= $(TARGET_FLAGS
) -DCC3D
247 TARGET_DIR
= $(ROOT
)/src
/main
/target
/CC3D
250 ifneq ($(filter $(TARGET
),$(OPBL_VALID_TARGETS
)),)
255 ifneq ($(filter $(TARGET
),$(OPBL_VALID_TARGETS
)),)
256 TARGET_FLAGS
:= -DOPBL
$(TARGET_FLAGS
)
257 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_f103_
$(FLASH_SIZE
)k_opbl.
ld
258 .DEFAULT_GOAL
:= binary
260 $(error OPBL specified with a unsupported target
)
264 ifeq ($(TARGET
),AFROMINI
)
265 # AFROMINI is a VARIANT of NAZE being recognized as rev4, but needs to use rev5 config
266 TARGET_FLAGS
:= $(TARGET_FLAGS
) -DNAZE
-DAFROMINI
267 TARGET_DIR
= $(ROOT
)/src
/main
/target
/NAZE
270 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
273 VPATH
:= $(VPATH
):$(TARGET_DIR
)
275 COMMON_SRC
= build_config.c \
280 config
/runtime_config.c \
283 common
/typeconversion.c \
290 flight
/altitudehold.c \
295 drivers
/bus_i2c_soft.c \
297 drivers
/sound_beeper.c \
299 drivers
/gyro_sync.c \
301 drivers
/buf_writer.c \
309 io
/statusindicator.c \
320 sensors
/acceleration.c \
322 sensors
/boardalignment.c \
325 sensors
/initialisation.c \
327 $(DEVICE_STDPERIPH_SRC
)
331 flight
/navigation.c \
332 flight
/gps_conversion.c \
333 common
/colorconversion.c \
337 telemetry
/telemetry.c \
340 telemetry
/smartport.c \
343 sensors
/barometer.c \
344 blackbox
/blackbox.c \
345 blackbox
/blackbox_io.c
355 drivers
/serial_usb_vcp.c
357 NAZE_SRC
= startup_stm32f10x_md_gcc.S \
358 drivers
/accgyro_adxl345.c \
359 drivers
/accgyro_bma280.c \
360 drivers
/accgyro_l3g4200d.c \
361 drivers
/accgyro_mma845x.c \
362 drivers
/accgyro_mpu.c \
363 drivers
/accgyro_mpu3050.c \
364 drivers
/accgyro_mpu6050.c \
365 drivers
/accgyro_mpu6500.c \
366 drivers
/accgyro_spi_mpu6500.c \
368 drivers
/adc_stm32f10x.c \
369 drivers
/barometer_bmp085.c \
370 drivers
/barometer_bmp280.c \
371 drivers
/barometer_ms5611.c \
372 drivers
/barometer_bmp280.c \
374 drivers
/bus_i2c_stm32f10x.c \
375 drivers
/compass_hmc5883l.c \
376 drivers
/display_ug2864hsweg01.h \
377 drivers
/flash_m25p16.c \
378 drivers
/gpio_stm32f10x.c \
380 drivers
/light_led_stm32f10x.c \
381 drivers
/light_ws2811strip.c \
382 drivers
/light_ws2811strip_stm32f10x.c \
383 drivers
/sonar_hcsr04.c \
384 drivers
/pwm_mapping.c \
385 drivers
/pwm_output.c \
387 drivers
/serial_softserial.c \
388 drivers
/serial_uart.c \
389 drivers
/serial_uart_stm32f10x.c \
390 drivers
/sound_beeper_stm32f10x.c \
391 drivers
/system_stm32f10x.c \
393 drivers
/timer_stm32f10x.c \
395 hardware_revision.c \
399 ALIENFLIGHTF1_SRC
= $(NAZE_SRC
)
401 AFROMINI_SRC
= $(NAZE_SRC
)
403 EUSTM32F103RC_SRC
= startup_stm32f10x_hd_gcc.S \
404 drivers
/accgyro_adxl345.c \
405 drivers
/accgyro_bma280.c \
406 drivers
/accgyro_l3g4200d.c \
407 drivers
/accgyro_mma845x.c \
408 drivers
/accgyro_mpu.c \
409 drivers
/accgyro_mpu3050.c \
410 drivers
/accgyro_mpu6050.c \
411 drivers
/accgyro_spi_mpu6000.c \
412 drivers
/accgyro_spi_mpu6500.c \
414 drivers
/adc_stm32f10x.c \
415 drivers
/barometer_bmp085.c \
416 drivers
/barometer_bmp280.c \
417 drivers
/barometer_ms5611.c \
418 drivers
/bus_i2c_stm32f10x.c \
420 drivers
/compass_ak8975.c \
421 drivers
/compass_hmc5883l.c \
422 drivers
/display_ug2864hsweg01.c \
423 drivers
/flash_m25p16.c \
424 drivers
/gpio_stm32f10x.c \
426 drivers
/light_led_stm32f10x.c \
427 drivers
/light_ws2811strip.c \
428 drivers
/light_ws2811strip_stm32f10x.c \
429 drivers
/pwm_mapping.c \
430 drivers
/pwm_output.c \
432 drivers
/serial_softserial.c \
433 drivers
/serial_uart.c \
434 drivers
/serial_uart_stm32f10x.c \
435 drivers
/sonar_hcsr04.c \
436 drivers
/sound_beeper_stm32f10x.c \
437 drivers
/system_stm32f10x.c \
439 drivers
/timer_stm32f10x.c \
444 PORT103R_SRC
= $(EUSTM32F103RC_SRC
)
446 OLIMEXINO_SRC
= startup_stm32f10x_md_gcc.S \
447 drivers
/accgyro_mpu.c \
448 drivers
/accgyro_mpu6050.c \
450 drivers
/adc_stm32f10x.c \
451 drivers
/barometer_bmp085.c \
452 drivers
/barometer_bmp280.c \
453 drivers
/bus_i2c_stm32f10x.c \
455 drivers
/compass_hmc5883l.c \
456 drivers
/gpio_stm32f10x.c \
457 drivers
/light_led_stm32f10x.c \
458 drivers
/light_ws2811strip.c \
459 drivers
/light_ws2811strip_stm32f10x.c \
460 drivers
/pwm_mapping.c \
461 drivers
/pwm_output.c \
463 drivers
/serial_softserial.c \
464 drivers
/serial_uart.c \
465 drivers
/serial_uart_stm32f10x.c \
466 drivers
/sonar_hcsr04.c \
467 drivers
/sound_beeper_stm32f10x.c \
468 drivers
/system_stm32f10x.c \
470 drivers
/timer_stm32f10x.c \
475 startup_stm32f10x_md_gcc.S \
477 drivers
/adc_stm32f10x.c \
478 drivers
/accgyro_mpu.c \
479 drivers
/accgyro_mpu6050.c \
480 drivers
/bus_i2c_stm32f10x.c \
481 drivers
/compass_hmc5883l.c \
482 drivers
/gpio_stm32f10x.c \
483 drivers
/light_led_stm32f10x.c \
484 drivers
/pwm_mapping.c \
485 drivers
/pwm_output.c \
487 drivers
/serial_uart.c \
488 drivers
/serial_uart_stm32f10x.c \
489 drivers
/sound_beeper_stm32f10x.c \
490 drivers
/system_stm32f10x.c \
492 drivers
/timer_stm32f10x.c \
493 hardware_revision.c \
495 blackbox
/blackbox.c \
496 blackbox
/blackbox_io.c \
500 startup_stm32f10x_md_gcc.S \
501 drivers
/accgyro_mpu.c \
502 drivers
/accgyro_spi_mpu6000.c \
504 drivers
/adc_stm32f10x.c \
505 drivers
/barometer_bmp085.c \
506 drivers
/barometer_bmp280.c \
507 drivers
/barometer_ms5611.c \
509 drivers
/bus_i2c_stm32f10x.c \
510 drivers
/compass_hmc5883l.c \
511 drivers
/display_ug2864hsweg01.c \
512 drivers
/flash_m25p16.c \
513 drivers
/gpio_stm32f10x.c \
515 drivers
/light_led_stm32f10x.c \
516 drivers
/light_ws2811strip.c \
517 drivers
/light_ws2811strip_stm32f10x.c \
518 drivers
/pwm_mapping.c \
519 drivers
/pwm_output.c \
521 drivers
/serial_softserial.c \
522 drivers
/serial_uart.c \
523 drivers
/serial_uart_stm32f10x.c \
524 drivers
/sonar_hcsr04.c \
525 drivers
/sound_beeper_stm32f10x.c \
526 drivers
/system_stm32f10x.c \
528 drivers
/timer_stm32f10x.c \
534 STM32F30x_COMMON_SRC
= \
535 startup_stm32f30x_md_gcc.S \
537 drivers
/adc_stm32f30x.c \
538 drivers
/bus_i2c_stm32f30x.c \
540 drivers
/display_ug2864hsweg01.h \
541 drivers
/gpio_stm32f30x.c \
542 drivers
/light_led_stm32f30x.c \
543 drivers
/pwm_mapping.c \
544 drivers
/pwm_output.c \
546 drivers
/serial_uart.c \
547 drivers
/serial_uart_stm32f30x.c \
548 drivers
/sound_beeper_stm32f30x.c \
549 drivers
/system_stm32f30x.c \
551 drivers
/timer_stm32f30x.c
554 $(STM32F30x_COMMON_SRC
) \
559 STM32F3DISCOVERY_COMMON_SRC
= \
560 $(STM32F30x_COMMON_SRC
) \
561 drivers
/light_ws2811strip.c \
562 drivers
/light_ws2811strip_stm32f30x.c \
563 drivers
/accgyro_l3gd20.c \
564 drivers
/accgyro_l3gd20.c \
565 drivers
/accgyro_lsm303dlhc.c \
566 drivers
/compass_hmc5883l.c \
569 STM32F3DISCOVERY_SRC
= \
570 $(STM32F3DISCOVERY_COMMON_SRC
) \
571 drivers
/accgyro_adxl345.c \
572 drivers
/accgyro_bma280.c \
573 drivers
/accgyro_mma845x.c \
574 drivers
/accgyro_mpu.c \
575 drivers
/accgyro_mpu3050.c \
576 drivers
/accgyro_mpu6050.c \
577 drivers
/accgyro_l3g4200d.c \
578 drivers
/barometer_ms5611.c \
579 drivers
/barometer_bmp280.c \
580 drivers
/compass_ak8975.c \
582 drivers
/sdcard_standard.c \
583 io
/asyncfatfs
/asyncfatfs.c \
584 io
/asyncfatfs
/fat_standard.c \
589 $(STM32F3DISCOVERY_SRC
) \
594 $(STM32F30x_COMMON_SRC
) \
596 drivers
/bus_bst_stm32f30x.c \
597 drivers
/accgyro_mpu.c \
598 drivers
/accgyro_mpu6500.c \
599 drivers
/accgyro_spi_mpu6500.c \
600 drivers
/accgyro_mpu6500.c \
601 drivers
/barometer_ms5611.c \
602 drivers
/compass_ak8975.c \
603 drivers
/compass_hmc5883l.c \
604 drivers
/display_ug2864hsweg01.c \
605 drivers
/light_ws2811strip.c \
606 drivers
/light_ws2811strip_stm32f30x.c \
607 drivers
/serial_usb_vcp.c \
613 $(STM32F30x_COMMON_SRC
) \
614 drivers
/accgyro_mpu.c \
615 drivers
/accgyro_mpu6500.c \
616 drivers
/accgyro_spi_mpu6500.c \
617 drivers
/accgyro_mpu6500.c \
618 drivers
/light_ws2811strip.c \
619 drivers
/light_ws2811strip_stm32f30x.c \
620 drivers
/serial_usb_vcp.c \
626 $(STM32F30x_COMMON_SRC
) \
627 drivers
/display_ug2864hsweg01.c \
628 drivers
/accgyro_mpu.c \
629 drivers
/accgyro_mpu6050.c \
630 drivers
/barometer_ms5611.c \
631 drivers
/barometer_bmp280.c \
632 drivers
/compass_ak8975.c \
633 drivers
/light_ws2811strip.c \
634 drivers
/light_ws2811strip_stm32f30x.c \
635 drivers
/serial_usb_vcp.c \
640 ALIENFLIGHTF3_SRC
= \
641 $(STM32F30x_COMMON_SRC
) \
642 drivers
/accgyro_mpu.c \
643 drivers
/accgyro_mpu6050.c \
644 drivers
/accgyro_mpu.c \
645 drivers
/accgyro_mpu6500.c \
646 drivers
/accgyro_spi_mpu6500.c \
647 drivers
/compass_ak8963.c \
648 hardware_revision.c \
649 drivers
/serial_usb_vcp.c \
650 drivers
/sonar_hcsr04.c \
656 $(STM32F30x_COMMON_SRC
) \
657 drivers
/accgyro_mpu.c \
658 drivers
/accgyro_mpu6050.c \
659 drivers
/barometer_bmp280.c \
660 drivers
/display_ug2864hsweg01.h \
661 drivers
/flash_m25p16.c \
662 drivers
/light_ws2811strip.c \
663 drivers
/light_ws2811strip_stm32f30x.c \
664 drivers
/serial_softserial.c \
665 drivers
/sonar_hcsr04.c \
671 $(STM32F30x_COMMON_SRC
) \
672 drivers
/accgyro_mpu.c \
673 drivers
/accgyro_mpu6050.c \
674 drivers
/barometer_ms5611.c \
675 drivers
/compass_ak8975.c \
676 drivers
/barometer_bmp085.c \
677 drivers
/barometer_bmp280.c \
678 drivers
/compass_hmc5883l.c \
679 drivers
/display_ug2864hsweg01.h \
680 drivers
/flash_m25p16.c \
681 drivers
/light_ws2811strip.c \
682 drivers
/light_ws2811strip_stm32f30x.c \
683 drivers
/serial_softserial.c \
684 drivers
/sonar_hcsr04.c \
690 $(STM32F30x_COMMON_SRC
) \
691 drivers
/accgyro_mpu.c \
692 drivers
/accgyro_mpu6050.c \
693 drivers
/barometer_ms5611.c \
694 drivers
/compass_ak8975.c \
695 drivers
/barometer_bmp085.c \
696 drivers
/barometer_bmp280.c \
697 drivers
/compass_hmc5883l.c \
698 drivers
/display_ug2864hsweg01.h \
699 drivers
/flash_m25p16.c \
700 drivers
/light_ws2811strip.c \
701 drivers
/light_ws2811strip_stm32f30x.c \
702 drivers
/serial_softserial.c \
703 drivers
/sonar_hcsr04.c \
709 $(STM32F30x_COMMON_SRC
) \
710 drivers
/accgyro_mpu.c \
711 drivers
/display_ug2864hsweg01.c \
712 drivers
/accgyro_mpu6050.c \
713 drivers
/accgyro_spi_mpu6000.c \
714 drivers
/barometer_ms5611.c \
715 drivers
/compass_hmc5883l.c \
716 drivers
/light_ws2811strip.c \
717 drivers
/light_ws2811strip_stm32f30x.c \
718 drivers
/serial_softserial.c \
719 drivers
/serial_usb_vcp.c \
720 drivers
/flash_m25p16.c \
726 SPRACINGF3MINI_SRC
= \
727 $(STM32F30x_COMMON_SRC
) \
728 drivers
/accgyro_mpu.c \
729 drivers
/accgyro_mpu6500.c \
730 drivers
/barometer_bmp280.c \
731 drivers
/compass_ak8975.c \
732 drivers
/compass_hmc5883l.c \
733 drivers
/display_ug2864hsweg01.h \
734 drivers
/flash_m25p16.c \
735 drivers
/light_ws2811strip.c \
736 drivers
/light_ws2811strip_stm32f30x.c \
737 drivers
/serial_softserial.c \
738 drivers
/serial_usb_vcp.c \
739 drivers
/sonar_hcsr04.c \
741 drivers
/sdcard_standard.c \
742 drivers
/transponder_ir.c \
743 drivers
/transponder_ir_stm32f30x.c \
744 io
/asyncfatfs
/asyncfatfs.c \
745 io
/asyncfatfs
/fat_standard.c \
746 io
/transponder_ir.c \
752 # Search path and source files for the ST stdperiph library
753 VPATH
:= $(VPATH
):$(STDPERIPH_DIR
)/src
755 ###############################################################################
756 # Things that might need changing to use different tools
760 CC
= arm-none-eabi-gcc
761 OBJCOPY
= arm-none-eabi-objcopy
762 SIZE
= arm-none-eabi-size
770 LTO_FLAGS
= $(OPTIMIZE
)
773 LTO_FLAGS
= -flto
-fuse-linker-plugin
$(OPTIMIZE
)
776 DEBUG_FLAGS
= -ggdb3
-DDEBUG
778 CFLAGS
= $(ARCH_FLAGS
) \
780 $(addprefix -D
,$(OPTIONS
)) \
781 $(addprefix -I
,$(INCLUDE_DIRS
)) \
784 -Wall
-Wextra
-Wunsafe-loop-optimizations
-Wdouble-promotion \
785 -ffunction-sections \
788 -DUSE_STDPERIPH_DRIVER \
790 -D
'__FORKNAME__="$(FORKNAME)"' \
791 -D
'__TARGET__="$(TARGET)"' \
792 -D
'__REVISION__="$(REVISION)"' \
796 ASFLAGS
= $(ARCH_FLAGS
) \
797 -x assembler-with-cpp \
798 $(addprefix -I
,$(INCLUDE_DIRS
)) \
810 -Wl
,-gc-sections
,-Map
,$(TARGET_MAP
) \
811 -Wl
,-L
$(LINKER_DIR
) \
815 ###############################################################################
816 # No user-serviceable parts below
817 ###############################################################################
819 CPPCHECK
= cppcheck
$(CSOURCES
) --enable
=all --platform
=unix64 \
820 --std
=c99
--inline-suppr
--quiet
--force \
821 $(addprefix -I
,$(INCLUDE_DIRS
)) \
822 -I
/usr
/include -I
/usr
/include/linux
825 # Things we will build
827 ifeq ($(filter $(TARGET
),$(VALID_TARGETS
)),)
828 $(error Target
'$(TARGET)' is not valid
, must be one of
$(VALID_TARGETS
))
831 CC3D_OPBL_SRC
= $(CC3D_SRC
)
833 TARGET_BIN
= $(BIN_DIR
)/$(FORKNAME
)_
$(FC_VER
)_
$(TARGET
).bin
834 TARGET_HEX
= $(BIN_DIR
)/$(FORKNAME
)_
$(FC_VER
)_
$(TARGET
).hex
835 TARGET_ELF
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).elf
836 TARGET_OBJS
= $(addsuffix .o
,$(addprefix $(OBJECT_DIR
)/$(TARGET
)/,$(basename $($(TARGET
)_SRC
))))
837 TARGET_DEPS
= $(addsuffix .d
,$(addprefix $(OBJECT_DIR
)/$(TARGET
)/,$(basename $($(TARGET
)_SRC
))))
838 TARGET_MAP
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).map
842 CLEAN_ARTIFACTS
:= $(TARGET_BIN
)
844 CLEAN_ARTIFACTS
:= $(TARGET_HEX
)
846 CLEAN_ARTIFACTS
+= $(TARGET_ELF
) $(TARGET_OBJS
) $(TARGET_MAP
)
848 # List of buildable ELF files and their object dependencies.
849 # It would be nice to compute these lists, but that seems to be just beyond make.
851 $(TARGET_HEX
): $(TARGET_ELF
)
852 $(OBJCOPY
) -O ihex
--set-start
0x8000000 $< $@
854 $(TARGET_BIN
): $(TARGET_ELF
)
855 $(OBJCOPY
) -O binary
$< $@
857 $(TARGET_ELF
): $(TARGET_OBJS
)
858 $(CC
) -o
$@
$^
$(LDFLAGS
)
859 $(SIZE
) $(TARGET_ELF
)
862 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.c
864 @echo
%% $(notdir $<)
865 @
$(CC
) -c
-o
$@
$(CFLAGS
) $<
868 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.s
870 @echo
%% $(notdir $<)
871 @
$(CC
) -c
-o
$@
$(ASFLAGS
) $<
873 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.S
875 @echo
%% $(notdir $<)
876 @
$(CC
) -c
-o
$@
$(ASFLAGS
) $<
879 ## all : default task; compile C code, build firmware
882 ## clean : clean up all temporary / machine-generated files
884 rm -f
$(CLEAN_ARTIFACTS
)
885 rm -rf
$(OBJECT_DIR
)/$(TARGET
)
886 cd src
/test && $(MAKE
) clean || true
888 flash_
$(TARGET
): $(TARGET_HEX
)
889 stty
-F
$(SERIAL_DEVICE
) raw speed
115200 -crtscts cs8
-parenb
-cstopb
-ixon
890 echo
-n
'R' >$(SERIAL_DEVICE
)
891 stm32flash
-w
$(TARGET_HEX
) -v
-g
0x0 -b
115200 $(SERIAL_DEVICE
)
893 ## flash : flash firmware (.hex) onto flight controller
894 flash
: flash_
$(TARGET
)
896 st-flash_
$(TARGET
): $(TARGET_BIN
)
897 st-flash
--reset write
$< 0x08000000
899 ## st-flash : flash firmware (.bin) onto flight controller
900 st-flash
: st-flash_
$(TARGET
)
902 binary
: $(TARGET_BIN
)
905 unbrick_
$(TARGET
): $(TARGET_HEX
)
906 stty
-F
$(SERIAL_DEVICE
) raw speed
115200 -crtscts cs8
-parenb
-cstopb
-ixon
907 stm32flash
-w
$(TARGET_HEX
) -v
-g
0x0 -b
115200 $(SERIAL_DEVICE
)
909 ## unbrick : unbrick flight controller
910 unbrick
: unbrick_
$(TARGET
)
912 ## cppcheck : run static analysis on C source code
913 cppcheck
: $(CSOURCES
)
916 cppcheck-result.xml
: $(CSOURCES
)
917 $(CPPCHECK
) --xml-version
=2 2> cppcheck-result.xml
919 ## help : print this help message and exit
922 @echo
"Makefile for the $(FORKNAME) firmware"
925 @echo
" make [TARGET=<target>] [OPTIONS=\"<options>\"]"
927 @echo
"Valid TARGET values are: $(VALID_TARGETS)"
929 @sed
-n
's/^## //p' $<
931 ## test : run the cleanflight test suite
933 cd src
/test && $(MAKE
) test || true
935 # rebuild everything when makefile changes
936 $(TARGET_OBJS
) : Makefile
938 # include auto-generated dependencies
939 -include $(TARGET_DEPS
)