Skip to content

Commit

Permalink
Merge pull request #5363 from iNavFlight/development
Browse files Browse the repository at this point in the history
Release 2.4
  • Loading branch information
digitalentity authored Feb 11, 2020
2 parents debe8ab + 60c13ef commit bcd4cae
Show file tree
Hide file tree
Showing 221 changed files with 460,679 additions and 1,068 deletions.
173 changes: 37 additions & 136 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
#
###############################################################################

# Root directory
ROOT := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))

# developer preferences, edit these at will, they'll be gitignored
-include $(ROOT)/make/local.mk

# Things that the user might override on the commandline
#
Expand All @@ -24,6 +29,8 @@ OPTIONS ?=
# Debugger optons, must be empty or GDB
DEBUG ?=

SEMIHOSTING ?=

# Build suffix
BUILD_SUFFIX ?=

Expand Down Expand Up @@ -60,7 +67,6 @@ endif
FORKNAME = inav

# Working directories
ROOT := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
SRC_DIR := $(ROOT)/src/main
OBJECT_DIR := $(ROOT)/obj/main
BIN_DIR := $(ROOT)/obj
Expand All @@ -72,69 +78,14 @@ LINKER_DIR := $(ROOT)/src/main/target/link
# import macros common to all supported build systems
include $(ROOT)/make/system-id.mk

# developer preferences, edit these at will, they'll be gitignored
-include $(ROOT)/make/local.mk

# default xtal value for F4 targets
HSE_VALUE = 8000000
MHZ_VALUE ?=

# used for turning on features like VCP and SDCARD
FEATURES =

