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 \
289 flight
/altitudehold.c \
294 drivers
/bus_i2c_soft.c \
296 drivers
/sound_beeper.c \
298 drivers
/gyro_sync.c \
300 drivers
/buf_writer.c \
308 io
/statusindicator.c \
319 sensors
/acceleration.c \
321 sensors
/boardalignment.c \
324 sensors
/initialisation.c \
326 $(DEVICE_STDPERIPH_SRC
)
330 flight
/navigation.c \
331 flight
/gps_conversion.c \
332 common
/colorconversion.c \
336 telemetry
/telemetry.c \
339 telemetry
/smartport.c \
342 sensors
/barometer.c \
343 blackbox
/blackbox.c \
344 blackbox
/blackbox_io.c
354 drivers
/serial_usb_vcp.c
356 NAZE_SRC
= startup_stm32f10x_md_gcc.S \
357 drivers
/accgyro_adxl345.c \
358 drivers
/accgyro_bma280.c \
359 drivers
/accgyro_l3g4200d.c \
360 drivers
/accgyro_mma845x.c \
361 drivers
/accgyro_mpu.c \
362 drivers
/accgyro_mpu3050.c \
363 drivers
/accgyro_mpu6050.c \
364 drivers
/accgyro_mpu6500.c \
365 drivers
/accgyro_spi_mpu6500.c \
367 drivers
/adc_stm32f10x.c \
368 drivers
/barometer_bmp085.c \
369 drivers
/barometer_bmp280.c \
370 drivers
/barometer_ms5611.c \
371 drivers
/barometer_bmp280.c \
373 drivers
/bus_i2c_stm32f10x.c \
374 drivers
/compass_hmc5883l.c \
375 drivers
/display_ug2864hsweg01.h \
376 drivers
/flash_m25p16.c \
377 drivers
/gpio_stm32f10x.c \
379 drivers
/light_led_stm32f10x.c \
380 drivers
/light_ws2811strip.c \
381 drivers
/light_ws2811strip_stm32f10x.c \
382 drivers
/sonar_hcsr04.c \
383 drivers
/pwm_mapping.c \
384 drivers
/pwm_output.c \
386 drivers
/serial_softserial.c \
387 drivers
/serial_uart.c \
388 drivers
/serial_uart_stm32f10x.c \
389 drivers
/sound_beeper_stm32f10x.c \
390 drivers
/system_stm32f10x.c \
392 drivers
/timer_stm32f10x.c \
394 hardware_revision.c \
398 ALIENFLIGHTF1_SRC
= $(NAZE_SRC
)
400 AFROMINI_SRC
= $(NAZE_SRC
)
402 EUSTM32F103RC_SRC
= startup_stm32f10x_hd_gcc.S \
403 drivers
/accgyro_adxl345.c \
404 drivers
/accgyro_bma280.c \
405 drivers
/accgyro_l3g4200d.c \
406 drivers
/accgyro_mma845x.c \
407 drivers
/accgyro_mpu.c \
408 drivers
/accgyro_mpu3050.c \
409 drivers
/accgyro_mpu6050.c \
410 drivers
/accgyro_spi_mpu6000.c \
411 drivers
/accgyro_spi_mpu6500.c \
413 drivers
/adc_stm32f10x.c \
414 drivers
/barometer_bmp085.c \
415 drivers
/barometer_bmp280.c \
416 drivers
/barometer_ms5611.c \
417 drivers
/bus_i2c_stm32f10x.c \
419 drivers
/compass_ak8975.c \
420 drivers
/compass_hmc5883l.c \
421 drivers
/display_ug2864hsweg01.c \
422 drivers
/flash_m25p16.c \
423 drivers
/gpio_stm32f10x.c \
425 drivers
/light_led_stm32f10x.c \
426 drivers
/light_ws2811strip.c \
427 drivers
/light_ws2811strip_stm32f10x.c \
428 drivers
/pwm_mapping.c \
429 drivers
/pwm_output.c \
431 drivers
/serial_softserial.c \
432 drivers
/serial_uart.c \
433 drivers
/serial_uart_stm32f10x.c \
434 drivers
/sonar_hcsr04.c \
435 drivers
/sound_beeper_stm32f10x.c \
436 drivers
/system_stm32f10x.c \
438 drivers
/timer_stm32f10x.c \
443 PORT103R_SRC
= $(EUSTM32F103RC_SRC
)
445 OLIMEXINO_SRC
= startup_stm32f10x_md_gcc.S \
446 drivers
/accgyro_mpu.c \
447 drivers
/accgyro_mpu6050.c \
449 drivers
/adc_stm32f10x.c \
450 drivers
/barometer_bmp085.c \
451 drivers
/barometer_bmp280.c \
452 drivers
/bus_i2c_stm32f10x.c \
454 drivers
/compass_hmc5883l.c \
455 drivers
/gpio_stm32f10x.c \
456 drivers
/light_led_stm32f10x.c \
457 drivers
/light_ws2811strip.c \
458 drivers
/light_ws2811strip_stm32f10x.c \
459 drivers
/pwm_mapping.c \
460 drivers
/pwm_output.c \
462 drivers
/serial_softserial.c \
463 drivers
/serial_uart.c \
464 drivers
/serial_uart_stm32f10x.c \
465 drivers
/sonar_hcsr04.c \
466 drivers
/sound_beeper_stm32f10x.c \
467 drivers
/system_stm32f10x.c \
469 drivers
/timer_stm32f10x.c \
474 startup_stm32f10x_md_gcc.S \
476 drivers
/adc_stm32f10x.c \
477 drivers
/accgyro_mpu.c \
478 drivers
/accgyro_mpu6050.c \
479 drivers
/bus_i2c_stm32f10x.c \
480 drivers
/compass_hmc5883l.c \
481 drivers
/gpio_stm32f10x.c \
482 drivers
/light_led_stm32f10x.c \
483 drivers
/pwm_mapping.c \
484 drivers
/pwm_output.c \
486 drivers
/serial_uart.c \
487 drivers
/serial_uart_stm32f10x.c \
488 drivers
/sound_beeper_stm32f10x.c \
489 drivers
/system_stm32f10x.c \
491 drivers
/timer_stm32f10x.c \
492 hardware_revision.c \
494 blackbox
/blackbox.c \
495 blackbox
/blackbox_io.c \
499 startup_stm32f10x_md_gcc.S \
500 drivers
/accgyro_mpu.c \
501 drivers
/accgyro_spi_mpu6000.c \
503 drivers
/adc_stm32f10x.c \
504 drivers
/barometer_bmp085.c \
505 drivers
/barometer_bmp280.c \
506 drivers
/barometer_ms5611.c \
508 drivers
/bus_i2c_stm32f10x.c \
509 drivers
/compass_hmc5883l.c \
510 drivers
/display_ug2864hsweg01.c \
511 drivers
/flash_m25p16.c \
512 drivers
/gpio_stm32f10x.c \
514 drivers
/light_led_stm32f10x.c \
515 drivers
/light_ws2811strip.c \
516 drivers
/light_ws2811strip_stm32f10x.c \
517 drivers
/pwm_mapping.c \
518 drivers
/pwm_output.c \
520 drivers
/serial_softserial.c \
521 drivers
/serial_uart.c \
522 drivers
/serial_uart_stm32f10x.c \
523 drivers
/sonar_hcsr04.c \
524 drivers
/sound_beeper_stm32f10x.c \
525 drivers
/system_stm32f10x.c \
527 drivers
/timer_stm32f10x.c \
533 STM32F30x_COMMON_SRC
= \
534 startup_stm32f30x_md_gcc.S \
536 drivers
/adc_stm32f30x.c \
537 drivers
/bus_i2c_stm32f30x.c \
539 drivers
/display_ug2864hsweg01.h \
540 drivers
/gpio_stm32f30x.c \
541 drivers
/light_led_stm32f30x.c \
542 drivers
/pwm_mapping.c \
543 drivers
/pwm_output.c \
545 drivers
/serial_uart.c \
546 drivers
/serial_uart_stm32f30x.c \
547 drivers
/sound_beeper_stm32f30x.c \
548 drivers
/system_stm32f30x.c \
550 drivers
/timer_stm32f30x.c
553 $(STM32F30x_COMMON_SRC
) \
558 STM32F3DISCOVERY_COMMON_SRC
= \
559 $(STM32F30x_COMMON_SRC
) \
560 drivers
/light_ws2811strip.c \
561 drivers
/light_ws2811strip_stm32f30x.c \
562 drivers
/accgyro_l3gd20.c \
563 drivers
/accgyro_l3gd20.c \
564 drivers
/accgyro_lsm303dlhc.c \
565 drivers
/compass_hmc5883l.c \
568 STM32F3DISCOVERY_SRC
= \
569 $(STM32F3DISCOVERY_COMMON_SRC
) \
570 drivers
/accgyro_adxl345.c \
571 drivers
/accgyro_bma280.c \
572 drivers
/accgyro_mma845x.c \
573 drivers
/accgyro_mpu.c \
574 drivers
/accgyro_mpu3050.c \
575 drivers
/accgyro_mpu6050.c \
576 drivers
/accgyro_l3g4200d.c \
577 drivers
/barometer_ms5611.c \
578 drivers
/barometer_bmp280.c \
579 drivers
/compass_ak8975.c \
581 drivers
/sdcard_standard.c \
582 io
/asyncfatfs
/asyncfatfs.c \
583 io
/asyncfatfs
/fat_standard.c \
588 $(STM32F3DISCOVERY_SRC
) \
593 $(STM32F30x_COMMON_SRC
) \
595 drivers
/bus_bst_stm32f30x.c \
596 drivers
/accgyro_mpu.c \
597 drivers
/accgyro_mpu6500.c \
598 drivers
/accgyro_spi_mpu6500.c \
599 drivers
/accgyro_mpu6500.c \
600 drivers
/barometer_ms5611.c \
601 drivers
/compass_ak8975.c \
602 drivers
/compass_hmc5883l.c \
603 drivers
/display_ug2864hsweg01.c \
604 drivers
/light_ws2811strip.c \
605 drivers
/light_ws2811strip_stm32f30x.c \
606 drivers
/serial_usb_vcp.c \
612 $(STM32F30x_COMMON_SRC
) \
613 drivers
/accgyro_mpu.c \
614 drivers
/accgyro_mpu6500.c \
615 drivers
/accgyro_spi_mpu6500.c \
616 drivers
/accgyro_mpu6500.c \
617 drivers
/light_ws2811strip.c \
618 drivers
/light_ws2811strip_stm32f30x.c \
619 drivers
/serial_usb_vcp.c \
625 $(STM32F30x_COMMON_SRC
) \
626 drivers
/display_ug2864hsweg01.c \
627 drivers
/accgyro_mpu.c \
628 drivers
/accgyro_mpu6050.c \
629 drivers
/barometer_ms5611.c \
630 drivers
/barometer_bmp280.c \
631 drivers
/compass_ak8975.c \
632 drivers
/light_ws2811strip.c \
633 drivers
/light_ws2811strip_stm32f30x.c \
634 drivers
/serial_usb_vcp.c \
639 ALIENFLIGHTF3_SRC
= \
640 $(STM32F30x_COMMON_SRC
) \
641 drivers
/accgyro_mpu.c \
642 drivers
/accgyro_mpu6050.c \
643 drivers
/accgyro_mpu.c \
644 drivers
/accgyro_mpu6500.c \
645 drivers
/accgyro_spi_mpu6500.c \
646 drivers
/compass_ak8963.c \
647 hardware_revision.c \
648 drivers
/serial_usb_vcp.c \
649 drivers
/sonar_hcsr04.c \
655 $(STM32F30x_COMMON_SRC
) \
656 drivers
/accgyro_mpu.c \
657 drivers
/accgyro_mpu6050.c \
658 drivers
/barometer_bmp280.c \
659 drivers
/display_ug2864hsweg01.h \
660 drivers
/flash_m25p16.c \
661 drivers
/light_ws2811strip.c \
662 drivers
/light_ws2811strip_stm32f30x.c \
663 drivers
/serial_softserial.c \
664 drivers
/sonar_hcsr04.c \
670 $(STM32F30x_COMMON_SRC
) \
671 drivers
/accgyro_mpu.c \
672 drivers
/accgyro_mpu6050.c \
673 drivers
/barometer_ms5611.c \
674 drivers
/compass_ak8975.c \
675 drivers
/barometer_bmp085.c \
676 drivers
/barometer_bmp280.c \
677 drivers
/compass_hmc5883l.c \
678 drivers
/display_ug2864hsweg01.h \
679 drivers
/flash_m25p16.c \
680 drivers
/light_ws2811strip.c \
681 drivers
/light_ws2811strip_stm32f30x.c \
682 drivers
/serial_softserial.c \
683 drivers
/sonar_hcsr04.c \
689 $(STM32F30x_COMMON_SRC
) \
690 drivers
/accgyro_mpu.c \
691 drivers
/accgyro_mpu6050.c \
692 drivers
/barometer_ms5611.c \
693 drivers
/compass_ak8975.c \
694 drivers
/barometer_bmp085.c \
695 drivers
/barometer_bmp280.c \
696 drivers
/compass_hmc5883l.c \
697 drivers
/display_ug2864hsweg01.h \
698 drivers
/flash_m25p16.c \
699 drivers
/light_ws2811strip.c \
700 drivers
/light_ws2811strip_stm32f30x.c \
701 drivers
/serial_softserial.c \
702 drivers
/sonar_hcsr04.c \
708 $(STM32F30x_COMMON_SRC
) \
709 drivers
/accgyro_mpu.c \
710 drivers
/display_ug2864hsweg01.c \
711 drivers
/accgyro_mpu6050.c \
712 drivers
/accgyro_spi_mpu6000.c \
713 drivers
/barometer_ms5611.c \
714 drivers
/compass_hmc5883l.c \
715 drivers
/light_ws2811strip.c \
716 drivers
/light_ws2811strip_stm32f30x.c \
717 drivers
/serial_softserial.c \
718 drivers
/serial_usb_vcp.c \
719 drivers
/flash_m25p16.c \
725 SPRACINGF3MINI_SRC
= \
726 $(STM32F30x_COMMON_SRC
) \
727 drivers
/accgyro_mpu.c \
728 drivers
/accgyro_mpu6500.c \
729 drivers
/barometer_bmp280.c \
730 drivers
/compass_ak8975.c \
731 drivers
/compass_hmc5883l.c \
732 drivers
/display_ug2864hsweg01.h \
733 drivers
/flash_m25p16.c \
734 drivers
/light_ws2811strip.c \
735 drivers
/light_ws2811strip_stm32f30x.c \
736 drivers
/serial_softserial.c \
737 drivers
/serial_usb_vcp.c \
738 drivers
/sonar_hcsr04.c \
740 drivers
/sdcard_standard.c \
741 drivers
/transponder_ir.c \
742 drivers
/transponder_ir_stm32f30x.c \
743 io
/asyncfatfs
/asyncfatfs.c \
744 io
/asyncfatfs
/fat_standard.c \
745 io
/transponder_ir.c \
751 # Search path and source files for the ST stdperiph library
752 VPATH
:= $(VPATH
):$(STDPERIPH_DIR
)/src
754 ###############################################################################
755 # Things that might need changing to use different tools
759 CC
= arm-none-eabi-gcc
760 OBJCOPY
= arm-none-eabi-objcopy
761 SIZE
= arm-none-eabi-size
769 LTO_FLAGS
= $(OPTIMIZE
)
772 LTO_FLAGS
= -flto
-fuse-linker-plugin
$(OPTIMIZE
)
775 DEBUG_FLAGS
= -ggdb3
-DDEBUG
777 CFLAGS
= $(ARCH_FLAGS
) \
779 $(addprefix -D
,$(OPTIONS
)) \
780 $(addprefix -I
,$(INCLUDE_DIRS
)) \
783 -Wall
-Wextra
-Wunsafe-loop-optimizations
-Wdouble-promotion \
784 -ffunction-sections \
787 -DUSE_STDPERIPH_DRIVER \
789 -D
'__FORKNAME__="$(FORKNAME)"' \
790 -D
'__TARGET__="$(TARGET)"' \
791 -D
'__REVISION__="$(REVISION)"' \
795 ASFLAGS
= $(ARCH_FLAGS
) \
796 -x assembler-with-cpp \
797 $(addprefix -I
,$(INCLUDE_DIRS
)) \
809 -Wl
,-gc-sections
,-Map
,$(TARGET_MAP
) \
810 -Wl
,-L
$(LINKER_DIR
) \
814 ###############################################################################
815 # No user-serviceable parts below
816 ###############################################################################
818 CPPCHECK
= cppcheck
$(CSOURCES
) --enable
=all --platform
=unix64 \
819 --std
=c99
--inline-suppr
--quiet
--force \
820 $(addprefix -I
,$(INCLUDE_DIRS
)) \
821 -I
/usr
/include -I
/usr
/include/linux
824 # Things we will build
826 ifeq ($(filter $(TARGET
),$(VALID_TARGETS
)),)
827 $(error Target
'$(TARGET)' is not valid
, must be one of
$(VALID_TARGETS
))
830 CC3D_OPBL_SRC
= $(CC3D_SRC
)
832 TARGET_BIN
= $(BIN_DIR
)/$(FORKNAME
)_
$(FC_VER
)_
$(TARGET
).bin
833 TARGET_HEX
= $(BIN_DIR
)/$(FORKNAME
)_
$(FC_VER
)_
$(TARGET
).hex
834 TARGET_ELF
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).elf
835 TARGET_OBJS
= $(addsuffix .o
,$(addprefix $(OBJECT_DIR
)/$(TARGET
)/,$(basename $($(TARGET
)_SRC
))))
836 TARGET_DEPS
= $(addsuffix .d
,$(addprefix $(OBJECT_DIR
)/$(TARGET
)/,$(basename $($(TARGET
)_SRC
))))
837 TARGET_MAP
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET
).map
841 CLEAN_ARTIFACTS
:= $(TARGET_BIN
)
843 CLEAN_ARTIFACTS
:= $(TARGET_HEX
)
845 CLEAN_ARTIFACTS
+= $(TARGET_ELF
) $(TARGET_OBJS
) $(TARGET_MAP
)
847 # List of buildable ELF files and their object dependencies.
848 # It would be nice to compute these lists, but that seems to be just beyond make.
850 $(TARGET_HEX
): $(TARGET_ELF
)
851 $(OBJCOPY
) -O ihex
--set-start
0x8000000 $< $@
853 $(TARGET_BIN
): $(TARGET_ELF
)
854 $(OBJCOPY
) -O binary
$< $@
856 $(TARGET_ELF
): $(TARGET_OBJS
)
857 $(CC
) -o
$@
$^
$(LDFLAGS
)
858 $(SIZE
) $(TARGET_ELF
)
861 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.c
863 @echo
%% $(notdir $<)
864 @
$(CC
) -c
-o
$@
$(CFLAGS
) $<
867 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.s
869 @echo
%% $(notdir $<)
870 @
$(CC
) -c
-o
$@
$(ASFLAGS
) $<
872 $(OBJECT_DIR
)/$(TARGET
)/%.o
: %.S
874 @echo
%% $(notdir $<)
875 @
$(CC
) -c
-o
$@
$(ASFLAGS
) $<
878 ## all : default task; compile C code, build firmware
881 ## clean : clean up all temporary / machine-generated files
883 rm -f
$(CLEAN_ARTIFACTS
)
884 rm -rf
$(OBJECT_DIR
)/$(TARGET
)
885 cd src
/test && $(MAKE
) clean || true
887 flash_
$(TARGET
): $(TARGET_HEX
)
888 stty
-F
$(SERIAL_DEVICE
) raw speed
115200 -crtscts cs8
-parenb
-cstopb
-ixon
889 echo
-n
'R' >$(SERIAL_DEVICE
)
890 stm32flash
-w
$(TARGET_HEX
) -v
-g
0x0 -b
115200 $(SERIAL_DEVICE
)
892 ## flash : flash firmware (.hex) onto flight controller
893 flash
: flash_
$(TARGET
)
895 st-flash_
$(TARGET
): $(TARGET_BIN
)
896 st-flash
--reset write
$< 0x08000000
898 ## st-flash : flash firmware (.bin) onto flight controller
899 st-flash
: st-flash_
$(TARGET
)
901 binary
: $(TARGET_BIN
)
904 unbrick_
$(TARGET
): $(TARGET_HEX
)
905 stty
-F
$(SERIAL_DEVICE
) raw speed
115200 -crtscts cs8
-parenb
-cstopb
-ixon
906 stm32flash
-w
$(TARGET_HEX
) -v
-g
0x0 -b
115200 $(SERIAL_DEVICE
)
908 ## unbrick : unbrick flight controller
909 unbrick
: unbrick_
$(TARGET
)
911 ## cppcheck : run static analysis on C source code
912 cppcheck
: $(CSOURCES
)
915 cppcheck-result.xml
: $(CSOURCES
)
916 $(CPPCHECK
) --xml-version
=2 2> cppcheck-result.xml
918 ## help : print this help message and exit
921 @echo
"Makefile for the $(FORKNAME) firmware"
924 @echo
" make [TARGET=<target>] [OPTIONS=\"<options>\"]"
926 @echo
"Valid TARGET values are: $(VALID_TARGETS)"
928 @sed
-n
's/^## //p' $<
930 ## test : run the cleanflight test suite
932 cd src
/test && $(MAKE
) test || true
934 # rebuild everything when makefile changes
935 $(TARGET_OBJS
) : Makefile
937 # include auto-generated dependencies
938 -include $(TARGET_DEPS
)