Update video-tutorials.md
[u360gts.git] / Makefile
blob95063249b7e4ba8193363c470062c25bbb176e65
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 ###############################################################################
14 # Things that the user might override on the commandline
17 # The target to build, see VALID_TARGETS below
18 TARGET ?= NAZE
20 # Compile-time options
21 OPTIONS ?=
23 # Debugger optons, must be empty or GDB
24 DEBUG ?=
26 # Serial port/Device for flashing
27 SERIAL_DEVICE ?= $(firstword $(wildcard /dev/ttyUSB*) no-port-found)
29 # Flash size (KB). Some low-end chips actually have more flash than advertised, use this to override.
30 FLASH_SIZE ?=
32 ###############################################################################
33 # Things that need to be maintained as the source changes
36 FORKNAME = amv-open360tracker
38 VALID_TARGETS = ALIENWIIF1 BLUEPILL ALIENWIIF3 CC3D CHEBUZZF3 CJMCU COLIBRI_RACE EUSTM32F103RC MOTOLAB NAZE NAZE32PRO OLIMEXINO PORT103R RMDO SPARKY SPRACINGF3 STM32F3DISCOVERY
40 # Configure default flash sizes for the targets
41 ifeq ($(FLASH_SIZE),)
42 ifeq ($(TARGET),$(filter $(TARGET),CJMCU))
43 FLASH_SIZE = 64
44 else ifeq ($(TARGET),$(filter $(TARGET),ALIENWIIF1 BLUEPILL CC3D NAZE OLIMEXINO RMDO))
45 FLASH_SIZE = 128
46 else ifeq ($(TARGET),$(filter $(TARGET),ALIENWIIF3 CHEBUZZF3 COLIBRI_RACE EUSTM32F103RC MOTOLAB NAZE32PRO PORT103R SPARKY SPRACINGF3 STM32F3DISCOVERY))
47 FLASH_SIZE = 256
48 else
49 $(error FLASH_SIZE not configured for target)
50 endif
51 endif
53 REVISION = $(shell git rev-parse --short HEAD)
55 # Working directories
56 ROOT := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
57 SRC_DIR = $(ROOT)/src/main
58 OBJECT_DIR = $(ROOT)/obj/main
59 BIN_DIR = $(ROOT)/obj
60 CMSIS_DIR = $(ROOT)/lib/main/CMSIS
61 INCLUDE_DIRS = $(SRC_DIR)
62 LINKER_DIR = $(ROOT)/src/main/target
64 # Search path for sources
65 VPATH := $(SRC_DIR):$(SRC_DIR)/startup
66 USBFS_DIR = $(ROOT)/lib/main/STM32_USB-FS-Device_Driver
67 USBPERIPH_SRC = $(notdir $(wildcard $(USBFS_DIR)/src/*.c))
69 CSOURCES := $(shell find $(SRC_DIR) -name '*.c')
71 ifeq ($(TARGET),$(filter $(TARGET),ALIENWIIF3 CHEBUZZF3 COLIBRI_RACE MOTOLAB NAZE32PRO RMDO SPARKY SPRACINGF3 STM32F3DISCOVERY))
73 STDPERIPH_DIR = $(ROOT)/lib/main/STM32F30x_StdPeriph_Driver
75 STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/src/*.c))
77 EXCLUDES = stm32f30x_crc.c \
78 stm32f30x_can.c
80 STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC))
82 DEVICE_STDPERIPH_SRC = \
83 $(STDPERIPH_SRC)
86 VPATH := $(VPATH):$(CMSIS_DIR)/CM1/CoreSupport:$(CMSIS_DIR)/CM1/DeviceSupport/ST/STM32F30x
87 CMSIS_SRC = $(notdir $(wildcard $(CMSIS_DIR)/CM1/CoreSupport/*.c \
88 $(CMSIS_DIR)/CM1/DeviceSupport/ST/STM32F30x/*.c))
90 INCLUDE_DIRS := $(INCLUDE_DIRS) \
91 $(STDPERIPH_DIR)/inc \
92 $(CMSIS_DIR)/CM1/CoreSupport \
93 $(CMSIS_DIR)/CM1/DeviceSupport/ST/STM32F30x
95 ifneq ($(TARGET),SPRACINGF3)
96 INCLUDE_DIRS := $(INCLUDE_DIRS) \
97 $(USBFS_DIR)/inc \
98 $(ROOT)/src/main/vcp
100 VPATH := $(VPATH):$(USBFS_DIR)/src
102 DEVICE_STDPERIPH_SRC := $(DEVICE_STDPERIPH_SRC)\
103 $(USBPERIPH_SRC)
105 endif
107 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f303_$(FLASH_SIZE)k.ld
109 ARCH_FLAGS = -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -Wdouble-promotion
110 DEVICE_FLAGS = -DSTM32F303xC -DSTM32F303
111 TARGET_FLAGS = -D$(TARGET)
112 ifeq ($(TARGET),CHEBUZZF3)
113 # CHEBUZZ is a VARIANT of STM32F3DISCOVERY
114 TARGET_FLAGS := $(TARGET_FLAGS) -DSTM32F3DISCOVERY
115 endif
117 ifeq ($(TARGET),RMDO)
118 # RMDO is a VARIANT of SPRACINGF3
119 TARGET_FLAGS := $(TARGET_FLAGS) -DSPRACINGF3
120 endif
122 else ifeq ($(TARGET),$(filter $(TARGET),EUSTM32F103RC PORT103R))
125 STDPERIPH_DIR = $(ROOT)/lib/main/STM32F10x_StdPeriph_Driver
127 STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/src/*.c))
129 EXCLUDES = stm32f10x_crc.c \
130 stm32f10x_cec.c \
131 stm32f10x_can.c
133 STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC))
135 # Search path and source files for the CMSIS sources
136 VPATH := $(VPATH):$(CMSIS_DIR)/CM3/CoreSupport:$(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x
137 CMSIS_SRC = $(notdir $(wildcard $(CMSIS_DIR)/CM3/CoreSupport/*.c \
138 $(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x/*.c))
140 INCLUDE_DIRS := $(INCLUDE_DIRS) \
141 $(STDPERIPH_DIR)/inc \
142 $(CMSIS_DIR)/CM3/CoreSupport \
143 $(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x \
145 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f103_$(FLASH_SIZE)k.ld
147 ARCH_FLAGS = -mthumb -mcpu=cortex-m3
148 TARGET_FLAGS = -D$(TARGET) -pedantic
149 DEVICE_FLAGS = -DSTM32F10X_HD -DSTM32F10X
151 DEVICE_STDPERIPH_SRC = $(STDPERIPH_SRC)
153 else
155 STDPERIPH_DIR = $(ROOT)/lib/main/STM32F10x_StdPeriph_Driver
157 STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/src/*.c))
159 EXCLUDES = stm32f10x_crc.c \
160 stm32f10x_cec.c \
161 stm32f10x_can.c
163 STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC))
165 # Search path and source files for the CMSIS sources
166 VPATH := $(VPATH):$(CMSIS_DIR)/CM3/CoreSupport:$(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x
167 CMSIS_SRC = $(notdir $(wildcard $(CMSIS_DIR)/CM3/CoreSupport/*.c \
168 $(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x/*.c))
170 INCLUDE_DIRS := $(INCLUDE_DIRS) \
171 $(STDPERIPH_DIR)/inc \
172 $(CMSIS_DIR)/CM3/CoreSupport \
173 $(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x \
175 DEVICE_STDPERIPH_SRC = $(STDPERIPH_SRC)
177 ifeq ($(TARGET),CC3D)
178 INCLUDE_DIRS := $(INCLUDE_DIRS) \
179 $(USBFS_DIR)/inc \
180 $(ROOT)/src/main/vcp
182 VPATH := $(VPATH):$(USBFS_DIR)/src
184 DEVICE_STDPERIPH_SRC := $(DEVICE_STDPERIPH_SRC) \
185 $(USBPERIPH_SRC)
187 endif
189 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f103_$(FLASH_SIZE)k.ld
191 ARCH_FLAGS = -mthumb -mcpu=cortex-m3
192 TARGET_FLAGS = -D$(TARGET) -pedantic
193 DEVICE_FLAGS = -DSTM32F10X_MD -DSTM32F10X
195 endif
197 ifneq ($(FLASH_SIZE),)
198 DEVICE_FLAGS := $(DEVICE_FLAGS) -DFLASH_SIZE=$(FLASH_SIZE)
199 endif
201 TARGET_DIR = $(ROOT)/src/main/target/$(TARGET)
202 TARGET_SRC = $(notdir $(wildcard $(TARGET_DIR)/*.c))
204 ifeq ($(TARGET),ALIENWIIF1)
205 # ALIENWIIF1 is a VARIANT of NAZE
206 TARGET_FLAGS := $(TARGET_FLAGS) -DNAZE -DALIENWII32
207 TARGET_DIR = $(ROOT)/src/main/target/NAZE
208 endif
210 INCLUDE_DIRS := $(INCLUDE_DIRS) \
211 $(TARGET_DIR)
213 VPATH := $(VPATH):$(TARGET_DIR)
215 TRACKER_SRC = tracker/main.c \
216 tracker/Arduino.c \
217 tracker/math.c \
218 tracker/TinyGPS.c \
219 tracker/ltm.c \
220 tracker/mfd.c \
221 tracker/compass.c \
222 tracker/telemetry.c \
223 tracker/mavlink.c \
224 tracker/frskyd.c \
225 tracker/rvosd.c \
226 tracker/ltm.c \
227 tracker/frskyx.c \
228 tracker/gps_estimation.c \
229 tracker/interpolation.c \
230 tracker/protocol_detection.c \
231 tracker/pitlab.c \
232 tracker/crossfire.c
234 COMMON_SRC = $(TRACKER_SRC)\
235 build_config.c \
236 debug.c \
237 version.c \
238 $(TARGET_SRC) \
239 config/config.c \
240 config/runtime_config.c \
241 common/maths.c \
242 common/printf.c \
243 common/typeconversion.c \
244 common/encoding.c \
245 common/filter.c \
246 main.c \
247 flight/altitudehold.c \
248 flight/failsafe.c \
249 flight/pid.c \
250 flight/imu.c \
251 flight/mixer.c \
252 flight/lowpass.c \
253 drivers/bus_i2c_soft.c \
254 drivers/serial.c \
255 drivers/sound_beeper.c \
256 drivers/system.c \
257 io/beeper.c \
258 io/rc_controls.c \
259 io/rc_curves.c \
260 io/serial.c \
261 io/serial_1wire.c \
262 io/serial_cli.c \
263 io/serial_msp.c \
264 io/statusindicator.c \
265 rx/rx.c \
266 rx/pwm.c \
267 rx/msp.c \
268 rx/sbus.c \
269 rx/sumd.c \
270 rx/sumh.c \
271 rx/spektrum.c \
272 rx/xbus.c \
273 sensors/acceleration.c \
274 sensors/battery.c \
275 sensors/boardalignment.c \
276 sensors/compass.c \
277 sensors/gyro.c \
278 sensors/initialisation.c \
279 $(CMSIS_SRC) \
280 $(DEVICE_STDPERIPH_SRC)
282 HIGHEND_SRC = \
283 flight/gtune.c \
284 flight/navigation.c \
285 flight/gps_conversion.c \
286 common/colorconversion.c \
287 io/gps.c \
288 io/ledstrip.c \
289 io/display.c \
290 telemetry/telemetry.c \
291 telemetry/frsky.c \
292 telemetry/hott.c \
293 telemetry/msp.c \
294 telemetry/smartport.c \
295 telemetry/mfd.c \
296 telemetry/mavlink.c \
297 telemetry/nmea.c \
298 telemetry/ltm.c \
299 telemetry/position_estimation_log.c \
300 telemetry/forward.c \
301 sensors/sonar.c \
302 sensors/barometer.c
304 VCP_SRC = \
305 vcp/hw_config.c \
306 vcp/stm32_it.c \
307 vcp/usb_desc.c \
308 vcp/usb_endp.c \
309 vcp/usb_istr.c \
310 vcp/usb_prop.c \
311 vcp/usb_pwr.c \
312 drivers/serial_usb_vcp.c
314 NAZE_SRC = startup_stm32f10x_md_gcc.S \
315 drivers/accgyro_adxl345.c \
316 drivers/accgyro_bma280.c \
317 drivers/accgyro_l3g4200d.c \
318 drivers/accgyro_mma845x.c \
319 drivers/accgyro_mpu.c \
320 drivers/accgyro_mpu3050.c \
321 drivers/accgyro_mpu6050.c \
322 drivers/accgyro_mpu6500.c \
323 drivers/accgyro_spi_mpu6500.c \
324 drivers/adc.c \
325 drivers/adc_stm32f10x.c \
326 drivers/barometer_bmp085.c \
327 drivers/barometer_ms5611.c \
328 drivers/barometer_bmp280.c \
329 drivers/bus_spi.c \
330 drivers/bus_i2c_stm32f10x.c \
331 drivers/compass_hmc5883l.c \
332 drivers/compass_qmc5883l.c \
333 drivers/display_ug2864hsweg01.h \
334 drivers/flash_m25p16.c \
335 drivers/gpio_stm32f10x.c \
336 drivers/inverter.c \
337 drivers/light_led_stm32f10x.c \
338 drivers/light_ws2811strip.c \
339 drivers/light_ws2811strip_stm32f10x.c \
340 drivers/sonar_hcsr04.c \
341 drivers/pwm_mapping.c \
342 drivers/pwm_output.c \
343 drivers/pwm_rx.c \
344 drivers/serial_softserial.c \
345 drivers/serial_uart.c \
346 drivers/serial_uart_stm32f10x.c \
347 drivers/sound_beeper_stm32f10x.c \
348 drivers/system_stm32f10x.c \
349 drivers/timer.c \
350 drivers/timer_stm32f10x.c \
351 io/flashfs.c \
352 hardware_revision.c \
353 $(HIGHEND_SRC) \
354 $(COMMON_SRC)
356 ALIENWIIF1_SRC = $(NAZE_SRC)
358 BLUEPILL_SRC = startup_stm32f10x_md_gcc.S \
359 drivers/adc.c \
360 drivers/adc_stm32f10x.c \
361 drivers/bus_spi.c \
362 drivers/bus_i2c_stm32f10x.c \
363 drivers/compass_hmc5883l.c \
364 drivers/compass_qmc5883l.c \
365 drivers/display_ug2864hsweg01.h \
366 drivers/flash_m25p16.c \
367 drivers/gpio_stm32f10x.c \
368 drivers/inverter.c \
369 drivers/light_led_stm32f10x.c \
370 drivers/light_ws2811strip.c \
371 drivers/light_ws2811strip_stm32f10x.c \
372 drivers/sonar_hcsr04.c \
373 drivers/pwm_mapping.c \
374 drivers/pwm_output.c \
375 drivers/pwm_rx.c \
376 drivers/serial_softserial.c \
377 drivers/serial_uart.c \
378 drivers/serial_uart_stm32f10x.c \
379 drivers/sound_beeper_stm32f10x.c \
380 drivers/system_stm32f10x.c \
381 drivers/timer.c \
382 drivers/timer_stm32f10x.c \
383 io/flashfs.c \
384 hardware_revision.c \
385 $(HIGHEND_SRC) \
386 $(COMMON_SRC)
388 EUSTM32F103RC_SRC = startup_stm32f10x_hd_gcc.S \
389 drivers/accgyro_adxl345.c \
390 drivers/accgyro_bma280.c \
391 drivers/accgyro_l3g4200d.c \
392 drivers/accgyro_mma845x.c \
393 drivers/accgyro_mpu.c \
394 drivers/accgyro_mpu3050.c \
395 drivers/accgyro_mpu6050.c \
396 drivers/accgyro_spi_mpu6000.c \
397 drivers/accgyro_spi_mpu6500.c \
398 drivers/adc.c \
399 drivers/adc_stm32f10x.c \
400 drivers/barometer_bmp085.c \
401 drivers/barometer_ms5611.c \
402 drivers/bus_i2c_stm32f10x.c \
403 drivers/bus_spi.c \
404 drivers/compass_ak8975.c \
405 drivers/compass_hmc5883l.c \
406 drivers/display_ug2864hsweg01.c \
407 drivers/flash_m25p16.c \
408 drivers/gpio_stm32f10x.c \
409 drivers/inverter.c \
410 drivers/light_led_stm32f10x.c \
411 drivers/light_ws2811strip.c \
412 drivers/light_ws2811strip_stm32f10x.c \
413 drivers/pwm_mapping.c \
414 drivers/pwm_output.c \
415 drivers/pwm_rx.c \
416 drivers/serial_softserial.c \
417 drivers/serial_uart.c \
418 drivers/serial_uart_stm32f10x.c \
419 drivers/sonar_hcsr04.c \
420 drivers/sound_beeper_stm32f10x.c \
421 drivers/system_stm32f10x.c \
422 drivers/timer.c \
423 drivers/timer_stm32f10x.c \
424 io/flashfs.c \
425 $(HIGHEND_SRC) \
426 $(COMMON_SRC)
428 PORT103R_SRC = $(EUSTM32F103RC_SRC)
430 OLIMEXINO_SRC = startup_stm32f10x_md_gcc.S \
431 drivers/accgyro_mpu.c \
432 drivers/accgyro_mpu6050.c \
433 drivers/adc.c \
434 drivers/adc_stm32f10x.c \
435 drivers/barometer_bmp085.c \
436 drivers/bus_i2c_stm32f10x.c \
437 drivers/bus_spi.c \
438 drivers/compass_hmc5883l.c \
439 drivers/gpio_stm32f10x.c \
440 drivers/light_led_stm32f10x.c \
441 drivers/light_ws2811strip.c \
442 drivers/light_ws2811strip_stm32f10x.c \
443 drivers/pwm_mapping.c \
444 drivers/pwm_output.c \
445 drivers/pwm_rx.c \
446 drivers/serial_softserial.c \
447 drivers/serial_uart.c \
448 drivers/serial_uart_stm32f10x.c \
449 drivers/sonar_hcsr04.c \
450 drivers/sound_beeper_stm32f10x.c \
451 drivers/system_stm32f10x.c \
452 drivers/timer.c \
453 drivers/timer_stm32f10x.c \
454 $(HIGHEND_SRC) \
455 $(COMMON_SRC)
457 CJMCU_SRC = \
458 startup_stm32f10x_md_gcc.S \
459 drivers/adc.c \
460 drivers/adc_stm32f10x.c \
461 drivers/accgyro_mpu.c \
462 drivers/accgyro_mpu6050.c \
463 drivers/bus_i2c_stm32f10x.c \
464 drivers/compass_hmc5883l.c \
465 drivers/gpio_stm32f10x.c \
466 drivers/light_led_stm32f10x.c \
467 drivers/pwm_mapping.c \
468 drivers/pwm_output.c \
469 drivers/pwm_rx.c \
470 drivers/serial_uart.c \
471 drivers/serial_uart_stm32f10x.c \
472 drivers/sound_beeper_stm32f10x.c \
473 drivers/system_stm32f10x.c \
474 drivers/timer.c \
475 drivers/timer_stm32f10x.c \
476 hardware_revision.c \
477 flight/gtune.c \
478 $(COMMON_SRC)
480 CC3D_SRC = \
481 startup_stm32f10x_md_gcc.S \
482 drivers/accgyro_mpu.c \
483 drivers/accgyro_spi_mpu6000.c \
484 drivers/adc.c \
485 drivers/adc_stm32f10x.c \
486 drivers/barometer_bmp085.c \
487 drivers/barometer_ms5611.c \
488 drivers/bus_spi.c \
489 drivers/bus_i2c_stm32f10x.c \
490 drivers/compass_hmc5883l.c \
491 drivers/compass_qmc5883l.c \
492 drivers/display_ug2864hsweg01.c \
493 drivers/flash_m25p16.c \
494 drivers/gpio_stm32f10x.c \
495 drivers/inverter.c \
496 drivers/light_led_stm32f10x.c \
497 drivers/light_ws2811strip.c \
498 drivers/light_ws2811strip_stm32f10x.c \
499 drivers/pwm_mapping.c \
500 drivers/pwm_output.c \
501 drivers/pwm_rx.c \
502 drivers/serial_softserial.c \
503 drivers/serial_uart.c \
504 drivers/serial_uart_stm32f10x.c \
505 drivers/sonar_hcsr04.c \
506 drivers/sound_beeper_stm32f10x.c \
507 drivers/system_stm32f10x.c \
508 drivers/timer.c \
509 drivers/timer_stm32f10x.c \
510 io/flashfs.c \
511 $(HIGHEND_SRC) \
512 $(COMMON_SRC) \
513 $(VCP_SRC)
515 STM32F30x_COMMON_SRC = \
516 startup_stm32f30x_md_gcc.S \
517 drivers/adc.c \
518 drivers/adc_stm32f30x.c \
519 drivers/bus_i2c_stm32f30x.c \
520 drivers/bus_spi.c \
521 drivers/gpio_stm32f30x.c \
522 drivers/light_led_stm32f30x.c \
523 drivers/light_ws2811strip.c \
524 drivers/light_ws2811strip_stm32f30x.c \
525 drivers/pwm_mapping.c \
526 drivers/pwm_output.c \
527 drivers/pwm_rx.c \
528 drivers/serial_uart.c \
529 drivers/serial_uart_stm32f30x.c \
530 drivers/sound_beeper_stm32f30x.c \
531 drivers/system_stm32f30x.c \
532 drivers/timer.c \
533 drivers/timer_stm32f30x.c
535 NAZE32PRO_SRC = \
536 $(STM32F30x_COMMON_SRC) \
537 $(HIGHEND_SRC) \
538 $(COMMON_SRC) \
539 $(VCP_SRC)
541 STM32F3DISCOVERY_COMMON_SRC = \
542 $(STM32F30x_COMMON_SRC) \
543 drivers/accgyro_l3gd20.c \
544 drivers/accgyro_l3gd20.c \
545 drivers/accgyro_lsm303dlhc.c \
546 drivers/compass_hmc5883l.c \
547 $(VCP_SRC)
549 STM32F3DISCOVERY_SRC = \
550 $(STM32F3DISCOVERY_COMMON_SRC) \
551 drivers/accgyro_adxl345.c \
552 drivers/accgyro_bma280.c \
553 drivers/accgyro_mma845x.c \
554 drivers/accgyro_mpu.c \
555 drivers/accgyro_mpu3050.c \
556 drivers/accgyro_mpu6050.c \
557 drivers/accgyro_l3g4200d.c \
558 drivers/barometer_ms5611.c \
559 drivers/compass_ak8975.c \
560 $(HIGHEND_SRC) \
561 $(COMMON_SRC)
563 CHEBUZZF3_SRC = \
564 $(STM32F3DISCOVERY_SRC) \
565 $(HIGHEND_SRC) \
566 $(COMMON_SRC)
568 COLIBRI_RACE_SRC = \
569 $(STM32F30x_COMMON_SRC) \
570 drivers/display_ug2864hsweg01.c \
571 drivers/accgyro_mpu.c \
572 drivers/accgyro_mpu6500.c \
573 drivers/accgyro_spi_mpu6500.c \
574 drivers/accgyro_mpu6500.c \
575 drivers/barometer_ms5611.c \
576 drivers/compass_ak8975.c \
577 drivers/compass_hmc5883l.c \
578 drivers/serial_usb_vcp.c \
579 $(HIGHEND_SRC) \
580 $(COMMON_SRC) \
581 $(VCP_SRC)
583 SPARKY_SRC = \
584 $(STM32F30x_COMMON_SRC) \
585 drivers/display_ug2864hsweg01.c \
586 drivers/accgyro_mpu.c \
587 drivers/accgyro_mpu6050.c \
588 drivers/barometer_ms5611.c \
589 drivers/compass_ak8975.c \
590 drivers/serial_usb_vcp.c \
591 $(HIGHEND_SRC) \
592 $(COMMON_SRC) \
593 $(VCP_SRC)
595 ALIENWIIF3_SRC = \
596 $(SPARKY_SRC)
598 RMDO_SRC = \
599 $(STM32F30x_COMMON_SRC) \
600 drivers/accgyro_mpu.c \
601 drivers/accgyro_mpu6050.c \
602 drivers/barometer_bmp280.c \
603 drivers/display_ug2864hsweg01.h \
604 drivers/flash_m25p16.c \
605 drivers/serial_softserial.c \
606 drivers/sonar_hcsr04.c \
607 io/flashfs.c \
608 $(HIGHEND_SRC) \
609 $(COMMON_SRC)
611 SPRACINGF3_SRC = \
612 $(STM32F30x_COMMON_SRC) \
613 drivers/accgyro_mpu.c \
614 drivers/accgyro_mpu6050.c \
615 drivers/barometer_ms5611.c \
616 drivers/compass_ak8975.c \
617 drivers/compass_hmc5883l.c \
618 drivers/compass_qmc5883l.c \
619 drivers/display_ug2864hsweg01.h \
620 drivers/flash_m25p16.c \
621 drivers/serial_softserial.c \
622 drivers/sonar_hcsr04.c \
623 io/flashfs.c \
624 $(HIGHEND_SRC) \
625 $(COMMON_SRC)
627 MOTOLAB_SRC = \
628 $(STM32F30x_COMMON_SRC) \
629 drivers/accgyro_mpu.c \
630 drivers/accgyro_mpu6050.c \
631 drivers/barometer_ms5611.c \
632 drivers/compass_hmc5883l.c \
633 drivers/display_ug2864hsweg01.c \
634 drivers/serial_usb_vcp.c \
635 drivers/flash_m25p16.c \
636 io/flashfs.c \
637 $(HIGHEND_SRC) \
638 $(COMMON_SRC) \
639 $(VCP_SRC)
641 # Search path and source files for the ST stdperiph library
642 VPATH := $(VPATH):$(STDPERIPH_DIR)/src
644 ###############################################################################
645 # Things that might need changing to use different tools
648 # Tool names
649 CC = arm-none-eabi-gcc
650 OBJCOPY = arm-none-eabi-objcopy
651 SIZE = arm-none-eabi-size
654 # Tool options.
657 ifeq ($(DEBUG),GDB)
658 OPTIMIZE = -O0
659 LTO_FLAGS = $(OPTIMIZE)
660 else
661 OPTIMIZE = -Os
662 LTO_FLAGS = -flto -fuse-linker-plugin $(OPTIMIZE)
663 endif
665 DEBUG_FLAGS = -ggdb3 -DDEBUG
667 CFLAGS = $(ARCH_FLAGS) \
668 $(LTO_FLAGS) \
669 $(addprefix -D,$(OPTIONS)) \
670 $(addprefix -I,$(INCLUDE_DIRS)) \
671 $(DEBUG_FLAGS) \
672 -std=gnu99 \
673 -Wall -Wextra -Wunsafe-loop-optimizations -Wdouble-promotion \
674 -ffunction-sections \
675 -fdata-sections \
676 $(DEVICE_FLAGS) \
677 -DUSE_STDPERIPH_DRIVER \
678 $(TARGET_FLAGS) \
679 -D'__FORKNAME__="$(FORKNAME)"' \
680 -D'__TARGET__="$(TARGET)"' \
681 -D'__REVISION__="$(REVISION)"' \
682 -save-temps=obj \
683 -MMD -MP
685 ASFLAGS = $(ARCH_FLAGS) \
686 -x assembler-with-cpp \
687 $(addprefix -I,$(INCLUDE_DIRS)) \
688 -MMD -MP
690 LDFLAGS = -lm \
691 -nostartfiles \
692 --specs=nano.specs \
693 -lc \
694 -lnosys \
695 $(ARCH_FLAGS) \
696 $(LTO_FLAGS) \
697 $(DEBUG_FLAGS) \
698 -static \
699 -Wl,-gc-sections,-Map,$(TARGET_MAP) \
700 -Wl,-L$(LINKER_DIR) \
701 -T$(LD_SCRIPT)
703 ###############################################################################
704 # No user-serviceable parts below
705 ###############################################################################
707 CPPCHECK = cppcheck $(CSOURCES) --enable=all --platform=unix64 \
708 --std=c99 --inline-suppr --quiet --force \
709 $(addprefix -I,$(INCLUDE_DIRS)) \
710 -I/usr/include -I/usr/include/linux
713 # Things we will build
715 ifeq ($(filter $(TARGET),$(VALID_TARGETS)),)
716 $(error Target '$(TARGET)' is not valid, must be one of $(VALID_TARGETS))
717 endif
719 TARGET_BIN = $(BIN_DIR)/$(FORKNAME)_$(TARGET).bin
720 TARGET_HEX = $(BIN_DIR)/$(FORKNAME)_$(TARGET).hex
721 TARGET_ELF = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET).elf
722 TARGET_OBJS = $(addsuffix .o,$(addprefix $(OBJECT_DIR)/$(TARGET)/,$(basename $($(TARGET)_SRC))))
723 TARGET_DEPS = $(addsuffix .d,$(addprefix $(OBJECT_DIR)/$(TARGET)/,$(basename $($(TARGET)_SRC))))
724 TARGET_MAP = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET).map
726 # List of buildable ELF files and their object dependencies.
727 # It would be nice to compute these lists, but that seems to be just beyond make.
729 $(TARGET_HEX): $(TARGET_ELF)
730 $(OBJCOPY) -O ihex --set-start 0x8000000 $< $@
732 $(TARGET_BIN): $(TARGET_ELF)
733 $(OBJCOPY) -O binary $< $@
735 $(TARGET_ELF): $(TARGET_OBJS)
736 $(CC) -o $@ $^ $(LDFLAGS)
737 $(SIZE) $(TARGET_ELF)
739 # Compile
740 $(OBJECT_DIR)/$(TARGET)/%.o: %.c
741 @mkdir -p $(dir $@)
742 @echo %% $(notdir $<)
743 @$(CC) -c -o $@ $(CFLAGS) $<
745 # Assemble
746 $(OBJECT_DIR)/$(TARGET)/%.o: %.s
747 @mkdir -p $(dir $@)
748 @echo %% $(notdir $<)
749 @$(CC) -c -o $@ $(ASFLAGS) $<
751 $(OBJECT_DIR)/$(TARGET)/%.o: %.S
752 @mkdir -p $(dir $@)
753 @echo %% $(notdir $<)
754 @$(CC) -c -o $@ $(ASFLAGS) $<
757 ## all : default task; compile C code, build firmware
758 all: binary
760 ## clean : clean up all temporary / machine-generated files
761 clean:
762 rm -f $(TARGET_BIN) $(TARGET_HEX) $(TARGET_ELF) $(TARGET_OBJS) $(TARGET_MAP)
763 rm -rf $(OBJECT_DIR)/$(TARGET)
764 cd src/test && $(MAKE) clean || true
766 flash_$(TARGET): $(TARGET_HEX)
767 stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
768 echo -n 'R' >$(SERIAL_DEVICE)
769 stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
771 ## flash : flash firmware (.hex) onto flight controller
772 flash: flash_$(TARGET)
774 st-flash_$(TARGET): $(TARGET_BIN)
775 st-flash --reset write $< 0x08000000
777 ## st-flash : flash firmware (.bin) onto flight controller
778 st-flash: st-flash_$(TARGET)
780 binary: $(TARGET_BIN)
782 unbrick_$(TARGET): $(TARGET_HEX)
783 stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
784 stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
786 ## unbrick : unbrick flight controller
787 unbrick: unbrick_$(TARGET)
789 ## cppcheck : run static analysis on C source code
790 cppcheck: $(CSOURCES)
791 $(CPPCHECK)
793 cppcheck-result.xml: $(CSOURCES)
794 $(CPPCHECK) --xml-version=2 2> cppcheck-result.xml
796 ## help : print this help message and exit
797 help: Makefile
798 @echo ""
799 @echo "Makefile for the $(FORKNAME) firmware"
800 @echo ""
801 @echo "Usage:"
802 @echo " make [TARGET=<target>] [OPTIONS=\"<options>\"]"
803 @echo ""
804 @echo "Valid TARGET values are: $(VALID_TARGETS)"
805 @echo ""
806 @sed -n 's/^## //p' $<
808 ## test : run the cleanflight test suite
809 test:
810 cd src/test && $(MAKE) test || true
812 # rebuild everything when makefile changes
813 $(TARGET_OBJS) : Makefile
815 # include auto-generated dependencies
816 -include $(TARGET_DEPS)