ALT_TARGETS = $(sort $(filter-out target, $(basename $(notdir $(wildcard $(ROOT)/src/main/target/*/*.mk)))))

VALID_TARGETS = $(dir $(wildcard $(ROOT)/src/main/target/*/target.mk))
VALID_TARGETS := $(subst /,, $(subst ./src/main/target/,, $(VALID_TARGETS)))
VALID_TARGETS := $(VALID_TARGETS) $(ALT_TARGETS)
VALID_TARGETS := $(sort $(VALID_TARGETS))

CLEAN_TARGETS = $(addprefix clean_,$(VALID_TARGETS) )
TARGETS_CLEAN = $(addsuffix _clean,$(VALID_TARGETS) )
STFLASH_TARGETS = $(addprefix st-flash_,$(VALID_TARGETS) )

ifeq ($(filter $(TARGET),$(ALT_TARGETS)), $(TARGET))
BASE_TARGET := $(firstword $(subst /,, $(subst ./src/main/target/,, $(dir $(wildcard $(ROOT)/src/main/target/*/$(TARGET).mk)))))
-include $(ROOT)/src/main/target/$(BASE_TARGET)/$(TARGET).mk
else
BASE_TARGET := $(TARGET)
endif

# silently ignore if the file is not present. Allows for target specific.
-include $(ROOT)/src/main/target/$(BASE_TARGET)/target.mk

F4_TARGETS = $(F405_TARGETS) $(F411_TARGETS) $(F427_TARGETS) $(F446_TARGETS)
F7_TARGETS = $(F7X2RE_TARGETS) $(F7X5XE_TARGETS) $(F7X5XG_TARGETS) $(F7X5XI_TARGETS) $(F7X6XG_TARGETS)

ifeq ($(filter $(TARGET),$(VALID_TARGETS)),)
$(error Target '$(TARGET)' is not valid, must be one of $(VALID_TARGETS). Have you prepared a valid target.mk?)
endif

ifeq ($(filter $(TARGET),$(F1_TARGETS) $(F3_TARGETS) $(F4_TARGETS) $(F7_TARGETS)),)
$(error Target '$(TARGET)' has not specified a valid STM group, must be one of F1, F3, F405, F411, F427 or F7x. Have you prepared a valid target.mk?)
endif

ifeq ($(TARGET),$(filter $(TARGET),$(F3_TARGETS)))
TARGET_MCU := STM32F3
else ifeq ($(TARGET),$(filter $(TARGET), $(F4_TARGETS)))
TARGET_MCU := STM32F4
else ifeq ($(TARGET),$(filter $(TARGET), $(F7_TARGETS)))
TARGET_MCU := STM32F7
else ifeq ($(TARGET),$(filter $(TARGET), $(F1_TARGETS)))
TARGET_MCU := STM32F1
else
$(error Unknown target MCU specified.)
endif

GROUP_1_TARGETS := ALIENFLIGHTF3 ALIENFLIGHTF4 AIRHEROF3 AIRHEROF3_QUAD COLIBRI_RACE LUX_RACE SPARKY REVO SPARKY2 COLIBRI KISSFC FALCORE FF_F35_LIGHTNING FF_FORTINIF4 FF_PIKOF4 FF_PIKOF4OSD
GROUP_2_TARGETS := SPRACINGF3 SPRACINGF3EVO SPRACINGF3EVO_1SS SPRACINGF3MINI SPRACINGF4EVO CLRACINGF4AIR CLRACINGF4AIRV2 BEEROTORF4 BETAFLIGHTF3 BETAFLIGHTF4 PIKOBLX
GROUP_3_TARGETS := OMNIBUS AIRBOTF4 BLUEJAYF4 OMNIBUSF4 OMNIBUSF4PRO FIREWORKSV2 SPARKY2 MATEKF405 OMNIBUSF7 DYSF4PRO OMNIBUSF4PRO_LEDSTRIPM5 OMNIBUSF7NXT OMNIBUSF7V2 ASGARD32F4
GROUP_4_TARGETS := ANYFC ANYFCF7 ANYFCF7_EXTERNAL_BARO ANYFCM7 ALIENFLIGHTNGF7 PIXRACER YUPIF4 YUPIF4MINI YUPIF4R2 YUPIF7 MATEKF405SE MATEKF411 MATEKF722 MATEKF405OSD MATEKF405_SERVOS6 NOX
GROUP_5_TARGETS := ASGARD32F7 CHEBUZZF3 CLRACINGF4AIRV3 DALRCF405 DALRCF722DUAL DYSF4PROV2 F4BY FISHDRONEF4 FOXEERF405 FOXEERF722DUAL FRSKYF3 FRSKYF4 FURYF3 FURYF3_SPIFLASH FURYF4OSD
GROUP_6_TARGETS := MAMBAF405 OMNIBUSF4V3 OMNIBUSF4V3_S6_SS OMNIBUSF4V3_S5S6_SS OMNIBUSF4V3_S5_S6_2SS AIKONF4
GROUP_7_TARGETS := KAKUTEF4 KAKUTEF4V2 KAKUTEF7 KAKUTEF7MINI KFC32F3_INAV KROOZX MATEKF411_RSSI MATEKF411_SFTSRL2 MATEKF722MINI MATEKF722SE MATEKF722_HEXSERVO
GROUP_8_TARGETS := MATEKF765
GROUP_OTHER_TARGETS := $(filter-out $(GROUP_1_TARGETS) $(GROUP_2_TARGETS) $(GROUP_3_TARGETS) $(GROUP_4_TARGETS) $(GROUP_5_TARGETS) $(GROUP_6_TARGETS) $(GROUP_7_TARGETS) $(GROUP_8_TARGETS), $(VALID_TARGETS))
include $(ROOT)/make/targets.mk

REVISION = $(shell git rev-parse --short HEAD)

Expand All @@ -158,7 +109,8 @@ VPATH := $(VPATH):$(ROOT)/make
CSOURCES := $(shell find $(SRC_DIR) -name '*.c')

# start specific includes
include $(ROOT)/make/mcu/$(TARGET_MCU).mk
include $(ROOT)/make/mcu/STM32.mk
include $(ROOT)/make/mcu/$(TARGET_MCU_GROUP).mk

# Configure default flash sizes for the targets (largest size specified gets hit first) if flash not specified already.
ifeq ($(FLASH_SIZE),)
Expand All @@ -171,7 +123,7 @@ endif

# Configure devide and target-specific defines and compiler flags
DEVICE_FLAGS := $(DEVICE_FLAGS) -DFLASH_SIZE=$(FLASH_SIZE)
TARGET_FLAGS := $(TARGET_FLAGS) -D$(TARGET_MCU) -D$(TARGET)
TARGET_FLAGS := $(TARGET_FLAGS) -D$(TARGET_MCU) -D$(TARGET_MCU_GROUP) -D$(TARGET)

ifneq ($(HSE_VALUE),)
DEVICE_FLAGS := $(DEVICE_FLAGS) -DHSE_VALUE=$(HSE_VALUE)
Expand Down Expand Up @@ -230,13 +182,24 @@ OPTIMIZE = -Os
LTO_FLAGS = -flto -fuse-linker-plugin $(OPTIMIZE)
endif

ifneq ($(SEMIHOSTING),)
SEMIHOSTING_CFLAGS = -DSEMIHOSTING
SEMIHOSTING_LDFLAGS = --specs=rdimon.specs -lc -lrdimon
SYSLIB :=
else
SEMIHOSTING_CFLAGS =
SEMIHOSTING_LDFLAGS =
SYSLIB := -lnosys
endif

DEBUG_FLAGS = -ggdb3 -DDEBUG

CFLAGS += $(ARCH_FLAGS) \
$(LTO_FLAGS) \
$(addprefix -D,$(OPTIONS)) \
$(addprefix -I,$(INCLUDE_DIRS)) \
$(DEBUG_FLAGS) \
$(SEMIHOSTING_CFLAGS) \
-std=gnu99 \
-Wall -Wextra -Wunsafe-loop-optimizations -Wdouble-promotion \
-Wstrict-prototypes \
Expand All @@ -263,10 +226,11 @@ LDFLAGS = -lm \
-nostartfiles \
--specs=nano.specs \
-lc \
-lnosys \
$(SYSLIB) \
$(ARCH_FLAGS) \
$(LTO_FLAGS) \
$(DEBUG_FLAGS) \
$(SEMIHOSTING_LDFLAGS) \
-static \
-Wl,-gc-sections,-Map,$(TARGET_MAP) \
-Wl,-L$(LINKER_DIR) \
Expand Down Expand Up @@ -307,41 +271,16 @@ TARGET_MAP = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET).map

CLEAN_ARTIFACTS := $(TARGET_BIN)
CLEAN_ARTIFACTS += $(TARGET_HEX)
CLEAN_ARTIFACTS += $(TARGET_ELF) $(TARGET_OBJS) $(TARGET_MAP)
CLEAN_ARTIFACTS += $(TARGET_ELF)
CLEAN_ARTIFACTS += $(TARGET_OBJS) $(TARGET_MAP)

include $(ROOT)/make/stamp.mk
include $(ROOT)/make/settings.mk
include $(ROOT)/make/svd.mk

# Make sure build date and revision is updated on every incremental build
$(TARGET_OBJ_DIR)/build/version.o : $(TARGET_SRC)

# Settings generator
.PHONY: .FORCE settings clean-settings
UTILS_DIR = $(ROOT)/src/utils
SETTINGS_GENERATOR = $(UTILS_DIR)/settings.rb
BUILD_STAMP = $(UTILS_DIR)/build_stamp.rb
STAMP = $(TARGET_OBJ_DIR)/build.stamp

GENERATED_SETTINGS = $(TARGET_OBJ_DIR)/settings_generated.h $(TARGET_OBJ_DIR)/settings_generated.c
SETTINGS_FILE = $(SRC_DIR)/fc/settings.yaml
GENERATED_FILES = $(GENERATED_SETTINGS)
$(GENERATED_SETTINGS): $(SETTINGS_GENERATOR) $(SETTINGS_FILE) $(STAMP)

# Make sure the generated files are in the include path
CFLAGS += -I$(TARGET_OBJ_DIR)

$(STAMP): .FORCE
$(V1) CPP_PATH="$(ARM_SDK_DIR)/bin" CFLAGS="$(CFLAGS)" TARGET=$(TARGET) ruby $(BUILD_STAMP) $(SETTINGS_FILE) $(STAMP)

# Use a pattern rule, since they're different than normal rules.
# See https://www.gnu.org/software/make/manual/make.html#Pattern-Examples
%generated.h %generated.c:
$(V1) echo "settings.yaml -> settings_generated.h, settings_generated.c" "$(STDOUT)"
$(V1) CPP_PATH="$(ARM_SDK_DIR)/bin" CFLAGS="$(CFLAGS)" TARGET=$(TARGET) ruby $(SETTINGS_GENERATOR) . $(SETTINGS_FILE) -o $(TARGET_OBJ_DIR)

settings-json:
$(V0) CPP_PATH="$(ARM_SDK_DIR)/bin" CFLAGS="$(CFLAGS)" TARGET=$(TARGET) ruby $(SETTINGS_GENERATOR) . $(SETTINGS_FILE) --json settings.json

clean-settings:
$(V1) $(RM) $(GENERATED_SETTINGS)

# CFLAGS used for ASM generation. These can't include the LTO related options
# since they prevent proper ASM generation. Since $(LTO_FLAGS) includes the
# optization level, we have to add it back. -g is required to make interleaved
Expand All @@ -352,7 +291,7 @@ ASM_CFLAGS=-g $(OPTIMZE) $(filter-out $(LTO_FLAGS) -save-temps=obj, $(CFLAGS))
# It would be nice to compute these lists, but that seems to be just beyond make.

$(TARGET_HEX): $(TARGET_ELF)
$(V0) $(OBJCOPY) -O ihex --set-start 0x8000000 $< $@
$(V0) $(OBJCOPY) -O ihex --set-start $(FLASH_ORIGIN) $< $@

$(TARGET_BIN): $(TARGET_ELF)
$(V0) $(OBJCOPY) -O binary $< $@
Expand Down Expand Up @@ -395,33 +334,6 @@ $(TOOLS_DIR):
## all : Build all valid targets
all: $(VALID_TARGETS)

## targets-group-1 : build some targets
targets-group-1: $(GROUP_1_TARGETS)

## targets-group-2 : build some targets
targets-group-2: $(GROUP_2_TARGETS)

## targets-group-3 : build some targets
targets-group-3: $(GROUP_3_TARGETS)

## targets-group-4 : build some targets
targets-group-4: $(GROUP_4_TARGETS)

## targets-group-5 : build some targets
targets-group-5: $(GROUP_5_TARGETS)

## targets-group-6 : build some targets
targets-group-6: $(GROUP_6_TARGETS)

## targets-group-7 : build some targets
targets-group-7: $(GROUP_7_TARGETS)

## targets-group-8 : build some targets
targets-group-8: $(GROUP_8_TARGETS)

## targets-group-rest: build the rest of the targets (not listed in group 1, 2 or 3)
targets-group-rest: $(GROUP_OTHER_TARGETS)

## targets-group-rest: build targets specified in release-targets list
release: $(RELEASE_TARGETS)

Expand Down Expand Up @@ -469,8 +381,9 @@ $(STFLASH_TARGETS) :

## st-flash : flash firmware (.bin) onto flight controller
st-flash: $(TARGET_BIN)
$(V0) st-flash --reset write $< 0x08000000
$(V0) st-flash --reset write $< $(FLASH_ORIGIN)

elf: $(TARGET_ELF)
binary: $(TARGET_BIN)
hex: $(TARGET_HEX)

Expand Down Expand Up @@ -502,22 +415,6 @@ help: Makefile
$(V0) @echo ""
$(V0) @sed -n 's/^## //p' $<

## targets : print a list of all valid target platforms (for consumption by scripts)
targets:
$(V0) @echo "Valid targets: $(VALID_TARGETS)"
$(V0) @echo "Target: $(TARGET)"
$(V0) @echo "Base target: $(BASE_TARGET)"
$(V0) @echo "targets-group-1: $(GROUP_1_TARGETS)"
$(V0) @echo "targets-group-2: $(GROUP_2_TARGETS)"
$(V0) @echo "targets-group-3: $(GROUP_3_TARGETS)"
$(V0) @echo "targets-group-4: $(GROUP_4_TARGETS)"
$(V0) @echo "targets-group-5: $(GROUP_5_TARGETS)"
$(V0) @echo "targets-group-6: $(GROUP_6_TARGETS)"
$(V0) @echo "targets-group-7: $(GROUP_7_TARGETS)"
$(V0) @echo "targets-group-7: $(GROUP_8_TARGETS)"
$(V0) @echo "targets-group-rest: $(GROUP_OTHER_TARGETS)"
$(V0) @echo "Release targets: $(RELEASE_TARGETS)"

## test : run the cleanflight test suite
test:
$(V0) cd src/test && $(MAKE) test
Expand All @@ -530,3 +427,7 @@ $(TARGET_OBJS) : Makefile | $(GENERATED_FILES) $(STAMP)

# include auto-generated dependencies
-include $(TARGET_DEPS)

# Developer tools
include $(ROOT)/make/openocd.mk
include $(ROOT)/make/gdb.mk
1 change: 0 additions & 1 deletion build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ doc_files=(
'Migrating from baseflight.md'
'Boards.md'
'Board - AlienFlight.md'
'Board - ChebuzzF3.md'
'Board - ColibriRace.md'
'Board - Motolab.md'
'Board - Paris Air Hero 32.md'
Expand Down
Loading

0 comments on commit bcd4cae

Please sign in to comment.