Version bump.
[u360gts.git] / Makefile
blobfdbbc7021c9a6fb4a750653317dddeebb2992bec
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 log -1 --format="%h")
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
233 COMMON_SRC = $(TRACKER_SRC)\
234 build_config.c \
235 debug.c \
236 version.c \
237 $(TARGET_SRC) \
238 config/config.c \
239 config/runtime_config.c \
240 common/maths.c \
241 common/printf.c \
242 common/typeconversion.c \
243 common/encoding.c \
244 common/filter.c \
245 main.c \
246 flight/altitudehold.c \
247 flight/failsafe.c \
248 flight/pid.c \
249 flight/imu.c \
250 flight/mixer.c \
251 flight/lowpass.c \
252 drivers/bus_i2c_soft.c \
253 drivers/serial.c \
254 drivers/sound_beeper.c \
255 drivers/system.c \
256 io/beeper.c \
257 io/rc_controls.c \
258 io/rc_curves.c \
259 io/serial.c \
260 io/serial_1wire.c \
261 io/serial_cli.c \
262 io/serial_msp.c \
263 io/statusindicator.c \
264 rx/rx.c \
265 rx/pwm.c \
266 rx/msp.c \
267 rx/sbus.c \
268 rx/sumd.c \
269 rx/sumh.c \
270 rx/spektrum.c \
271 rx/xbus.c \
272 sensors/acceleration.c \
273 sensors/battery.c \
274 sensors/boardalignment.c \
275 sensors/compass.c \
276 sensors/gyro.c \
277 sensors/initialisation.c \
278 $(CMSIS_SRC) \
279 $(DEVICE_STDPERIPH_SRC)
281 HIGHEND_SRC = \
282 flight/gtune.c \
283 flight/navigation.c \
284 flight/gps_conversion.c \
285 common/colorconversion.c \
286 io/gps.c \
287 io/ledstrip.c \
288 io/display.c \
289 telemetry/telemetry.c \
290 telemetry/frsky.c \
291 telemetry/hott.c \
292 telemetry/msp.c \
293 telemetry/smartport.c \
294 telemetry/mfd.c \
295 telemetry/mavlink.c \
296 telemetry/nmea.c \
297 telemetry/ltm.c \
298 telemetry/position_estimation_log.c \
299 sensors/sonar.c \
300 sensors/barometer.c
302 VCP_SRC = \
303 vcp/hw_config.c \
304 vcp/stm32_it.c \
305 vcp/usb_desc.c \
306 vcp/usb_endp.c \
307 vcp/usb_istr.c \
308 vcp/usb_prop.c \
309 vcp/usb_pwr.c \
310 drivers/serial_usb_vcp.c
312 NAZE_SRC = startup_stm32f10x_md_gcc.S \
313 drivers/accgyro_adxl345.c \
314 drivers/accgyro_bma280.c \
315 drivers/accgyro_l3g4200d.c \
316 drivers/accgyro_mma845x.c \
317 drivers/accgyro_mpu.c \
318 drivers/accgyro_mpu3050.c \
319 drivers/accgyro_mpu6050.c \
320 drivers/accgyro_mpu6500.c \
321 drivers/accgyro_spi_mpu6500.c \
322 drivers/adc.c \
323 drivers/adc_stm32f10x.c \
324 drivers/barometer_bmp085.c \
325 drivers/barometer_ms5611.c \
326 drivers/barometer_bmp280.c \
327 drivers/bus_spi.c \
328 drivers/bus_i2c_stm32f10x.c \
329 drivers/compass_hmc5883l.c \
330 drivers/display_ug2864hsweg01.h \
331 drivers/flash_m25p16.c \
332 drivers/gpio_stm32f10x.c \
333 drivers/inverter.c \
334 drivers/light_led_stm32f10x.c \
335 drivers/light_ws2811strip.c \
336 drivers/light_ws2811strip_stm32f10x.c \
337 drivers/sonar_hcsr04.c \
338 drivers/pwm_mapping.c \
339 drivers/pwm_output.c \
340 drivers/pwm_rx.c \
341 drivers/serial_softserial.c \
342 drivers/serial_uart.c \
343 drivers/serial_uart_stm32f10x.c \
344 drivers/sound_beeper_stm32f10x.c \
345 drivers/system_stm32f10x.c \
346 drivers/timer.c \
347 drivers/timer_stm32f10x.c \
348 io/flashfs.c \
349 hardware_revision.c \
350 $(HIGHEND_SRC) \
351 $(COMMON_SRC)
353 ALIENWIIF1_SRC = $(NAZE_SRC)
355 BLUEPILL_SRC = startup_stm32f10x_md_gcc.S \
356 drivers/adc.c \
357 drivers/adc_stm32f10x.c \
358 drivers/bus_spi.c \
359 drivers/bus_i2c_stm32f10x.c \
360 drivers/compass_hmc5883l.c \
361 drivers/display_ug2864hsweg01.h \
362 drivers/flash_m25p16.c \
363 drivers/gpio_stm32f10x.c \
364 drivers/inverter.c \
365 drivers/light_led_stm32f10x.c \
366 drivers/light_ws2811strip.c \
367 drivers/light_ws2811strip_stm32f10x.c \
368 drivers/sonar_hcsr04.c \
369 drivers/pwm_mapping.c \
370 drivers/pwm_output.c \
371 drivers/pwm_rx.c \
372 drivers/serial_softserial.c \
373 drivers/serial_uart.c \
374 drivers/serial_uart_stm32f10x.c \
375 drivers/sound_beeper_stm32f10x.c \
376 drivers/system_stm32f10x.c \
377 drivers/timer.c \
378 drivers/timer_stm32f10x.c \
379 io/flashfs.c \
380 hardware_revision.c \
381 $(HIGHEND_SRC) \
382 $(COMMON_SRC)
384 EUSTM32F103RC_SRC = startup_stm32f10x_hd_gcc.S \
385 drivers/accgyro_adxl345.c \
386 drivers/accgyro_bma280.c \
387 drivers/accgyro_l3g4200d.c \
388 drivers/accgyro_mma845x.c \
389 drivers/accgyro_mpu.c \
390 drivers/accgyro_mpu3050.c \
391 drivers/accgyro_mpu6050.c \
392 drivers/accgyro_spi_mpu6000.c \
393 drivers/accgyro_spi_mpu6500.c \
394 drivers/adc.c \
395 drivers/adc_stm32f10x.c \
396 drivers/barometer_bmp085.c \
397 drivers/barometer_ms5611.c \
398 drivers/bus_i2c_stm32f10x.c \
399 drivers/bus_spi.c \
400 drivers/compass_ak8975.c \
401 drivers/compass_hmc5883l.c \
402 drivers/display_ug2864hsweg01.c \
403 drivers/flash_m25p16.c \
404 drivers/gpio_stm32f10x.c \
405 drivers/inverter.c \
406 drivers/light_led_stm32f10x.c \
407 drivers/light_ws2811strip.c \
408 drivers/light_ws2811strip_stm32f10x.c \
409 drivers/pwm_mapping.c \
410 drivers/pwm_output.c \
411 drivers/pwm_rx.c \
412 drivers/serial_softserial.c \
413 drivers/serial_uart.c \
414 drivers/serial_uart_stm32f10x.c \
415 drivers/sonar_hcsr04.c \
416 drivers/sound_beeper_stm32f10x.c \
417 drivers/system_stm32f10x.c \
418 drivers/timer.c \
419 drivers/timer_stm32f10x.c \
420 io/flashfs.c \
421 $(HIGHEND_SRC) \
422 $(COMMON_SRC)
424 PORT103R_SRC = $(EUSTM32F103RC_SRC)
426 OLIMEXINO_SRC = startup_stm32f10x_md_gcc.S \
427 drivers/accgyro_mpu.c \
428 drivers/accgyro_mpu6050.c \
429 drivers/adc.c \
430 drivers/adc_stm32f10x.c \
431 drivers/barometer_bmp085.c \
432 drivers/bus_i2c_stm32f10x.c \
433 drivers/bus_spi.c \
434 drivers/compass_hmc5883l.c \
435 drivers/gpio_stm32f10x.c \
436 drivers/light_led_stm32f10x.c \
437 drivers/light_ws2811strip.c \
438 drivers/light_ws2811strip_stm32f10x.c \
439 drivers/pwm_mapping.c \
440 drivers/pwm_output.c \
441 drivers/pwm_rx.c \
442 drivers/serial_softserial.c \
443 drivers/serial_uart.c \
444 drivers/serial_uart_stm32f10x.c \
445 drivers/sonar_hcsr04.c \
446 drivers/sound_beeper_stm32f10x.c \
447 drivers/system_stm32f10x.c \
448 drivers/timer.c \
449 drivers/timer_stm32f10x.c \
450 $(HIGHEND_SRC) \
451 $(COMMON_SRC)
453 CJMCU_SRC = \
454 startup_stm32f10x_md_gcc.S \
455 drivers/adc.c \
456 drivers/adc_stm32f10x.c \
457 drivers/accgyro_mpu.c \
458 drivers/accgyro_mpu6050.c \
459 drivers/bus_i2c_stm32f10x.c \
460 drivers/compass_hmc5883l.c \
461 drivers/gpio_stm32f10x.c \
462 drivers/light_led_stm32f10x.c \
463 drivers/pwm_mapping.c \
464 drivers/pwm_output.c \
465 drivers/pwm_rx.c \
466 drivers/serial_uart.c \
467 drivers/serial_uart_stm32f10x.c \
468 drivers/sound_beeper_stm32f10x.c \
469 drivers/system_stm32f10x.c \
470 drivers/timer.c \
471 drivers/timer_stm32f10x.c \
472 hardware_revision.c \
473 flight/gtune.c \
474 $(COMMON_SRC)
476 CC3D_SRC = \
477 startup_stm32f10x_md_gcc.S \
478 drivers/accgyro_mpu.c \
479 drivers/accgyro_spi_mpu6000.c \
480 drivers/adc.c \
481 drivers/adc_stm32f10x.c \
482 drivers/barometer_bmp085.c \
483 drivers/barometer_ms5611.c \
484 drivers/bus_spi.c \
485 drivers/bus_i2c_stm32f10x.c \
486 drivers/compass_hmc5883l.c \
487 drivers/display_ug2864hsweg01.c \
488 drivers/flash_m25p16.c \
489 drivers/gpio_stm32f10x.c \
490 drivers/inverter.c \
491 drivers/light_led_stm32f10x.c \
492 drivers/light_ws2811strip.c \
493 drivers/light_ws2811strip_stm32f10x.c \
494 drivers/pwm_mapping.c \
495 drivers/pwm_output.c \
496 drivers/pwm_rx.c \
497 drivers/serial_softserial.c \
498 drivers/serial_uart.c \
499 drivers/serial_uart_stm32f10x.c \
500 drivers/sonar_hcsr04.c \
501 drivers/sound_beeper_stm32f10x.c \
502 drivers/system_stm32f10x.c \
503 drivers/timer.c \
504 drivers/timer_stm32f10x.c \
505 io/flashfs.c \
506 $(HIGHEND_SRC) \
507 $(COMMON_SRC) \
508 $(VCP_SRC)
510 STM32F30x_COMMON_SRC = \
511 startup_stm32f30x_md_gcc.S \
512 drivers/adc.c \
513 drivers/adc_stm32f30x.c \
514 drivers/bus_i2c_stm32f30x.c \
515 drivers/bus_spi.c \
516 drivers/gpio_stm32f30x.c \
517 drivers/light_led_stm32f30x.c \
518 drivers/light_ws2811strip.c \
519 drivers/light_ws2811strip_stm32f30x.c \
520 drivers/pwm_mapping.c \
521 drivers/pwm_output.c \
522 drivers/pwm_rx.c \
523 drivers/serial_uart.c \
524 drivers/serial_uart_stm32f30x.c \
525 drivers/sound_beeper_stm32f30x.c \
526 drivers/system_stm32f30x.c \
527 drivers/timer.c \
528 drivers/timer_stm32f30x.c
530 NAZE32PRO_SRC = \
531 $(STM32F30x_COMMON_SRC) \
532 $(HIGHEND_SRC) \
533 $(COMMON_SRC) \
534 $(VCP_SRC)
536 STM32F3DISCOVERY_COMMON_SRC = \
537 $(STM32F30x_COMMON_SRC) \
538 drivers/accgyro_l3gd20.c \
539 drivers/accgyro_l3gd20.c \
540 drivers/accgyro_lsm303dlhc.c \
541 drivers/compass_hmc5883l.c \
542 $(VCP_SRC)
544 STM32F3DISCOVERY_SRC = \
545 $(STM32F3DISCOVERY_COMMON_SRC) \
546 drivers/accgyro_adxl345.c \
547 drivers/accgyro_bma280.c \
548 drivers/accgyro_mma845x.c \
549 drivers/accgyro_mpu.c \
550 drivers/accgyro_mpu3050.c \
551 drivers/accgyro_mpu6050.c \
552 drivers/accgyro_l3g4200d.c \
553 drivers/barometer_ms5611.c \
554 drivers/compass_ak8975.c \
555 $(HIGHEND_SRC) \
556 $(COMMON_SRC)
558 CHEBUZZF3_SRC = \
559 $(STM32F3DISCOVERY_SRC) \
560 $(HIGHEND_SRC) \
561 $(COMMON_SRC)
563 COLIBRI_RACE_SRC = \
564 $(STM32F30x_COMMON_SRC) \
565 drivers/display_ug2864hsweg01.c \
566 drivers/accgyro_mpu.c \
567 drivers/accgyro_mpu6500.c \
568 drivers/accgyro_spi_mpu6500.c \
569 drivers/accgyro_mpu6500.c \
570 drivers/barometer_ms5611.c \
571 drivers/compass_ak8975.c \
572 drivers/compass_hmc5883l.c \
573 drivers/serial_usb_vcp.c \
574 $(HIGHEND_SRC) \
575 $(COMMON_SRC) \
576 $(VCP_SRC)
578 SPARKY_SRC = \
579 $(STM32F30x_COMMON_SRC) \
580 drivers/display_ug2864hsweg01.c \
581 drivers/accgyro_mpu.c \
582 drivers/accgyro_mpu6050.c \
583 drivers/barometer_ms5611.c \
584 drivers/compass_ak8975.c \
585 drivers/serial_usb_vcp.c \
586 $(HIGHEND_SRC) \
587 $(COMMON_SRC) \
588 $(VCP_SRC)
590 ALIENWIIF3_SRC = \
591 $(SPARKY_SRC)
593 RMDO_SRC = \
594 $(STM32F30x_COMMON_SRC) \
595 drivers/accgyro_mpu.c \
596 drivers/accgyro_mpu6050.c \
597 drivers/barometer_bmp280.c \
598 drivers/display_ug2864hsweg01.h \
599 drivers/flash_m25p16.c \
600 drivers/serial_softserial.c \
601 drivers/sonar_hcsr04.c \
602 io/flashfs.c \
603 $(HIGHEND_SRC) \
604 $(COMMON_SRC)
606 SPRACINGF3_SRC = \
607 $(STM32F30x_COMMON_SRC) \
608 drivers/accgyro_mpu.c \
609 drivers/accgyro_mpu6050.c \
610 drivers/barometer_ms5611.c \
611 drivers/compass_ak8975.c \
612 drivers/compass_hmc5883l.c \
613 drivers/display_ug2864hsweg01.h \
614 drivers/flash_m25p16.c \
615 drivers/serial_softserial.c \
616 drivers/sonar_hcsr04.c \
617 io/flashfs.c \
618 $(HIGHEND_SRC) \
619 $(COMMON_SRC)
621 MOTOLAB_SRC = \
622 $(STM32F30x_COMMON_SRC) \
623 drivers/accgyro_mpu.c \
624 drivers/accgyro_mpu6050.c \
625 drivers/barometer_ms5611.c \
626 drivers/compass_hmc5883l.c \
627 drivers/display_ug2864hsweg01.c \
628 drivers/serial_usb_vcp.c \
629 drivers/flash_m25p16.c \
630 io/flashfs.c \
631 $(HIGHEND_SRC) \
632 $(COMMON_SRC) \
633 $(VCP_SRC)
635 # Search path and source files for the ST stdperiph library
636 VPATH := $(VPATH):$(STDPERIPH_DIR)/src
638 ###############################################################################
639 # Things that might need changing to use different tools
642 # Tool names
643 CC = arm-none-eabi-gcc
644 OBJCOPY = arm-none-eabi-objcopy
645 SIZE = arm-none-eabi-size
648 # Tool options.
651 ifeq ($(DEBUG),GDB)
652 OPTIMIZE = -O0
653 LTO_FLAGS = $(OPTIMIZE)
654 else
655 OPTIMIZE = -Os
656 LTO_FLAGS = -flto -fuse-linker-plugin $(OPTIMIZE)
657 endif
659 DEBUG_FLAGS = -ggdb3 -DDEBUG
661 CFLAGS = $(ARCH_FLAGS) \
662 $(LTO_FLAGS) \
663 $(addprefix -D,$(OPTIONS)) \
664 $(addprefix -I,$(INCLUDE_DIRS)) \
665 $(DEBUG_FLAGS) \
666 -std=gnu99 \
667 -Wall -Wextra -Wunsafe-loop-optimizations -Wdouble-promotion \
668 -ffunction-sections \
669 -fdata-sections \
670 $(DEVICE_FLAGS) \
671 -DUSE_STDPERIPH_DRIVER \
672 $(TARGET_FLAGS) \
673 -D'__FORKNAME__="$(FORKNAME)"' \
674 -D'__TARGET__="$(TARGET)"' \
675 -D'__REVISION__="$(REVISION)"' \
676 -save-temps=obj \
677 -MMD -MP
679 ASFLAGS = $(ARCH_FLAGS) \
680 -x assembler-with-cpp \
681 $(addprefix -I,$(INCLUDE_DIRS)) \
682 -MMD -MP
684 LDFLAGS = -lm \
685 -nostartfiles \
686 --specs=nano.specs \
687 -lc \
688 -lnosys \
689 $(ARCH_FLAGS) \
690 $(LTO_FLAGS) \
691 $(DEBUG_FLAGS) \
692 -static \
693 -Wl,-gc-sections,-Map,$(TARGET_MAP) \
694 -Wl,-L$(LINKER_DIR) \
695 -T$(LD_SCRIPT)
697 ###############################################################################
698 # No user-serviceable parts below
699 ###############################################################################
701 CPPCHECK = cppcheck $(CSOURCES) --enable=all --platform=unix64 \
702 --std=c99 --inline-suppr --quiet --force \
703 $(addprefix -I,$(INCLUDE_DIRS)) \
704 -I/usr/include -I/usr/include/linux
707 # Things we will build
709 ifeq ($(filter $(TARGET),$(VALID_TARGETS)),)
710 $(error Target '$(TARGET)' is not valid, must be one of $(VALID_TARGETS))
711 endif
713 TARGET_BIN = $(BIN_DIR)/$(FORKNAME)_$(TARGET).bin
714 TARGET_HEX = $(BIN_DIR)/$(FORKNAME)_$(TARGET).hex
715 TARGET_ELF = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET).elf
716 TARGET_OBJS = $(addsuffix .o,$(addprefix $(OBJECT_DIR)/$(TARGET)/,$(basename $($(TARGET)_SRC))))
717 TARGET_DEPS = $(addsuffix .d,$(addprefix $(OBJECT_DIR)/$(TARGET)/,$(basename $($(TARGET)_SRC))))
718 TARGET_MAP = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET).map
720 # List of buildable ELF files and their object dependencies.
721 # It would be nice to compute these lists, but that seems to be just beyond make.
723 $(TARGET_HEX): $(TARGET_ELF)
724 $(OBJCOPY) -O ihex --set-start 0x8000000 $< $@
726 $(TARGET_BIN): $(TARGET_ELF)
727 $(OBJCOPY) -O binary $< $@
729 $(TARGET_ELF): $(TARGET_OBJS)
730 $(CC) -o $@ $^ $(LDFLAGS)
731 $(SIZE) $(TARGET_ELF)
733 # Compile
734 $(OBJECT_DIR)/$(TARGET)/%.o: %.c
735 @mkdir -p $(dir $@)
736 @echo %% $(notdir $<)
737 @$(CC) -c -o $@ $(CFLAGS) $<
739 # Assemble
740 $(OBJECT_DIR)/$(TARGET)/%.o: %.s
741 @mkdir -p $(dir $@)
742 @echo %% $(notdir $<)
743 @$(CC) -c -o $@ $(ASFLAGS) $<
745 $(OBJECT_DIR)/$(TARGET)/%.o: %.S
746 @mkdir -p $(dir $@)
747 @echo %% $(notdir $<)
748 @$(CC) -c -o $@ $(ASFLAGS) $<
751 ## all : default task; compile C code, build firmware
752 all: binary
754 ## clean : clean up all temporary / machine-generated files
755 clean:
756 rm -f $(TARGET_BIN) $(TARGET_HEX) $(TARGET_ELF) $(TARGET_OBJS) $(TARGET_MAP)
757 rm -rf $(OBJECT_DIR)/$(TARGET)
758 cd src/test && $(MAKE) clean || true
760 flash_$(TARGET): $(TARGET_HEX)
761 stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
762 echo -n 'R' >$(SERIAL_DEVICE)
763 stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
765 ## flash : flash firmware (.hex) onto flight controller
766 flash: flash_$(TARGET)
768 st-flash_$(TARGET): $(TARGET_BIN)
769 st-flash --reset write $< 0x08000000
771 ## st-flash : flash firmware (.bin) onto flight controller
772 st-flash: st-flash_$(TARGET)
774 binary: $(TARGET_BIN)
776 unbrick_$(TARGET): $(TARGET_HEX)
777 stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
778 stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
780 ## unbrick : unbrick flight controller
781 unbrick: unbrick_$(TARGET)
783 ## cppcheck : run static analysis on C source code
784 cppcheck: $(CSOURCES)
785 $(CPPCHECK)
787 cppcheck-result.xml: $(CSOURCES)
788 $(CPPCHECK) --xml-version=2 2> cppcheck-result.xml
790 ## help : print this help message and exit
791 help: Makefile
792 @echo ""
793 @echo "Makefile for the $(FORKNAME) firmware"
794 @echo ""
795 @echo "Usage:"
796 @echo " make [TARGET=<target>] [OPTIONS=\"<options>\"]"
797 @echo ""
798 @echo "Valid TARGET values are: $(VALID_TARGETS)"
799 @echo ""
800 @sed -n 's/^## //p' $<
802 ## test : run the cleanflight test suite
803 test:
804 cd src/test && $(MAKE) test || true
806 # rebuild everything when makefile changes
807 $(TARGET_OBJS) : Makefile
809 # include auto-generated dependencies
810 -include $(TARGET_DEPS)