mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 03:49:12 +08:00
Merge branch 'master' of github.com:PX4/Firmware
This commit is contained in:
@@ -159,11 +159,11 @@ $(NUTTX_ARCHIVES): $(ARCHIVE_DIR)%.export: $(NUTTX_SRC) $(NUTTX_APPS)
|
|||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
$(Q) $(RMDIR) $(BUILD_DIR)*.build
|
$(Q) $(RMDIR) $(BUILD_DIR)*.build
|
||||||
$(Q) $(REMOVE) -f $(IMAGE_DIR)*.px4
|
$(Q) $(REMOVE) $(IMAGE_DIR)*.px4
|
||||||
|
|
||||||
.PHONY: distclean
|
.PHONY: distclean
|
||||||
distclean: clean
|
distclean: clean
|
||||||
$(Q) $(REMOVE) -f $(ARCHIVE_DIR)*.export
|
$(Q) $(REMOVE) $(ARCHIVE_DIR)*.export
|
||||||
$(Q) make -C $(NUTTX_SRC) -r $(MQUIET) distclean
|
$(Q) make -C $(NUTTX_SRC) -r $(MQUIET) distclean
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -196,6 +196,11 @@ help:
|
|||||||
@echo " distclean"
|
@echo " distclean"
|
||||||
@echo " Remove all compilation products, including NuttX RTOS archives."
|
@echo " Remove all compilation products, including NuttX RTOS archives."
|
||||||
@echo ""
|
@echo ""
|
||||||
|
@echo " upload"
|
||||||
|
@echo " When exactly one config is being built, add this target to upload the"
|
||||||
|
@echo " firmware to the board when the build is complete. Not supported for"
|
||||||
|
@echo " all configurations."
|
||||||
|
@echo ""
|
||||||
@echo " Common options:"
|
@echo " Common options:"
|
||||||
@echo " ---------------"
|
@echo " ---------------"
|
||||||
@echo ""
|
@echo ""
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
PX4 Build System
|
||||||
|
================
|
||||||
|
|
||||||
|
The files in this directory implement the PX4 runtime firmware build system
|
||||||
|
and configuration for the standard PX4 boards and software, in conjunction
|
||||||
|
with Makefile in the parent directory.
|
||||||
|
|
||||||
|
../Makefile
|
||||||
|
|
||||||
|
Top-level makefile for the PX4 build system. This makefile supports
|
||||||
|
building NuttX archives, as well as supervising the building of all
|
||||||
|
of the defined PX4 firmware configurations.
|
||||||
|
|
||||||
|
Try 'make help' in the parent directory for documentation.
|
||||||
|
|
||||||
|
firmware.mk
|
||||||
|
|
||||||
|
Manages the build for one specific firmware configuration.
|
||||||
|
See the comments at the top of this file for detailed documentation.
|
||||||
|
|
||||||
|
Builds modules, builtin command lists and the ROMFS (if configured).
|
||||||
|
|
||||||
|
This is the makefile directly used by external build systems; it can
|
||||||
|
be configured to compile modules both inside and outside the PX4
|
||||||
|
source tree. When used in this mode, at least BOARD, MODULES and
|
||||||
|
CONFIG_FILE must be set.
|
||||||
|
|
||||||
|
module.mk
|
||||||
|
|
||||||
|
Called by firmware.mk to build individual modules.
|
||||||
|
See the comments at the top of this file for detailed documentation.
|
||||||
|
|
||||||
|
Not normally used other than by firmware.mk.
|
||||||
|
|
||||||
|
nuttx.mk
|
||||||
|
|
||||||
|
Called by ../Makefile to build or download the NuttX archives.
|
||||||
|
|
||||||
|
upload.mk
|
||||||
|
|
||||||
|
Called by ../Makefile to upload files to a target board. Can be used
|
||||||
|
by external build systems as well.
|
||||||
|
|
||||||
|
setup.mk
|
||||||
|
|
||||||
|
Provides common path and tool definitions. Implements host system-specific
|
||||||
|
compatibility hacks.
|
||||||
|
|
||||||
|
board_<boardname>.mk
|
||||||
|
|
||||||
|
Board-specific configuration for <boardname>. Typically sets CONFIG_ARCH
|
||||||
|
and then includes the toolchain definition for the board.
|
||||||
|
|
||||||
|
config_<boardname>_<configname>.mk
|
||||||
|
|
||||||
|
Parameters for a specific configuration on a specific board.
|
||||||
|
The board name is derived from the filename. Sets MODULES to select
|
||||||
|
source modules to be included in the configuration, may also set
|
||||||
|
ROMFS_ROOT to build a ROMFS and BUILTIN_COMMANDS to include non-module
|
||||||
|
commands (e.g. from NuttX)
|
||||||
|
|
||||||
|
toolchain_<toolchainname>.mk
|
||||||
|
|
||||||
|
Provides macros used to compile and link source files.
|
||||||
|
Accepts EXTRADEFINES to add additional pre-processor symbol definitions,
|
||||||
|
EXTRACFLAGS, EXTRACXXFLAGS, EXTRAAFLAGS and EXTRALDFLAGS to pass
|
||||||
|
additional flags to the C compiler, C++ compiler, assembler and linker
|
||||||
|
respectively.
|
||||||
|
|
||||||
|
Defines the COMPILE, COMPILEXX, ASSEMBLE, PRELINK, ARCHIVE and LINK
|
||||||
|
macros that are used elsewhere in the build system.
|
||||||
+17
-10
@@ -223,12 +223,15 @@ MODULE_OBJS := $(foreach path,$(dir $(MODULE_MKFILES)),$(WORK_DIR)$(path)module
|
|||||||
.PHONY: $(MODULE_OBJS)
|
.PHONY: $(MODULE_OBJS)
|
||||||
$(MODULE_OBJS): relpath = $(patsubst $(WORK_DIR)%,%,$@)
|
$(MODULE_OBJS): relpath = $(patsubst $(WORK_DIR)%,%,$@)
|
||||||
$(MODULE_OBJS): mkfile = $(patsubst %module.pre.o,%module.mk,$(relpath))
|
$(MODULE_OBJS): mkfile = $(patsubst %module.pre.o,%module.mk,$(relpath))
|
||||||
|
$(MODULE_OBJS): workdir = $(@D)
|
||||||
$(MODULE_OBJS): $(GLOBAL_DEPS) $(NUTTX_CONFIG_HEADER)
|
$(MODULE_OBJS): $(GLOBAL_DEPS) $(NUTTX_CONFIG_HEADER)
|
||||||
|
$(Q) $(MKDIR) -p $(workdir)
|
||||||
$(Q) $(MAKE) -r -f $(PX4_MK_DIR)module.mk \
|
$(Q) $(MAKE) -r -f $(PX4_MK_DIR)module.mk \
|
||||||
MODULE_WORK_DIR=$(dir $@) \
|
-C $(workdir) \
|
||||||
|
MODULE_WORK_DIR=$(workdir) \
|
||||||
MODULE_OBJ=$@ \
|
MODULE_OBJ=$@ \
|
||||||
MODULE_MK=$(mkfile) \
|
MODULE_MK=$(mkfile) \
|
||||||
MODULE_NAME=$(lastword $(subst /, ,$(@D))) \
|
MODULE_NAME=$(lastword $(subst /, ,$(workdir))) \
|
||||||
module
|
module
|
||||||
|
|
||||||
# make a list of phony clean targets for modules
|
# make a list of phony clean targets for modules
|
||||||
@@ -266,14 +269,18 @@ endif
|
|||||||
#
|
#
|
||||||
|
|
||||||
# Add dependencies on anything in the ROMFS root
|
# Add dependencies on anything in the ROMFS root
|
||||||
ROMFS_DEPS += $(wildcard \
|
ROMFS_FILES += $(wildcard \
|
||||||
(ROMFS_ROOT)/* \
|
$(ROMFS_ROOT)/* \
|
||||||
(ROMFS_ROOT)/*/* \
|
$(ROMFS_ROOT)/*/* \
|
||||||
(ROMFS_ROOT)/*/*/* \
|
$(ROMFS_ROOT)/*/*/* \
|
||||||
(ROMFS_ROOT)/*/*/*/* \
|
$(ROMFS_ROOT)/*/*/*/* \
|
||||||
(ROMFS_ROOT)/*/*/*/*/* \
|
$(ROMFS_ROOT)/*/*/*/*/* \
|
||||||
(ROMFS_ROOT)/*/*/*/*/*/*)
|
$(ROMFS_ROOT)/*/*/*/*/*/*)
|
||||||
ROMFS_IMG = $(WORK_DIR)romfs.img
|
ifeq ($(ROMFS_FILES),)
|
||||||
|
$(error ROMFS_ROOT $(ROMFS_ROOT) specifies a directory containing no files)
|
||||||
|
endif
|
||||||
|
ROMFS_DEPS += $(ROMFS_FILES)
|
||||||
|
ROMFS_IMG = romfs.img
|
||||||
ROMFS_CSRC = $(ROMFS_IMG:.img=.c)
|
ROMFS_CSRC = $(ROMFS_IMG:.img=.c)
|
||||||
ROMFS_OBJ = $(ROMFS_CSRC:.c=.o)
|
ROMFS_OBJ = $(ROMFS_CSRC:.c=.o)
|
||||||
LIBS += $(ROMFS_OBJ)
|
LIBS += $(ROMFS_OBJ)
|
||||||
|
|||||||
+31
-20
@@ -39,6 +39,10 @@
|
|||||||
# symbols, as the global namespace is shared between all modules. Normally an
|
# symbols, as the global namespace is shared between all modules. Normally an
|
||||||
# module will just export one or more <command>_main functions.
|
# module will just export one or more <command>_main functions.
|
||||||
#
|
#
|
||||||
|
# IMPORTANT NOTE:
|
||||||
|
#
|
||||||
|
# This makefile assumes it is being invoked in the module's output directory.
|
||||||
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
# Variables that can be set by the module's module.mk:
|
# Variables that can be set by the module's module.mk:
|
||||||
@@ -179,26 +183,30 @@ CXXFLAGS += -fvisibility=$(DEFAULT_VISIBILITY) -include $(PX4_INCLUDE_DIR)visibi
|
|||||||
#
|
#
|
||||||
module: $(MODULE_OBJ) $(MODULE_COMMAND_FILES)
|
module: $(MODULE_OBJ) $(MODULE_COMMAND_FILES)
|
||||||
|
|
||||||
|
##
|
||||||
|
## Locate sources (allows relative source paths in module.mk)
|
||||||
|
##
|
||||||
|
#define SRC_SEARCH
|
||||||
|
# $(abspath $(firstword $(wildcard $1) $(wildcard $(MODULE_SRC)/$1) MISSING_$1))
|
||||||
|
#endef
|
||||||
#
|
#
|
||||||
# Locate sources (allows relative source paths in module.mk)
|
#ABS_SRCS ?= $(foreach src,$(SRCS),$(call SRC_SEARCH,$(src)))
|
||||||
|
#MISSING_SRCS := $(subst MISSING_,,$(filter MISSING_%,$(ABS_SRCS)))
|
||||||
|
#ifneq ($(MISSING_SRCS),)
|
||||||
|
#$(error $(MODULE_MK): missing in SRCS: $(MISSING_SRCS))
|
||||||
|
#endif
|
||||||
|
#ifeq ($(ABS_SRCS),)
|
||||||
|
#$(error $(MODULE_MK): nothing to compile in SRCS)
|
||||||
|
#endif
|
||||||
#
|
#
|
||||||
define SRC_SEARCH
|
##
|
||||||
$(abspath $(firstword $(wildcard $1) $(wildcard $(MODULE_SRC)/$1) MISSING_$1))
|
## Object files we will generate from sources
|
||||||
endef
|
##
|
||||||
|
#OBJS := $(foreach src,$(ABS_SRCS),$(MODULE_WORK_DIR)$(src).o)
|
||||||
|
|
||||||
ABS_SRCS ?= $(foreach src,$(SRCS),$(call SRC_SEARCH,$(src)))
|
OBJS = $(addsuffix .o,$(SRCS))
|
||||||
MISSING_SRCS := $(subst MISSING_,,$(filter MISSING_%,$(ABS_SRCS)))
|
$(info SRCS $(SRCS))
|
||||||
ifneq ($(MISSING_SRCS),)
|
$(info OBJS $(OBJS))
|
||||||
$(error $(MODULE_MK): missing in SRCS: $(MISSING_SRCS))
|
|
||||||
endif
|
|
||||||
ifeq ($(ABS_SRCS),)
|
|
||||||
$(error $(MODULE_MK): nothing to compile in SRCS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
#
|
|
||||||
# Object files we will generate from sources
|
|
||||||
#
|
|
||||||
OBJS := $(foreach src,$(ABS_SRCS),$(MODULE_WORK_DIR)$(src).o)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# SRCS -> OBJS rules
|
# SRCS -> OBJS rules
|
||||||
@@ -206,13 +214,16 @@ OBJS := $(foreach src,$(ABS_SRCS),$(MODULE_WORK_DIR)$(src).o)
|
|||||||
|
|
||||||
$(OBJS): $(GLOBAL_DEPS)
|
$(OBJS): $(GLOBAL_DEPS)
|
||||||
|
|
||||||
$(filter %.c.o,$(OBJS)): $(MODULE_WORK_DIR)%.c.o: %.c $(GLOBAL_DEPS)
|
vpath %.c $(MODULE_SRC)
|
||||||
|
$(filter %.c.o,$(OBJS)): %.c.o: %.c $(GLOBAL_DEPS)
|
||||||
$(call COMPILE,$<,$@)
|
$(call COMPILE,$<,$@)
|
||||||
|
|
||||||
$(filter %.cpp.o,$(OBJS)): $(MODULE_WORK_DIR)%.cpp.o: %.cpp $(GLOBAL_DEPS)
|
vpath %.cpp $(MODULE_SRC)
|
||||||
|
$(filter %.cpp.o,$(OBJS)): %.cpp.o: %.cpp $(GLOBAL_DEPS)
|
||||||
$(call COMPILEXX,$<,$@)
|
$(call COMPILEXX,$<,$@)
|
||||||
|
|
||||||
$(filter %.S.o,$(OBJS)): $(MODULE_WORK_DIR)%.S.o: %.S $(GLOBAL_DEPS)
|
vpath %.S $(MODULE_SRC)
|
||||||
|
$(filter %.S.o,$(OBJS)): %.S.o: %.S $(GLOBAL_DEPS)
|
||||||
$(call ASSEMBLE,$<,$@)
|
$(call ASSEMBLE,$<,$@)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -254,6 +254,20 @@ endef
|
|||||||
# - relink the object and insert the binary file
|
# - relink the object and insert the binary file
|
||||||
# - edit symbol names to suit
|
# - edit symbol names to suit
|
||||||
#
|
#
|
||||||
|
# NOTE: exercise caution using this with absolute pathnames; it looks
|
||||||
|
# like the MinGW tools insert an extra _ in the binary symbol name; e.g.
|
||||||
|
# the path:
|
||||||
|
#
|
||||||
|
# /d/px4/firmware/Build/px4fmu_default.build/romfs.img
|
||||||
|
#
|
||||||
|
# is assigned symbols like:
|
||||||
|
#
|
||||||
|
# _binary_d__px4_firmware_Build_px4fmu_default_build_romfs_img_size
|
||||||
|
#
|
||||||
|
# when we would expect
|
||||||
|
#
|
||||||
|
# _binary__d_px4_firmware_Build_px4fmu_default_build_romfs_img_size
|
||||||
|
#
|
||||||
define BIN_SYM_PREFIX
|
define BIN_SYM_PREFIX
|
||||||
_binary_$(subst /,_,$(subst .,_,$1))
|
_binary_$(subst /,_,$(subst .,_,$1))
|
||||||
endef
|
endef
|
||||||
@@ -267,4 +281,5 @@ define BIN_TO_OBJ
|
|||||||
--redefine-sym $(call BIN_SYM_PREFIX,$1)_start=$3 \
|
--redefine-sym $(call BIN_SYM_PREFIX,$1)_start=$3 \
|
||||||
--redefine-sym $(call BIN_SYM_PREFIX,$1)_size=$3_len \
|
--redefine-sym $(call BIN_SYM_PREFIX,$1)_size=$3_len \
|
||||||
--strip-symbol $(call BIN_SYM_PREFIX,$1)_end
|
--strip-symbol $(call BIN_SYM_PREFIX,$1)_end
|
||||||
|
$(Q) $(REMOVE) $2.c $2.c.o
|
||||||
endef
|
endef
|
||||||
|
|||||||
@@ -38,8 +38,9 @@
|
|||||||
#
|
#
|
||||||
# Find sources
|
# Find sources
|
||||||
#
|
#
|
||||||
DSPLIB_SRCDIR := $(PX4_MODULE_SRC)/modules/mathlib/CMSIS
|
DSPLIB_SRCDIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||||
ABS_SRCS := $(wildcard $(DSPLIB_SRCDIR)/DSP_Lib/Source/*/*.c)
|
SRCLIST := $(wildcard $(DSPLIB_SRCDIR)DSP_Lib/Source/*/*.c)
|
||||||
|
SRCS := $(patsubst $(DSPLIB_SRCDIR)%,%,$(SRCLIST))
|
||||||
|
|
||||||
INCLUDE_DIRS += $(DSPLIB_SRCDIR)/Include \
|
INCLUDE_DIRS += $(DSPLIB_SRCDIR)/Include \
|
||||||
$(DSPLIB_SRCDIR)/Device/ARM/ARMCM4/Include \
|
$(DSPLIB_SRCDIR)/Device/ARM/ARMCM4/Include \
|
||||||
|
|||||||
Reference in New Issue
Block a user