2013-01-02 02:28:09 -04:00
|
|
|
# PX4 build is via external build system
|
|
|
|
|
|
|
|
ifneq ($(PX4_ROOT),)
|
|
|
|
|
2013-08-30 00:32:23 -03:00
|
|
|
# cope with relative paths
|
2013-08-02 01:12:24 -03:00
|
|
|
ifeq ($(wildcard $(PX4_ROOT)/nuttx-configs),)
|
2013-05-22 09:57:24 -03:00
|
|
|
PX4_ROOT := $(shell cd $(SKETCHBOOK)/$(PX4_ROOT) && pwd)
|
|
|
|
endif
|
2013-08-30 00:32:23 -03:00
|
|
|
|
|
|
|
# check it is a valid PX4Firmware tree
|
2013-08-02 01:12:24 -03:00
|
|
|
ifeq ($(wildcard $(PX4_ROOT)/nuttx-configs),)
|
|
|
|
$(error ERROR: PX4_ROOT not set correctly - no nuttx-configs directory found)
|
|
|
|
endif
|
|
|
|
|
2013-08-30 00:32:23 -03:00
|
|
|
# default to PX4NuttX above the PX4Firmware tree
|
|
|
|
ifeq ($(NUTTX_SRC),)
|
|
|
|
NUTTX_SRC := $(shell cd $(PX4_ROOT)/../PX4NuttX/nuttx && pwd)/
|
|
|
|
endif
|
|
|
|
|
|
|
|
# cope with relative paths for NUTTX_SRC
|
|
|
|
ifeq ($(wildcard $(NUTTX_SRC)/configs),)
|
|
|
|
NUTTX_SRC := $(shell cd $(SKETCHBOOK)/$(NUTTX_SRC) && pwd)/
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(wildcard $(NUTTX_SRC)configs),)
|
|
|
|
$(error ERROR: NUTTX_SRC not set correctly - no configs directory found)
|
2013-05-22 09:57:24 -03:00
|
|
|
endif
|
|
|
|
|
2014-01-14 00:35:41 -04:00
|
|
|
NUTTX_GIT_VERSION := $(shell cd $(NUTTX_SRC) && git rev-parse HEAD | cut -c1-8)
|
|
|
|
PX4_GIT_VERSION := $(shell cd $(PX4_ROOT) && git rev-parse HEAD | cut -c1-8)
|
|
|
|
|
|
|
|
EXTRAFLAGS += -DNUTTX_GIT_VERSION="\"$(NUTTX_GIT_VERSION)\""
|
|
|
|
EXTRAFLAGS += -DPX4_GIT_VERSION="\"$(PX4_GIT_VERSION)\""
|
|
|
|
|
2013-07-24 01:59:08 -03:00
|
|
|
# we have different config files for V1 and V2
|
|
|
|
PX4_V1_CONFIG_FILE=$(MK_DIR)/PX4/config_px4fmu-v1_APM.mk
|
|
|
|
PX4_V2_CONFIG_FILE=$(MK_DIR)/PX4/config_px4fmu-v2_APM.mk
|
|
|
|
|
2014-10-29 18:09:08 -03:00
|
|
|
SKETCHFLAGS=$(SKETCHLIBINCLUDES) -I$(PWD) -DARDUPILOT_BUILD -DTESTS_MATHLIB_DISABLE -DCONFIG_HAL_BOARD=HAL_BOARD_PX4 -DSKETCHNAME="\\\"$(SKETCH)\\\"" -DSKETCH_MAIN=ArduPilot_main -DAPM_BUILD_DIRECTORY=APM_BUILD_$(SKETCH)
|
2013-07-24 01:59:08 -03:00
|
|
|
|
2014-07-08 07:27:54 -03:00
|
|
|
WARNFLAGS = -Wno-psabi -Wno-packed -Wno-error=double-promotion -Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=reorder
|
2013-12-10 18:59:41 -04:00
|
|
|
|
2014-07-08 19:12:10 -03:00
|
|
|
# avoid PX4 submodules
|
|
|
|
export GIT_SUBMODULES_ARE_EVIL = 1
|
|
|
|
|
|
|
|
PX4_MAKE = $(v) GIT_SUBMODULES_ARE_EVIL=1 make -C $(SKETCHBOOK) -f $(PX4_ROOT)/Makefile EXTRADEFINES="$(SKETCHFLAGS) $(WARNFLAGS) "'$(EXTRAFLAGS)' APM_MODULE_DIR=$(SKETCHBOOK) SKETCHBOOK=$(SKETCHBOOK) PX4_ROOT=$(PX4_ROOT) NUTTX_SRC=$(NUTTX_SRC) MAXOPTIMIZATION="-Os"
|
|
|
|
PX4_MAKE_ARCHIVES = make -C $(PX4_ROOT) NUTTX_SRC=$(NUTTX_SRC) archives MAXOPTIMIZATION="-Os"
|
2013-01-20 17:22:02 -04:00
|
|
|
|
2013-08-26 23:20:45 -03:00
|
|
|
.PHONY: module_mk
|
|
|
|
module_mk:
|
2013-05-04 05:47:08 -03:00
|
|
|
$(RULEHDR)
|
2013-12-10 18:59:41 -04:00
|
|
|
$(v) echo "# Auto-generated file - do not edit" > $(SKETCHBOOK)/module.mk.new
|
|
|
|
$(v) echo "MODULE_COMMAND = ArduPilot" >> $(SKETCHBOOK)/module.mk.new
|
|
|
|
$(v) echo "SRCS = Build.$(SKETCH)/$(SKETCH).cpp $(SKETCHLIBSRCSRELATIVE)" >> $(SKETCHBOOK)/module.mk.new
|
|
|
|
$(v) echo "MODULE_STACKSIZE = 4096" >> $(SKETCHBOOK)/module.mk.new
|
|
|
|
$(v) cmp $(SKETCHBOOK)/module.mk $(SKETCHBOOK)/module.mk.new 2>/dev/null || mv $(SKETCHBOOK)/module.mk.new $(SKETCHBOOK)/module.mk
|
|
|
|
$(v) rm -f $(SKETCHBOOK)/module.mk.new
|
2013-05-04 05:47:08 -03:00
|
|
|
|
2014-07-31 17:54:03 -03:00
|
|
|
px4-v1: $(BUILDROOT)/make.flags $(PX4_ROOT)/Archives/px4fmu-v1.export $(SKETCHCPP) module_mk px4-io-v1
|
2013-07-24 01:59:08 -03:00
|
|
|
$(RULEHDR)
|
2013-08-12 21:10:42 -03:00
|
|
|
$(v) rm -f $(PX4_ROOT)/makefiles/$(PX4_V1_CONFIG_FILE)
|
|
|
|
$(v) cp $(PWD)/$(PX4_V1_CONFIG_FILE) $(PX4_ROOT)/makefiles/
|
2013-07-30 22:43:24 -03:00
|
|
|
$(v) $(PX4_MAKE) px4fmu-v1_APM
|
2013-07-24 01:59:08 -03:00
|
|
|
$(v) /bin/rm -f $(SKETCH)-v1.px4
|
2013-07-30 22:43:24 -03:00
|
|
|
$(v) cp $(PX4_ROOT)/Images/px4fmu-v1_APM.px4 $(SKETCH)-v1.px4
|
2013-07-24 01:59:08 -03:00
|
|
|
$(v) echo "PX4 $(SKETCH) Firmware is in $(SKETCH)-v1.px4"
|
|
|
|
|
2014-07-31 17:54:03 -03:00
|
|
|
px4-v2: $(BUILDROOT)/make.flags $(PX4_ROOT)/Archives/px4fmu-v2.export $(SKETCHCPP) module_mk px4-io-v2
|
2013-05-04 05:47:08 -03:00
|
|
|
$(RULEHDR)
|
2013-08-12 21:10:42 -03:00
|
|
|
$(v) rm -f $(PX4_ROOT)/makefiles/$(PX4_V2_CONFIG_FILE)
|
|
|
|
$(v) cp $(PWD)/$(PX4_V2_CONFIG_FILE) $(PX4_ROOT)/makefiles/
|
|
|
|
$(PX4_MAKE) px4fmu-v2_APM
|
2013-07-24 01:59:08 -03:00
|
|
|
$(v) /bin/rm -f $(SKETCH)-v2.px4
|
2013-07-30 22:43:24 -03:00
|
|
|
$(v) cp $(PX4_ROOT)/Images/px4fmu-v2_APM.px4 $(SKETCH)-v2.px4
|
2013-07-24 01:59:08 -03:00
|
|
|
$(v) echo "PX4 $(SKETCH) Firmware is in $(SKETCH)-v2.px4"
|
|
|
|
|
|
|
|
px4: px4-v1 px4-v2
|
2013-05-04 05:47:08 -03:00
|
|
|
|
|
|
|
px4-clean: clean px4-archives-clean
|
|
|
|
$(v) /bin/rm -rf $(PX4_ROOT)/makefiles/build $(PX4_ROOT)/Build
|
|
|
|
|
2014-01-22 01:35:12 -04:00
|
|
|
px4-cleandep: clean
|
|
|
|
$(v) find $(PX4_ROOT)/Build -type f -name '*.d' | xargs rm -f
|
|
|
|
|
2013-08-06 02:37:41 -03:00
|
|
|
px4-v1-upload: px4-v1
|
2013-05-04 05:47:08 -03:00
|
|
|
$(RULEHDR)
|
2013-07-31 05:58:04 -03:00
|
|
|
$(v) $(PX4_MAKE) px4fmu-v1_APM upload
|
2013-07-24 01:59:08 -03:00
|
|
|
|
2013-08-06 02:37:41 -03:00
|
|
|
px4-v2-upload: px4-v2
|
2013-07-31 05:58:04 -03:00
|
|
|
$(RULEHDR)
|
|
|
|
$(v) $(PX4_MAKE) px4fmu-v2_APM upload
|
2013-07-24 01:59:08 -03:00
|
|
|
|
2013-07-31 05:58:04 -03:00
|
|
|
px4-upload: px4-v1-upload
|
2013-05-04 02:10:20 -03:00
|
|
|
|
2013-05-04 05:47:08 -03:00
|
|
|
px4-archives-clean:
|
2013-05-04 19:10:54 -03:00
|
|
|
$(v) /bin/rm -rf $(PX4_ROOT)/Archives
|
2013-01-02 02:28:09 -04:00
|
|
|
|
2013-07-24 03:31:13 -03:00
|
|
|
px4-io-v1: $(PX4_ROOT)/Archives/px4io-v1.export
|
2013-07-20 18:41:19 -03:00
|
|
|
$(v) make -C $(PX4_ROOT) px4io-v1_default
|
|
|
|
$(v) /bin/rm -f px4io-v1.bin
|
2013-07-31 05:58:04 -03:00
|
|
|
$(v) cp $(PX4_ROOT)/Images/px4io-v1_default.bin px4io-v1.bin
|
2013-12-27 19:09:40 -04:00
|
|
|
$(v) cp $(PX4_ROOT)/Build/px4io-v1_default.build/firmware.elf px4io-v1.elf
|
2013-07-31 05:58:04 -03:00
|
|
|
$(v) mkdir -p $(MK_DIR)/PX4/ROMFS/px4io/
|
|
|
|
$(v) rm -f $(MK_DIR)/PX4/ROMFS/px4io/px4io.bin
|
|
|
|
$(v) cp px4io-v1.bin $(MK_DIR)/PX4/ROMFS/px4io/px4io.bin
|
2013-09-04 00:15:51 -03:00
|
|
|
$(v) mkdir -p $(MK_DIR)/PX4/ROMFS/bootloader/
|
|
|
|
$(v) rm -f $(MK_DIR)/PX4/ROMFS/bootloader/fmu_bl.bin
|
|
|
|
$(v) cp $(SKETCHBOOK)/mk/PX4/bootloader/px4fmu_bl.bin $(MK_DIR)/PX4/ROMFS/bootloader/fmu_bl.bin
|
2013-07-20 18:41:19 -03:00
|
|
|
$(v) echo "PX4IOv1 Firmware is in px4io-v1.bin"
|
2013-05-04 02:10:20 -03:00
|
|
|
|
2013-07-25 22:12:14 -03:00
|
|
|
|
2013-07-24 03:31:13 -03:00
|
|
|
px4-io-v2: $(PX4_ROOT)/Archives/px4io-v2.export
|
|
|
|
$(v) make -C $(PX4_ROOT) px4io-v2_default
|
2013-12-29 23:51:40 -04:00
|
|
|
$(v) /bin/rm -f px4io-v2.bin
|
2013-07-24 03:31:13 -03:00
|
|
|
$(v) cp $(PX4_ROOT)/Build/px4io-v2_default.build/firmware.bin px4io-v2.bin
|
2013-07-31 05:58:04 -03:00
|
|
|
$(v) cp $(PX4_ROOT)/Images/px4io-v2_default.bin px4io-v2.bin
|
2013-12-27 19:09:40 -04:00
|
|
|
$(v) cp $(PX4_ROOT)/Build/px4io-v2_default.build/firmware.elf px4io-v2.elf
|
2013-07-31 05:58:04 -03:00
|
|
|
$(v) mkdir -p $(MK_DIR)/PX4/ROMFS/px4io/
|
|
|
|
$(v) rm -f $(MK_DIR)/PX4/ROMFS/px4io/px4io.bin
|
|
|
|
$(v) cp px4io-v2.bin $(MK_DIR)/PX4/ROMFS/px4io/px4io.bin
|
2013-09-04 00:15:51 -03:00
|
|
|
$(v) mkdir -p $(MK_DIR)/PX4/ROMFS/bootloader/
|
|
|
|
$(v) rm -f $(MK_DIR)/PX4/ROMFS/bootloader/fmu_bl.bin
|
|
|
|
$(v) cp $(SKETCHBOOK)/mk/PX4/bootloader/px4fmuv2_bl.bin $(MK_DIR)/PX4/ROMFS/bootloader/fmu_bl.bin
|
2013-07-24 03:31:13 -03:00
|
|
|
$(v) echo "PX4IOv2 Firmware is in px4io-v2.bin"
|
|
|
|
|
|
|
|
px4-io: px4-io-v1 px4-io-v2
|
|
|
|
|
2013-01-02 02:28:09 -04:00
|
|
|
|
2013-08-12 22:23:50 -03:00
|
|
|
$(PX4_ROOT)/Archives/px4fmu-v1.export:
|
|
|
|
$(v) $(PX4_MAKE_ARCHIVES)
|
2013-07-24 01:59:08 -03:00
|
|
|
|
2013-08-12 22:23:50 -03:00
|
|
|
$(PX4_ROOT)/Archives/px4fmu-v2.export:
|
|
|
|
$(v) $(PX4_MAKE_ARCHIVES)
|
2013-01-02 02:28:09 -04:00
|
|
|
|
2013-08-12 22:23:50 -03:00
|
|
|
$(PX4_ROOT)/Archives/px4io-v1.export:
|
|
|
|
$(v) $(PX4_MAKE_ARCHIVES)
|
|
|
|
|
|
|
|
$(PX4_ROOT)/Archives/px4io-v2.export:
|
|
|
|
$(v) $(PX4_MAKE_ARCHIVES)
|
2013-07-24 01:59:08 -03:00
|
|
|
|
2013-07-25 22:12:14 -03:00
|
|
|
px4-archives:
|
2013-08-12 22:23:50 -03:00
|
|
|
$(v) $(PX4_MAKE_ARCHIVES)
|
2013-05-04 19:10:54 -03:00
|
|
|
|
2013-01-02 02:32:28 -04:00
|
|
|
else
|
|
|
|
|
|
|
|
px4:
|
|
|
|
$(error ERROR: You need to add PX4_ROOT to your config.mk)
|
|
|
|
|
2013-01-20 17:22:02 -04:00
|
|
|
px4-clean: px4
|
|
|
|
|
|
|
|
px4-upload: px4
|
|
|
|
|
2013-01-02 02:28:09 -04:00
|
|
|
endif
|