mk: update build for FMUv4 from master

This commit is contained in:
Andrew Tridgell 2016-02-08 19:29:23 +11:00
parent 9ef6d9bee9
commit adc578edbe
25 changed files with 657 additions and 120 deletions

111
mk/PX4/ROMFS/init.d/rc.APM Normal file → Executable file
View File

@ -56,13 +56,19 @@ then
echo "Created APM directory" echo "Created APM directory"
fi fi
if [ -f /bin/lsm303d ] if [ -f /bin/px4io ]
then then
if [ -f /bin/lsm303d ]
then
echo "Detected FMUv2 board" echo "Detected FMUv2 board"
set BOARD FMUv2 set BOARD FMUv2
else else
echo "Detected FMUv1 board" echo "Detected FMUv1 board"
set BOARD FMUv1 set BOARD FMUv1
fi
else
echo "Detected FMUv4 board"
set BOARD FMUv4
fi fi
if [ $BOARD == FMUv1 ] if [ $BOARD == FMUv1 ]
@ -108,16 +114,17 @@ then
mkblctrl -mkmode x -d /dev/pwm_output mkblctrl -mkmode x -d /dev/pwm_output
fi fi
if [ -f /bin/px4io ]
echo "Trying PX4IO board"
# try the px4io start twice. Some FMUv2 board don't
# come up the first time
set HAVE_PX4IO false
if px4io start norc
then then
echo "Trying PX4IO board"
# try the px4io start twice. Some FMUv2 board don't
# come up the first time
set HAVE_PX4IO false
if px4io start norc
then
set HAVE_PX4IO true set HAVE_PX4IO true
else else
# it may be in bootloader mode # it may be in bootloader mode
echo Loading /etc/px4io/px4io.bin echo Loading /etc/px4io/px4io.bin
tone_alarm MBABGP tone_alarm MBABGP
@ -136,6 +143,10 @@ else
# play happy tune again # play happy tune again
tone_alarm 1 tone_alarm 1
fi fi
fi
else
set HAVE_PX4IO false
echo "No PX4IO support"
fi fi
if [ $HAVE_PX4IO == true ] if [ $HAVE_PX4IO == true ]
@ -222,13 +233,17 @@ fi
if [ $BOARD == FMUv1 ] if [ $BOARD == FMUv1 ]
then then
echo "Starting FMUv1 sensors" echo "Starting FMUv1 sensors"
if hmc5883 -C -T start if hmc5883 -C -T -X start
then then
echo "hmc5883 started OK" echo "Have external hmc5883"
else else
echo "hmc5883 start failed" echo "No external hmc5883"
echo "hmc5883 start failed" >> $logfile fi
sh /etc/init.d/rc.error if hmc5883 -C -T -I start
then
echo "Have internal hmc5883"
else
echo "No internal hmc5883"
fi fi
if mpu6000 start if mpu6000 start
then then
@ -243,7 +258,10 @@ then
echo "No l3gd20" echo "No l3gd20"
echo "No l3gd20" >> $logfile echo "No l3gd20" >> $logfile
fi fi
else fi
if [ $BOARD == FMUv2 ]
then
echo "Starting FMUv2 sensors" echo "Starting FMUv2 sensors"
if hmc5883 -C -T -X start if hmc5883 -C -T -X start
then then
@ -337,6 +355,34 @@ else
fi fi
fi fi
if [ $BOARD == FMUv4 ]
then
echo "Starting FMUv4 sensors"
if hmc5883 -C -T -X start
then
echo "Have external hmc5883"
else
echo "No external hmc5883"
fi
if hmc5883 -C -T -S -R 2 start
then
echo "Have SPI hmc5883"
else
echo "No SPI hmc5883"
fi
if mpu6000 -R 2 -T 20608 start
then
echo "Found ICM-20608 internal"
fi
if mpu9250 -R 2 start
then
echo "Found mpu9250 internal"
fi
fi
# optional ETS airspeed sensor # optional ETS airspeed sensor
if ets_airspeed start if ets_airspeed start
then then
@ -346,6 +392,11 @@ fi
if meas_airspeed start if meas_airspeed start
then then
echo "Found MEAS airspeed sensor" echo "Found MEAS airspeed sensor"
else
if meas_airspeed start -b 2
then
echo "Found MEAS airspeed sensor (bus2)"
fi
fi fi
# optional Range Finder sensor # optional Range Finder sensor
@ -370,9 +421,12 @@ then
fi fi
# optional PX4Flow sensor # optional PX4Flow sensor
if px4flow start if [ -f /bin/px4flow ]
then then
if px4flow start
then
echo "Found px4flow sensor" echo "Found px4flow sensor"
fi
fi fi
# optional PWM input driver # optional PWM input driver
@ -381,8 +435,6 @@ then
echo "started pwm_input driver" echo "started pwm_input driver"
fi fi
echo "Trying PX4IO board"
if mtd start /fs/mtd if mtd start /fs/mtd
then then
echo "started mtd driver OK" echo "started mtd driver OK"
@ -401,14 +453,13 @@ else
sh /etc/init.d/rc.error sh /etc/init.d/rc.error
fi fi
if [ -f /bin/uavcan ] # optional oreo leds
if [ -f /bin/oreoled ]
then then
if uavcan start 1 if oreoled start autoupdate
then then
echo "started uavcan OK" echo "oreoled started OK"
else fi
echo "failed to start uavcan"
fi
fi fi
# optional smbus battery monitor # optional smbus battery monitor
@ -417,13 +468,13 @@ then
echo "Found batt_smbus" echo "Found batt_smbus"
fi fi
# optional oreo leds # optional irlock
if oreoled start if irlock start
then then
echo "oreoled started OK" echo "irlock started"
fi fi
if [ $BOARD == FMUv2 ] if [ $BOARD == FMUv2 -o $BOARD == FMUv4 ]
then then
# the ramtron on FMUv2 is very fast and can handle trillions of # the ramtron on FMUv2 is very fast and can handle trillions of
# writes. This full rw test on each boot ensures it is working # writes. This full rw test on each boot ensures it is working

View File

@ -10,3 +10,4 @@ bootloaders using:
from a nsh prompt. Users can get a nsh prompt either via the CLI in from a nsh prompt. Users can get a nsh prompt either via the CLI in
test -> shell, or by booting with no SD card installed test -> shell, or by booting with no SD card installed
to use NSH to do this, please see the Wiki http://dev.ardupilot.com/wiki/interfacing-with-pixhawk-using-the-nsh

Binary file not shown.

View File

@ -4,4 +4,5 @@
include $(SKETCHBOOK)/mk/PX4/px4_common.mk include $(SKETCHBOOK)/mk/PX4/px4_common.mk
MODULES += drivers/boards/px4fmu-v1 MODULES += drivers/boards/px4fmu-v1
MODULES += drivers/px4io
MODULES += drivers/px4flow

View File

@ -10,3 +10,6 @@ MODULES += drivers/boards/px4fmu-v2
MODULES += drivers/pwm_input MODULES += drivers/pwm_input
MODULES += modules/uavcan MODULES += modules/uavcan
MODULES += lib/mathlib MODULES += lib/mathlib
MODULES += drivers/px4io
MODULES += drivers/px4flow
MODULES += drivers/oreoled

View File

@ -0,0 +1,10 @@
#
# Makefile for the px4fmu-v4_APM configuration
#
include $(SKETCHBOOK)/mk/PX4/px4_common.mk
MODULES += drivers/mpu9250
MODULES += drivers/boards/px4fmu-v4
MODULES += drivers/pwm_input
MODULES += modules/uavcan
MODULES += lib/mathlib

View File

@ -17,10 +17,7 @@ MODULES += drivers/stm32/adc
MODULES += drivers/stm32/tone_alarm MODULES += drivers/stm32/tone_alarm
MODULES += drivers/led MODULES += drivers/led
MODULES += drivers/px4fmu MODULES += drivers/px4fmu
MODULES += drivers/px4io
MODULES += drivers/px4flow
MODULES += drivers/rgbled MODULES += drivers/rgbled
MODULES += drivers/oreoled
MODULES += drivers/mpu6000 MODULES += drivers/mpu6000
MODULES += drivers/hmc5883 MODULES += drivers/hmc5883
MODULES += drivers/ms5611 MODULES += drivers/ms5611
@ -37,6 +34,7 @@ MODULES += drivers/ets_airspeed
MODULES += drivers/meas_airspeed MODULES += drivers/meas_airspeed
MODULES += drivers/mkblctrl MODULES += drivers/mkblctrl
MODULES += drivers/batt_smbus MODULES += drivers/batt_smbus
MODULES += drivers/irlock
# #
# System commands # System commands

View File

@ -24,15 +24,8 @@ include $(MK_DIR)/targets.mk
include $(MK_DIR)/sketch_sources.mk include $(MK_DIR)/sketch_sources.mk
ifneq ($(MAKECMDGOALS),clean) ifneq ($(MAKECMDGOALS),clean)
# board specific includes # board specific includes
ifeq ($(HAL_BOARD),HAL_BOARD_APM1)
include $(MK_DIR)/board_avr.mk
endif
ifeq ($(HAL_BOARD),HAL_BOARD_APM2)
include $(MK_DIR)/board_avr.mk
endif
ifeq ($(HAL_BOARD),HAL_BOARD_SITL) ifeq ($(HAL_BOARD),HAL_BOARD_SITL)
include $(MK_DIR)/board_native.mk include $(MK_DIR)/board_native.mk
endif endif
@ -53,6 +46,10 @@ ifeq ($(HAL_BOARD),HAL_BOARD_FLYMAPLE)
include $(MK_DIR)/board_flymaple.mk include $(MK_DIR)/board_flymaple.mk
endif endif
ifeq ($(HAL_BOARD),HAL_BOARD_QURT)
include $(MK_DIR)/board_qurt.mk
endif
endif endif
endif endif

View File

@ -35,7 +35,7 @@ DEFINES += -DSKETCH=\"$(SKETCH)\" -DAPM_BUILD_DIRECTORY=APM_BUILD_$(SKE
DEFINES += $(EXTRAFLAGS) DEFINES += $(EXTRAFLAGS)
DEFINES += -DCONFIG_HAL_BOARD=$(HAL_BOARD) DEFINES += -DCONFIG_HAL_BOARD=$(HAL_BOARD)
WARNFLAGS = -Wformat -Wall -Wshadow -Wpointer-arith -Wcast-align -Wno-psabi WARNFLAGS = -Wformat -Wall -Wshadow -Wpointer-arith -Wcast-align -Wno-psabi
WARNFLAGS += -Wwrite-strings -Wformat=2 WARNFLAGS += -Wwrite-strings -Wformat=2 -Wno-unused-parameter
WARNFLAGSCXX = -Wno-reorder WARNFLAGSCXX = -Wno-reorder
DEPFLAGS = -MD -MT $@ DEPFLAGS = -MD -MT $@
@ -73,14 +73,6 @@ LDFLAGS = $(CPUFLAGS) $(OPTFLAGS) $(WARNFLAGS) -mcpu=cortex-m3 -mthumb
-Xassembler --march=armv7-m -Wall -Xassembler --march=armv7-m -Wall
LDFLAGS += -Wl,--gc-sections -Wl,-Map -Wl,$(SKETCHMAP) $(CPULDFLAGS) LDFLAGS += -Wl,--gc-sections -Wl,-Map -Wl,$(SKETCHMAP) $(CPULDFLAGS)
# under certain situations with certain avr-gcc versions the --relax flag causes
# a bug. Give the user a way to disable this flag per-sketch.
# I know this is a rotten hack but we're really close to sunset on AVR.
EXCLUDE_RELAX := $(wildcard $(SRCROOT)/norelax.inoflag)
ifeq ($(EXCLUDE_RELAX),)
# LDFLAGS += -Wl,--relax
endif
LIBS = -lm LIBS = -lm
ifeq ($(VERBOSE),) ifeq ($(VERBOSE),)

View File

@ -3,5 +3,6 @@ TOOLCHAIN = NATIVE
include $(MK_DIR)/find_tools.mk include $(MK_DIR)/find_tools.mk
# Linux build is just the same as SITL for now # Linux build is just the same as SITL for now
LIBS = -lm -lpthread -lrt LIBS = -lm -pthread -lrt
include $(MK_DIR)/board_native.mk include $(MK_DIR)/board_native.mk
include $(MK_DIR)/upload_firmware.mk

View File

@ -12,7 +12,6 @@ DEFINES += -DCONFIG_HAL_BOARD=$(HAL_BOARD) -DCONFIG_HAL_BOARD_SUBTYPE=$
WARNFLAGS = -Wformat -Wall -Wshadow -Wpointer-arith -Wcast-align -Wno-unused-parameter -Wno-missing-field-initializers WARNFLAGS = -Wformat -Wall -Wshadow -Wpointer-arith -Wcast-align -Wno-unused-parameter -Wno-missing-field-initializers
WARNFLAGS += -Wwrite-strings -Wformat=2 WARNFLAGS += -Wwrite-strings -Wformat=2
WARNFLAGSCXX = -Wno-reorder \ WARNFLAGSCXX = -Wno-reorder \
-Werror=unused-but-set-variable
-Werror=format-security \ -Werror=format-security \
-Werror=array-bounds \ -Werror=array-bounds \
-Wfatal-errors \ -Wfatal-errors \
@ -20,13 +19,21 @@ WARNFLAGSCXX = -Wno-reorder \
-Werror=uninitialized \ -Werror=uninitialized \
-Werror=init-self \ -Werror=init-self \
-Wno-missing-field-initializers -Wno-missing-field-initializers
DEPFLAGS = -MD -MT $@ DEPFLAGS = -MD -MP -MT $@
CXXOPTS = -ffunction-sections -fdata-sections -fno-exceptions -fsigned-char CXXOPTS = -ffunction-sections -fdata-sections -fno-exceptions -fsigned-char
COPTS = -ffunction-sections -fdata-sections -fsigned-char COPTS = -ffunction-sections -fdata-sections -fsigned-char
ASOPTS = -x assembler-with-cpp ASOPTS = -x assembler-with-cpp
# features: TODO detect dependecy and make them optional
HAVE_LTTNG=
ifeq ($(HAVE_LTTNG),1)
DEFINES += -DPERF_LTTNG=1
LIBS += -llttng-ust -ldl
endif
# disable as this breaks distcc # disable as this breaks distcc
#ifneq ($(SYSTYPE),Darwin) #ifneq ($(SYSTYPE),Darwin)
#LISTOPTS = -adhlns=$(@:.o=.lst) #LISTOPTS = -adhlns=$(@:.o=.lst)
@ -48,7 +55,7 @@ ifneq ($(SYSTYPE),Darwin)
LDFLAGS += -Wl,--gc-sections -Wl,-Map -Wl,$(SKETCHMAP) LDFLAGS += -Wl,--gc-sections -Wl,-Map -Wl,$(SKETCHMAP)
endif endif
LIBS ?= -lm -lpthread LIBS ?= -lm -pthread
ifneq ($(findstring CYGWIN, $(SYSTYPE)),) ifneq ($(findstring CYGWIN, $(SYSTYPE)),)
LIBS += -lwinmm LIBS += -lwinmm
endif endif
@ -102,6 +109,9 @@ print-%:
# fetch dependency info from a previous build if any of it exists # fetch dependency info from a previous build if any of it exists
-include $(ALLDEPS) -include $(ALLDEPS)
ifeq ($(HAL_BOARD_SUBTYPE),HAL_BOARD_SUBTYPE_LINUX_QFLIGHT)
include $(MK_DIR)/board_qflight.mk
else
# Link the final object # Link the final object
$(SKETCHELF): $(SKETCHOBJS) $(LIBOBJS) $(SKETCHELF): $(SKETCHOBJS) $(LIBOBJS)
@echo "Building $(SKETCHELF)" @echo "Building $(SKETCHELF)"
@ -109,6 +119,7 @@ $(SKETCHELF): $(SKETCHOBJS) $(LIBOBJS)
$(v)$(LD) $(LDFLAGS) -o $@ $(SKETCHOBJS) $(LIBOBJS) $(LIBS) $(v)$(LD) $(LDFLAGS) -o $@ $(SKETCHOBJS) $(LIBOBJS) $(LIBS)
$(v)cp $(SKETCHELF) . $(v)cp $(SKETCHELF) .
@echo "Firmware is in $(BUILDELF)" @echo "Firmware is in $(BUILDELF)"
endif
SKETCH_INCLUDES = $(SKETCHLIBINCLUDES) SKETCH_INCLUDES = $(SKETCHLIBINCLUDES)
SLIB_INCLUDES = -I$(dir $<)/utility $(SKETCHLIBINCLUDES) SLIB_INCLUDES = -I$(dir $<)/utility $(SKETCHLIBINCLUDES)

108
mk/board_qflight.mk Normal file
View File

@ -0,0 +1,108 @@
# extra rules for qualcomm flight linux build
FLIGHT_BOARD ?= flight4
HEXAGON_TOOLS_ROOT ?= $(HOME)/Qualcomm/HEXAGON_Tools/7.2.11
HEXAGON_SDK_ROOT ?= $(HOME)/Qualcomm/Hexagon_SDK/2.0
HEXAGON_FC_ADDON ?= $(HOME)/Qualcomm/HexagonFCAddon/flight_controller
V_ARCH = v5
CROSSDEV = hexagon-
HEXAGON_BIN = $(addsuffix /Tools/bin,$(HEXAGON_TOOLS_ROOT))
HEXAGON_CLANG_BIN = $(addsuffix /Tools/bin,$(HEXAGON_TOOLS_ROOT))
QURT_CC = $(HEXAGON_CLANG_BIN)/$(CROSSDEV)clang
QURT_CXX = $(HEXAGON_CLANG_BIN)/$(CROSSDEV)clang++
HEXAGON_GCC_BIN = $(HEXAGON_TOOLS_ROOT)/gnu/bin
LINUX_QAIC = $(HEXAGON_SDK_ROOT)/tools/qaic/Linux/qaic
QURT_ARM_GCC_ROOT = $(HEXAGON_SDK_ROOT)/gcc-linaro-arm-linux-gnueabihf-4.8-2013.08_linux
QURT_ARM_CC = $(QURT_ARM_GCC_ROOT)/bin/arm-linux-gnueabihf-gcc
QURT_ARM_CXX = $(QURT_ARM_GCC_ROOT)/bin/arm-linux-gnueabihf-g++
HEXAGON_LINK = $(QURT_CC)
LIBSTDCXX = $(HEXAGON_TOOLS_ROOT)/Tools/target/hexagon/lib/v5/G0/pic/libstdc++.a
QFLIGHT_CC = $(QURT_ARM_CC)
QFLIGHT_CXX = $(QURT_ARM_CXX)
QFLIGHT_LD = $(QURT_ARM_CXX)
QFLIGHT_SRC = $(SKETCHBOOK)/libraries/AP_HAL_Linux/qflight
QFLIGHT_BUILD = $(BUILDROOT)/libraries/AP_HAL_Linux/qflight
GENERATE_DSP_C = $(QFLIGHT_BUILD)/qflight_skel.c
GENERATE_ARM_C = $(QFLIGHT_BUILD)/qflight_stub.c
GENERATE_TARGETS = $(GENERATE_DSP_C) $(GENERATE_ARM_C) $(QFLIGHT_BUILD)/qflight_dsp.h
LIBOBJS += $(QFLIGHT_BUILD)/qflight_stub.o
# DSP build flags
DSP_INC=$(SHARED_INC) -I$(HEXAGON_FC_ADDON)/hexagon/inc -I$(HEXAGON_FC_ADDON)/hexagon/inc/dspal/sys -I$(HEXAGON_FC_ADDON)/hexagon/inc/dspal/sys/sys -I$(HEXAGON_FC_ADDON)/hexagon/inc/dspal/include -I$(HEXAGON_SDK_ROOT)/lib/common/qurt/ADSPv5MP/include -I$(HEXAGON_SDK_ROOT)/lib/common/remote/ship/hexagon_ReleaseG -I$(QFLIGHT_BUILD) -I$(HEXAGON_SDK_ROOT)/inc/stddef -I$(SKETCHBOOK)/libraries
DSP_FLAGS=-mv5 -G0 -g -O3 -fno-exceptions -fno-strict-aliasing -fno-zero-initialized-in-bss -fdata-sections -fpic -D__V_DYNAMIC__ $(DSP_INC) -D_PID_T -D_UID_T -D_TIMER_T -D_HAS_C9X
$(GENERATE_TARGETS): $(QFLIGHT_SRC)/qflight_dsp.idl
@echo Generating DSP IDL sources for $^
$(v)mkdir -p $(QFLIGHT_BUILD)
$(v)$(LINUX_QAIC) -mdll -o $(QFLIGHT_BUILD) -I$(QFLIGHT_SRC) -I$(HEXAGON_SDK_ROOT)/inc/stddef $<
DSP_LINK_FLAGS = -mv5 -O3 -G0 -fpic -shared -Wl,-Bsymbolic -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=free -Wl,--wrap=realloc -Wl,--wrap=memalign -Wl,--wrap=__stack_chk_fail -Wl,-soname=libqflight_skel.so
ARM_INC=-I$(HEXAGON_SDK_ROOT)/lib/common/remote/ship/UbuntuARM_ReleaseG -I$(HEXAGON_SDK_ROOT)/lib/common/rpcmem/UbuntuARM_ReleaseG/ship -I$(HEXAGON_SDK_ROOT)/inc/stddef -I$(BUILDROOT)/libraries -I$(HEXAGON_SDK_ROOT)/inc/stddef
ARM_CFLAGS=-fPIC -mword-relocations -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 -march=armv7-a -g -O3 -fno-strict-aliasing -DARM_ARCH_7A -DUSE_SYSLOG $(ARM_INC)
ARM_LINK_LIBS1 = -L$(HEXAGON_SDK_ROOT)/lib/common/remote/ship/UbuntuARM_ReleaseG -ladsprpc $(HEXAGON_SDK_ROOT)/lib/common/rpcmem/UbuntuARM_ReleaseG/ship/rpcmem.a $(HEXAGON_SDK_ROOT)/lib/common/adspmsgd/ship/UbuntuARM_ReleaseG/adspmsgd.a
ARM_LINK_LIBS2 = -lm -lc -lsupc++ -lgcc_eh -lgcc
ARM_LINK_FLAGS = -march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 -Wl,-unresolved-symbols=ignore-in-shared-libs -Wl,-ldl
LIBS += $(ARM_LINK_FLAGS) $(ARM_LINK_LIBS1) $(ARM_LINK_LIBS2)
CXXOPTS += $(ARM_CFLAGS)
COPTS += $(ARM_CFLAGS)
LIBSKETCH_SKEL_SO = $(BUILDROOT)/libqflight_skel.so
.SUFFIXES: .o .c .cpp .so .do
# build DSP object from C file
$(BUILDROOT)/libraries/%.do: $(SKETCHBOOK)/libraries/%.c $(MAVLINK_HEADERS)
$(RULEHDR)
$(v)$(QURT_CC) $(DSP_FLAGS) -c -o $@ $<
$(BUILDROOT)/libraries/AP_HAL_Linux/qflight/%.o: $(BUILDROOT)/libraries/AP_HAL_Linux/qflight/%.c
$(RULEHDR)
$(v)$(CC) -c -fPIC -mword-relocations -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 -march=armv7-a -g -O3 -fno-strict-aliasing -DARM_ARCH_7A -DUSE_SYSLOG -I$(HEXAGON_SDK_ROOT)/inc/stddef -I$(HEXAGON_SDK_ROOT)/lib/common/adspmsgd/ship/UbuntuARM_ReleaseG -I$(HEXAGON_SDK_ROOT)/lib/common/rpcmem/UbuntuARM_ReleaseG/ship -I$(HEXAGON_SDK_ROOT)/lib/common/rpcmem/UbuntuARM_ReleaseG/ship -I$(HEXAGON_SDK_ROOT)/lib/common/remote/ship/UbuntuARM_ReleaseG -std=gnu99 -o $@ $<
$(BUILDROOT)/libraries/%.do: $(SKETCHBOOK)/libraries/%.cpp
$(RULEHDR)
$(v)$(QURT_CXX) -std=gnu++11 $(DSP_FLAGS) -DSKEL_INVOKE=$(SKETCH)_skel_invoke -c -o $@ $<
.c.do:
$(RULEHDR)
$(v)$(QURT_CC) $(DSP_FLAGS) -DSKEL_INVOKE=$(SKETCH)_skel_invoke -c -o $@ $<
.cpp.do:
$(RULEHDR)
$(v)$(QURT_CXX) -std=gnu++11 $(DSP_FLAGS) -DSKEL_INVOKE=$(SKETCH)_skel_invoke -c -o $@ $<
DSPSKELOBJS=$(QFLIGHT_BUILD)/qflight_skel.do $(QFLIGHT_BUILD)/dsp_functions.do $(BUILDROOT)/libraries/AP_HAL/utility/RingBuffer.do
$(SKETCHELF): $(LIBSKETCH_SKEL_SO)
$(LIBSKETCH_SKEL_SO): $(DSPSKELOBJS)
@echo Linking $@
$(v)$(HEXAGON_LINK) -L$(HEXAGON_FC_ADDON)/hexagon/libs -lmpu9x50 -lbmp280 -g -mv5 -mG0lib -G0 -fpic -shared -Wl,-Bsymbolic -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=free -Wl,--wrap=realloc -Wl,--wrap=memalign -Wl,--wrap=__stack_chk_fail -lc -lm -Wl,-soname=libqflight_skel.so -o $@ -Wl,--whole-archive $^ -Wl,--no-whole-archive -Wl,$(LIBSTDCXX)
$(v)cp $(LIBSKETCH_SKEL_SO) .
@echo "DSP skel firmware is in libqflight_skel.so"
# Link the final object
$(SKETCHELF): $(SKETCHOBJS) $(LIBOBJS)
@echo "Building $(SKETCHELF)"
$(RULEHDR)
$(v)$(QFLIGHT_CC) -march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 -Wl,-unresolved-symbols=ignore-in-shared-libs -Wl,-ldl -o $@ -Wl,"-(" $(SKETCHOBJS) $(LIBOBJS) -L$(HEXAGON_SDK_ROOT)/lib/common/remote/ship/UbuntuARM_ReleaseG/ -ladsprpc $(HEXAGON_SDK_ROOT)/lib/common/rpcmem/UbuntuARM_ReleaseG/ship/rpcmem.a $(HEXAGON_SDK_ROOT)/lib/common/adspmsgd/ship/UbuntuARM_ReleaseG/adspmsgd.a -Wl,"-)" -lm -lc -lsupc++ -lgcc_eh -lgcc -lpthread -lstdc++
#$(v)$(LD) $(LDFLAGS) -o $@ $(SKETCHOBJS) $(LIBOBJS) $(LIBS)
$(v)cp $(SKETCHELF) .
@echo "Firmware is in $(BUILDELF)"
qflight_send: qflight
rsync -av $(LIBSKETCH_SKEL_SO) root@$(FLIGHT_BOARD):/usr/share/data/adsp
rsync -av $(SKETCHELF) root@$(FLIGHT_BOARD):

168
mk/board_qurt.mk Normal file
View File

@ -0,0 +1,168 @@
# extra rules for qualcomm flight build targetting the DSPs
# host name of flight board for "qurt_send" target
FLIGHT_BOARD ?= flight4
HEXAGON_TOOLS_ROOT ?= $(HOME)/Qualcomm/HEXAGON_Tools/7.2.11
HEXAGON_SDK_ROOT ?= $(HOME)/Qualcomm/Hexagon_SDK/2.0
HEXAGON_FC_ADDON ?= $(HOME)/Qualcomm/HexagonFCAddon/flight_controller
V_ARCH = v5
CROSSDEV = hexagon-
HEXAGON_BIN = $(addsuffix /Tools/bin,$(HEXAGON_TOOLS_ROOT))
HEXAGON_CLANG_BIN = $(addsuffix /Tools/bin,$(HEXAGON_TOOLS_ROOT))
QURT_CC = $(HEXAGON_CLANG_BIN)/$(CROSSDEV)clang
QURT_CXX = $(HEXAGON_CLANG_BIN)/$(CROSSDEV)clang++
LINUX_QAIC = $(HEXAGON_SDK_ROOT)/tools/qaic/Linux/qaic
QURT_ARM_GCC_ROOT = $(HEXAGON_SDK_ROOT)/gcc-linaro-arm-linux-gnueabihf-4.8-2013.08_linux
QURT_ARM_CC = $(QURT_ARM_GCC_ROOT)/bin/arm-linux-gnueabihf-gcc
QURT_ARM_CXX = $(QURT_ARM_GCC_ROOT)/bin/arm-linux-gnueabihf-g++
HEXAGON_LINK = $(QURT_CC)
LIBSTDCXX = $(HEXAGON_TOOLS_ROOT)/Tools/target/hexagon/lib/v5/G0/pic/libstdc++.a
LIBQCC = $(HEXAGON_TOOLS_ROOT)/Tools/target/hexagon/lib/v5/G0/pic/libqcc.a
QFLIGHT_CC = $(QURT_ARM_CC)
QFLIGHT_CXX = $(QURT_ARM_CXX)
OPT = -O3
include $(MK_DIR)/find_tools.mk
DEFINES += -DSKETCH=\"$(SKETCH)\" -DSKETCHNAME="\"$(SKETCH)\"" -DSKETCHBOOK="\"$(SKETCHBOOK)\"" -DAPM_BUILD_DIRECTORY=APM_BUILD_$(SKETCH)
DEFINES += $(EXTRAFLAGS)
DEFINES += -DCONFIG_HAL_BOARD=$(HAL_BOARD) -DCONFIG_HAL_BOARD_SUBTYPE=$(HAL_BOARD_SUBTYPE) -DAP_MAIN=ArduPilot_main
DEPFLAGS = -MD -MP -MT $@
CXXOPTS = -ffunction-sections -fdata-sections -fno-exceptions -fsigned-char $(DSP_CFLAGS) $(WARNFLAGSCXX)
COPTS = -ffunction-sections -fdata-sections -fsigned-char $(DSP_CFLAGS)
# DSP build flags
DSP_INC=-I$(HEXAGON_SDK_ROOT)/gnu/hexagon/include -I$(HEXAGON_FC_ADDON)/hexagon/inc -I$(HEXAGON_FC_ADDON)/hexagon/inc/dspal/sys -I$(HEXAGON_FC_ADDON)/hexagon/inc/dspal/sys/sys -I$(HEXAGON_FC_ADDON)/hexagon/inc/dspal/include -I$(HEXAGON_SDK_ROOT)/lib/common/qurt/ADSPv5MP/include -I$(HEXAGON_SDK_ROOT)/lib/common/remote/ship/hexagon_Debug_dynamic -I$(HEXAGON_SDK_ROOT)/inc/stddef -I$(HAL_QURT_BUILD)
DSP_WARN=-Wno-unused-parameter
DSP_FLAGS=-mv5 -G0 -g $(OPT) $(DSP_WARN) -fno-exceptions -fno-strict-aliasing -fno-zero-initialized-in-bss -fdata-sections -fpic -D__V_DYNAMIC__ -D_DEBUG $(DSP_INC) -D_PID_T -D_UID_T -D_TIMER_T -D_HAS_C9X
DSP_LINK_FLAGS = -mv5 -G0 -fpic -shared -Wl,-Bsymbolic -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=free -Wl,--wrap=realloc -Wl,--wrap=memalign -Wl,--wrap=__stack_chk_fail -Wl,-soname=lib$(SKETCHNAME)_skel.so
CXXFLAGS += -std=gnu++11 $(WARNFLAGS) $(WARNFLAGSCXX) $(DEPFLAGS) $(CXXOPTS) $(DEFINES) $(DSP_FLAGS)
CFLAGS += $(WARNFLAGS) $(DEPFLAGS) $(COPTS) $(DEFINES) $(DSP_FLAGS)
ARM_INC=-I$(HEXAGON_SDK_ROOT)/lib/common/remote/ship/UbuntuARM_Debug -I$(SKETCHBOOK)/libraries/
ARM_WARN=-Wno-unused-parameter
ARM_CFLAGS=$(ARM_WARN) -fPIC -mword-relocations -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 -march=armv7-a -g -O0 -fno-strict-aliasing -DARM_ARCH_7A -DUSE_SYSLOG $(ARM_INC) -I$(HEXAGON_SDK_ROOT)/inc/stddef -DCONFIG_HAL_BOARD=HAL_BOARD_LINUX -DCONFIG_HAL_BOARD_SUBTYPE=HAL_BOARD_SUBTYPE_LINUX_QFLIGHT
ifeq ($(VERBOSE),)
v = @
else
v =
endif
# Library object files
LIBOBJS := $(SKETCHLIBOBJS)
# The ELF file
SKETCHELF = $(BUILDROOT)/$(SKETCH).elf
LIBSKETCH_SKEL_SO = $(BUILDROOT)/libardupilot_skel.so
BUILDELF = $(notdir $(SKETCHELF))
# All of the objects that may be built
ALLOBJS = $(SKETCHOBJS) $(LIBOBJS)
# All of the dependency files that may be generated
ALLDEPS = $(ALLOBJS:%.o=%.d)
HAL_QURT_SRC = $(SKETCHBOOK)/libraries/AP_HAL_QURT
HAL_QURT_BUILD = $(BUILDROOT)/libraries/AP_HAL_QURT
# main app sources
MAINAPP_SRC = $(wildcard $(HAL_QURT_SRC)/mainapp/*.cpp) $(wildcard $(SKETCHBOOK)/libraries/AP_HAL/utility/*.cpp)
MAINAPPOBJS = $(subst $(SKETCHBOOK)/,$(BUILDROOT)/,$(MAINAPP_SRC:%.cpp=%.ao)) $(HAL_QURT_BUILD)/ardupilot_stub.ao
.SUFFIXES: .ao .o .c .so .do
# build arm object
$(BUILDROOT)/libraries/%.ao: $(SKETCHBOOK)/libraries/%.c
$(RULEHDR)
$(v)$(QURT_ARM_CC) -c $(ARM_CFLAGS) -I$(HAL_QURT_BUILD) -o $@ $< -DSKETCHNAME="\"$(SKETCH)\""
# build arm C++ object
$(BUILDROOT)/libraries/%.ao: $(SKETCHBOOK)/libraries/%.cpp $(HAL_QURT_BUILD)/qurt_dsp.h
$(RULEHDR)
$(v)$(QURT_ARM_CXX) -std=gnu++11 -c $(ARM_CFLAGS) -I$(HAL_QURT_BUILD) -o $@ $< -DSKETCHNAME="\"$(SKETCH)\""
$(BUILDROOT)/libraries/%.ao: $(BUILDROOT)/libraries/%.c
$(RULEHDR)
$(v)$(QURT_ARM_CC) -c $(ARM_CFLAGS) -I$(HAL_QURT_BUILD) -o $@ $< -DSKETCHNAME="\"$(SKETCH)\""
# build DSP object from C file
$(BUILDROOT)/libraries/%.do: $(BUILDROOT)/libraries/%.c
$(RULEHDR)
$(v)$(QURT_CC) $(CFLAGS) -I$(HEXAGON_SDK_ROOT)/inc/stddef -DSKEL_INVOKE=$(SKETCH)_skel_invoke -c -o $@ $<
################################################################################
# Targets
#
all: $(SKETCHELF)
print-%:
echo "$*=$($*)"
################################################################################
# Rules
#
SKETCH_INCLUDES = $(SKETCHLIBINCLUDES)
SLIB_INCLUDES = $(SKETCHLIBINCLUDES)
# fetch dependency info from a previous build if any of it exists
-include $(ALLDEPS)
GENERATE_DSP_C = $(HAL_QURT_BUILD)/ardupilot_skel.c
GENERATE_ARM_C = $(HAL_QURT_BUILD)/ardupilot_stub.c
GENERATE_TARGETS = $(HAL_QURT_BUILD)/qurt_dsp.h $(GENERATE_DSP_C) $(GENERATE_ARM_C)
$(GENERATE_TARGETS): $(HAL_QURT_SRC)/qurt_dsp.idl
@echo Generating DSP IDL sources for $^
$(v)mkdir -p $(HAL_QURT_BUILD)
$(v)$(LINUX_QAIC) -mdll -o $(HAL_QURT_BUILD) -I$(HAL_QURT_SRC) -I$(HEXAGON_SDK_ROOT)/inc/stddef $<
# Link the final object
$(SKETCHELF): $(MAINAPPOBJS) $(LIBSKETCH_SKEL_SO) $(GENERATE_TARGETS)
@echo "Building $(SKETCHELF)"
$(RULEHDR)
$(v)$(QFLIGHT_CXX) -march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 -Wl,-unresolved-symbols=ignore-in-shared-libs -Wl,-ldl -o $@ -Wl,"-(" $(MAINAPPOBJS) -L$(HEXAGON_SDK_ROOT)/lib/common/remote/ship/UbuntuARM_ReleaseG/ -ladsprpc $(HEXAGON_SDK_ROOT)/lib/common/rpcmem/UbuntuARM_ReleaseG/ship/rpcmem.a $(HEXAGON_SDK_ROOT)/lib/common/adspmsgd/ship/UbuntuARM_ReleaseG/adspmsgd.a -Wl,"-)" -lm -lc -lsupc++ -lgcc_eh -lgcc -lpthread -lstdc++
$(v)cp $(SKETCHELF) .
@echo "Firmware is in $(BUILDELF)"
DSPSKELOBJS=$(HAL_QURT_BUILD)/ardupilot_skel.do
# this is quite bizarre. The provided libc mixes PIC and non-PIC code,
# which seems to confuse the linker. In order to link to some critical
# system objects we need to extract them from libc into a new library
LIBC_SRC=$(HEXAGON_TOOLS_ROOT)/Tools/target/hexagon/lib/v5/G0/pic/libc.a
LIBC_EXTRACTDIR=$(BUILDROOT)/libc_extracted
LIBC_OBJECTS=xfdtest.o xdtest.o feclearexcept.o fegetenv.o fesetenv.o
LIBC_EXTRACTED=$(LIBC_EXTRACTDIR)/libc_extracted.a
$(LIBC_EXTRACTED): $(LIBC_SRC)
$(v)echo Extracting libc objects into $@
$(v)mkdir -p $(LIBC_EXTRACTDIR)
$(v)(cd $(LIBC_EXTRACTDIR) && ar x $(LIBC_SRC) $(LIBC_OBJECTS) && ar crs libc_extracted.a $(LIBC_OBJECTS))
$(LIBSKETCH_SKEL_SO): $(DSPSKELOBJS) $(ALLOBJS) $(GENERATE_TARGETS) $(LIBC_EXTRACTED)
@echo Linking $@
$(v)$(HEXAGON_LINK) -L$(HEXAGON_FC_ADDON)/hexagon/libs -lmpu9x50 -lbmp280 -lcsr_gps -g -mv5 -mG0lib -G0 -fpic -shared -Wl,-Bsymbolic -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=free -Wl,--wrap=realloc -Wl,--wrap=memalign -Wl,--wrap=__stack_chk_fail -lc -lm -Wl,-soname=libqflight_skel.so -o $@ -Wl,--whole-archive $(DSPSKELOBJS) $(ALLOBJS) $(LIBC_EXTRACTED) -Wl,--no-whole-archive -Wl,$(LIBSTDCXX) -Wl,$(LIBQCC) -Wl,$(HEXAGON_TOOLS_ROOT)/Tools/target/hexagon/lib/v5/G0/libdl.a
$(v)cp $(LIBSKETCH_SKEL_SO) .
@echo "DSP skel firmware is in $(BUILDELF)"
include $(MK_DIR)/build_rules.mk
qurt_send: qurt
rsync -av $(LIBSKETCH_SKEL_SO) root@$(FLIGHT_BOARD):/usr/share/data/adsp
rsync -av $(SKETCHELF) root@$(FLIGHT_BOARD):

View File

@ -3,11 +3,11 @@
# Build sketch objects # Build sketch objects
# #
$(BUILDROOT)/%.o: $(BUILDROOT)/%.cpp $(BUILDROOT)/%.o: $(BUILDROOT)/%.cpp $(GENERATE_TARGETS) $(MAVLINK_HEADERS)
$(RULEHDR) $(RULEHDR)
$(v)$(CXX) $(CXXFLAGS) -c -o $@ $< $(SKETCH_INCLUDES) $(v)$(CXX) $(CXXFLAGS) -c -o $@ $< $(SKETCH_INCLUDES)
$(BUILDROOT)/%.o: $(BUILDROOT)/make.flags $(SRCROOT)/%.cpp $(BUILDROOT)/%.o: $(BUILDROOT)/make.flags $(SRCROOT)/%.cpp $(GENERATE_TARGETS) $(MAVLINK_HEADERS)
$(RULEHDR) $(RULEHDR)
$(v)$(CXX) $(CXXFLAGS) -c -o $@ $*.cpp $(SKETCH_INCLUDES) $(v)$(CXX) $(CXXFLAGS) -c -o $@ $*.cpp $(SKETCH_INCLUDES)
@ -23,7 +23,7 @@ $(BUILDROOT)/%.o: $(SRCROOT)/%.S
# Build library objects from sources in the sketchbook # Build library objects from sources in the sketchbook
# #
$(BUILDROOT)/libraries/%.o: $(SKETCHBOOK)/libraries/%.cpp $(BUILDROOT)/libraries/%.o: $(SKETCHBOOK)/libraries/%.cpp $(GENERATE_TARGETS) $(MAVLINK_HEADERS)
$(RULEHDR) $(RULEHDR)
$(v)$(CXX) $(CXXFLAGS) -c -o $@ $< $(SLIB_INCLUDES) $(v)$(CXX) $(CXXFLAGS) -c -o $@ $< $(SLIB_INCLUDES)

View File

@ -2,7 +2,7 @@
echo "Checking modules" echo "Checking modules"
MODULE_LIST="PX4Firmware PX4NuttX uavcan" MODULE_LIST="PX4Firmware PX4NuttX uavcan mavlink"
NEED_INIT=0 NEED_INIT=0
@ -10,12 +10,12 @@ cd $(dirname "$0")/.. || exit 1
for m in $MODULE_LIST; do for m in $MODULE_LIST; do
[ -d modules/$m ] || { [ -d modules/$m ] || {
echo "module/$m missing - need module init" echo "modules/$m missing - need module init"
NEED_INIT=1 NEED_INIT=1
break break
} }
[ -f modules/$m/.git ] || { [ -f modules/$m/.git ] || {
echo "module/$m/.git missing - need module init" echo "modules/$m/.git missing - need module init"
NEED_INIT=1 NEED_INIT=1
break break
} }
@ -25,10 +25,12 @@ done
set -x set -x
git submodule init || { git submodule init || {
echo "git submodule init failed" echo "git submodule init failed"
git submodule status
exit 1 exit 1
} }
git submodule update || { git submodule update || {
echo "git submodule update failed" echo "git submodule update failed"
git submodule status
exit 1 exit 1
} }
cat <<EOF cat <<EOF

View File

@ -137,9 +137,9 @@ HAL_BOARD = HAL_BOARD_LINUX
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_NONE HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_NONE
endif endif
ifneq ($(findstring erle, $(MAKECMDGOALS)),) ifneq ($(findstring erleboard, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_LINUX HAL_BOARD = HAL_BOARD_LINUX
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_ERLE HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_ERLEBOARD
endif endif
ifneq ($(findstring zynq, $(MAKECMDGOALS)),) ifneq ($(findstring zynq, $(MAKECMDGOALS)),)
@ -163,11 +163,26 @@ HAL_BOARD = HAL_BOARD_LINUX
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_NAVIO HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_NAVIO
endif endif
ifneq ($(findstring raspilot, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_LINUX
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_RASPILOT
endif
ifneq ($(findstring erlebrain2, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_LINUX
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2
endif
ifneq ($(findstring bbbmini, $(MAKECMDGOALS)),) ifneq ($(findstring bbbmini, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_LINUX HAL_BOARD = HAL_BOARD_LINUX
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_BBBMINI HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_BBBMINI
endif endif
ifneq ($(findstring minlure, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_LINUX
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_MINLURE
endif
ifneq ($(findstring vrbrain, $(MAKECMDGOALS)),) ifneq ($(findstring vrbrain, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_VRBRAIN HAL_BOARD = HAL_BOARD_VRBRAIN
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_NONE HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_NONE
@ -183,23 +198,32 @@ HAL_BOARD = HAL_BOARD_VRBRAIN
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_NONE HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_NONE
endif endif
ifneq ($(findstring apm1, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_APM1
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_AVR_APM1
endif
ifneq ($(findstring apm2, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_APM2
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_AVR_APM2
endif
ifneq ($(findstring flymaple, $(MAKECMDGOALS)),) ifneq ($(findstring flymaple, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_FLYMAPLE HAL_BOARD = HAL_BOARD_FLYMAPLE
endif endif
ifneq ($(findstring bhat, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_LINUX
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_BH
endif
ifneq ($(findstring qflight, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_LINUX
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_QFLIGHT
endif
ifneq ($(findstring qurt, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_QURT
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_NONE
endif
ifneq ($(findstring pxfmini, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_LINUX
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_PXFMINI
endif
# default to SITL # default to SITL
ifeq ($(HAL_BOARD),) ifeq ($(HAL_BOARD),)
HAL_BOARD = HAL_BOARD_SITL HAL_BOARD = HAL_BOARD_SITL
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_NONE HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_NONE
endif endif

View File

@ -7,7 +7,6 @@
# #
ifeq ($(SYSTYPE),Darwin) ifeq ($(SYSTYPE),Darwin)
# use the tools that come with Arduino # use the tools that come with Arduino
TOOLPATH := $(ARDUINO)/hardware/tools/avr/bin
# use BWK awk # use BWK awk
AWK = awk AWK = awk
FIND_TOOL = $(firstword $(wildcard $(addsuffix /$(1),$(TOOLPATH)))) FIND_TOOL = $(firstword $(wildcard $(addsuffix /$(1),$(TOOLPATH))))
@ -35,15 +34,6 @@ NATIVE_LD := g++
NATIVE_GDB := gdb NATIVE_GDB := gdb
NATIVE_OBJCOPY := objcopy NATIVE_OBJCOPY := objcopy
AVR_CXX := $(call FIND_TOOL,avr-g++)
AVR_CC := $(call FIND_TOOL,avr-gcc)
AVR_AS := $(call FIND_TOOL,avr-gcc)
AVR_AR := $(call FIND_TOOL,avr-ar)
AVR_LD := $(call FIND_TOOL,avr-gcc)
AVR_GDB := $(call FIND_TOOL,avr-gdb)
AVR_OBJCOPY := $(call FIND_TOOL,avr-objcopy)
AVRDUDE := $(call FIND_TOOL,avrdude)
AVARICE := $(call FIND_TOOL,avarice) AVARICE := $(call FIND_TOOL,avarice)
# Tools for Maple/Flymaple # Tools for Maple/Flymaple

View File

@ -20,10 +20,9 @@ help:
@echo " Targets" @echo " Targets"
@echo " -------" @echo " -------"
@echo "" @echo ""
@echo " apm1 - the APM1 board"
@echo " apm2 - the APM2 board"
@echo " px4-v1 - the PX4v1 board" @echo " px4-v1 - the PX4v1 board"
@echo " px4-v2 - the Pixhawk" @echo " px4-v2 - the Pixhawk"
@echo " px4-v4 - the XRacer"
@echo " pxf - the Beagle Bone Black (BBB) + PXF cape combination" @echo " pxf - the Beagle Bone Black (BBB) + PXF cape combination"
@echo " navio - the RaspberryPi + NavIO cape combination" @echo " navio - the RaspberryPi + NavIO cape combination"
@echo " linux - a generic Linux build" @echo " linux - a generic Linux build"
@ -32,3 +31,10 @@ help:
@echo " sitl - the SITL Software In The Loop simulation" @echo " sitl - the SITL Software In The Loop simulation"
@echo " bbbmini - the Beagle Bone Black mini" @echo " bbbmini - the Beagle Bone Black mini"
@echo " bebop - the Parrot Bebop" @echo " bebop - the Parrot Bebop"
@echo " raspilot - the RaspberryPi + pilot cape combination"
@echo " erleboard - the ErleBoard legacy design"
@echo " minlure - the drone lure for MinnowBoard and others"
@echo " qflight - qualcomm flight board"
@echo " erlebrain2 - the Erle-Brain 2 board"
@echo " bhat - the RaspberryPi + BH HAT combination"
@echo " pxfmini - the RaspberryPi Zero + PXFmini cape combination"

12
mk/mavgen.mk Normal file
View File

@ -0,0 +1,12 @@
# mavlink header generation
MAVLINK_DIR := $(SKETCHBOOK)/modules/mavlink/
MESSAGE_DEFINITIONS := $(SKETCHBOOK)/modules/mavlink/message_definitions/v1.0
MAVLINK_HEADERS := $(BUILDROOT)/libraries/GCS_MAVLink/include/mavlink/v1.0/ardupilotmega/mavlink.h $(wildcard $(BUILDROOT)/libraries/GCS_MAVLink/include/mavlink/v1.0/,*.h) $(wildcard $(BUILDROOT)/libraries/GCS_MAVLink/include/mavlink/v1.0/ardupilotmega,*.h)
MAVLINK_OUTPUT_DIR := $(BUILDROOT)/libraries/GCS_MAVLink/include/mavlink/v1.0
$(MAVLINK_HEADERS): $(MESSAGE_DEFINITIONS)/ardupilotmega.xml $(MESSAGE_DEFINITIONS)/common.xml
echo "Generating MAVLink headers..."
#goto mavlink module directory and run the most recent generator script
echo "Generating C code using mavgen.py located at" $(SKETCHBOOK)/modules/mavlink/
PYTHONPATH=$(MAVLINK_DIR) python $(MAVLINK_DIR)/pymavlink/tools/mavgen.py --lang=C --wire-protocol=1.0 --output=$(MAVLINK_OUTPUT_DIR) $(MAVLINK_DIR)/message_definitions/v1.0/ardupilotmega.xml

41
mk/module_clean.sh Normal file
View File

@ -0,0 +1,41 @@
#!/bin/sh
echo "cleaning modules"
MODULE_LIST="PX4Firmware PX4NuttX uavcan"
NEED_INIT=0
cd $(dirname "$0")/.. || exit 1
for m in $MODULE_LIST; do
[ -d modules/$m ] || {
echo "module/$m missing - need module init"
NEED_INIT=1
break
}
done
[ $NEED_INIT = 1 ] && {
set -x
git submodule init || {
echo "git submodule init failed"
exit 1
}
git submodule update || {
echo "git submodule update failed"
exit 1
}
}
for m in $MODULE_LIST; do
RET=$(git submodule summary modules/$m | egrep "^..<")
[ -z "$RET" ] || {
echo "Module modules/$m out of date"
git submodule summary modules/$m
echo "Please run 'git submodule update'"
exit 1
}
done
exit 0

View File

@ -2,9 +2,7 @@
# git submodule support # git submodule support
.PHONY: CHECK_MODULES .PHONY: CHECK_MODULES
all: CHECK_MODULES
# PX4 build needs submodules
px4-%: CHECK_MODULES
CHECK_MODULES: CHECK_MODULES:
$(v)$(MK_DIR)/check_modules.sh $(v)$(MK_DIR)/check_modules.sh

View File

@ -43,10 +43,12 @@ EXTRAFLAGS += -DUAVCAN=1
# we have different config files for V1 and V2 # we have different config files for V1 and V2
PX4_V1_CONFIG_FILE=$(MK_DIR)/PX4/config_px4fmu-v1_APM.mk PX4_V1_CONFIG_FILE=$(MK_DIR)/PX4/config_px4fmu-v1_APM.mk
PX4_V2_CONFIG_FILE=$(MK_DIR)/PX4/config_px4fmu-v2_APM.mk PX4_V2_CONFIG_FILE=$(MK_DIR)/PX4/config_px4fmu-v2_APM.mk
PX4_V4_CONFIG_FILE=$(MK_DIR)/PX4/config_px4fmu-v4_APM.mk
SKETCHFLAGS=$(SKETCHLIBINCLUDES) -DARDUPILOT_BUILD -DTESTS_MATHLIB_DISABLE -DCONFIG_HAL_BOARD=HAL_BOARD_PX4 -DSKETCHNAME="\\\"$(SKETCH)\\\"" -DSKETCH_MAIN=ArduPilot_main -DAPM_BUILD_DIRECTORY=APM_BUILD_$(SKETCH) SKETCHFLAGS=$(SKETCHLIBINCLUDES) -DARDUPILOT_BUILD -DTESTS_MATHLIB_DISABLE -DCONFIG_HAL_BOARD=HAL_BOARD_PX4 -DSKETCHNAME="\\\"$(SKETCH)\\\"" -DSKETCH_MAIN=ArduPilot_main -DAPM_BUILD_DIRECTORY=APM_BUILD_$(SKETCH)
WARNFLAGS = -Werror -Wno-psabi -Wno-packed -Wno-error=double-promotion -Wno-error=unused-variable -Wno-error=reorder -Wno-error=float-equal -Wno-error=pmf-conversions -Wno-error=missing-declarations -Wno-error=unused-function WARNFLAGS = -Werror -Wno-psabi -Wno-packed -Wno-error=double-promotion -Wno-error=unused-variable -Wno-error=reorder -Wno-error=float-equal -Wno-error=pmf-conversions -Wno-error=missing-declarations -Wno-error=unused-function
OPTFLAGS = -fsingle-precision-constant
# avoid PX4 submodules # avoid PX4 submodules
export GIT_SUBMODULES_ARE_EVIL = 1 export GIT_SUBMODULES_ARE_EVIL = 1
@ -54,8 +56,8 @@ export GIT_SUBMODULES_ARE_EVIL = 1
PYTHONPATH=$(SKETCHBOOK)/mk/PX4/Tools/genmsg/src:$(SKETCHBOOK)/mk/PX4/Tools/gencpp/src PYTHONPATH=$(SKETCHBOOK)/mk/PX4/Tools/genmsg/src:$(SKETCHBOOK)/mk/PX4/Tools/gencpp/src
export PYTHONPATH export PYTHONPATH
PX4_MAKE = $(v) GIT_SUBMODULES_ARE_EVIL=1 ARDUPILOT_BUILD=1 make -C $(SKETCHBOOK) -f $(PX4_ROOT)/Makefile EXTRADEFINES="$(SKETCHFLAGS) $(WARNFLAGS) "'$(EXTRAFLAGS)' APM_MODULE_DIR=$(SKETCHBOOK) SKETCHBOOK=$(SKETCHBOOK) CCACHE=$(CCACHE) PX4_ROOT=$(PX4_ROOT) NUTTX_SRC=$(NUTTX_SRC) MAXOPTIMIZATION="-Os" UAVCAN_DIR=$(UAVCAN_DIR) PX4_MAKE = $(v)+ GIT_SUBMODULES_ARE_EVIL=1 ARDUPILOT_BUILD=1 $(MAKE) -C $(SKETCHBOOK) -f $(PX4_ROOT)/Makefile.make EXTRADEFINES="$(SKETCHFLAGS) $(WARNFLAGS) $(OPTFLAGS) "'$(EXTRAFLAGS)' APM_MODULE_DIR=$(SKETCHBOOK) SKETCHBOOK=$(SKETCHBOOK) CCACHE=$(CCACHE) PX4_ROOT=$(PX4_ROOT) NUTTX_SRC=$(NUTTX_SRC) MAXOPTIMIZATION="-Os" UAVCAN_DIR=$(UAVCAN_DIR)
PX4_MAKE_ARCHIVES = make -C $(PX4_ROOT) NUTTX_SRC=$(NUTTX_SRC) CCACHE=$(CCACHE) archives MAXOPTIMIZATION="-Os" PX4_MAKE_ARCHIVES = $(MAKE) -C $(PX4_ROOT) -f $(PX4_ROOT)/Makefile.make NUTTX_SRC=$(NUTTX_SRC) CCACHE=$(CCACHE) archives MAXOPTIMIZATION="-Os"
HASHADDER_FLAGS += --ardupilot "$(SKETCHBOOK)" HASHADDER_FLAGS += --ardupilot "$(SKETCHBOOK)"
@ -75,39 +77,59 @@ module_mk:
$(v) echo "MODULE_COMMAND = ArduPilot" >> $(SKETCHBOOK)/module.mk.new $(v) echo "MODULE_COMMAND = ArduPilot" >> $(SKETCHBOOK)/module.mk.new
$(v) echo "SRCS = $(wildcard $(SRCROOT)/*.cpp) $(SKETCHLIBSRCSRELATIVE)" >> $(SKETCHBOOK)/module.mk.new $(v) echo "SRCS = $(wildcard $(SRCROOT)/*.cpp) $(SKETCHLIBSRCSRELATIVE)" >> $(SKETCHBOOK)/module.mk.new
$(v) echo "MODULE_STACKSIZE = 4096" >> $(SKETCHBOOK)/module.mk.new $(v) echo "MODULE_STACKSIZE = 4096" >> $(SKETCHBOOK)/module.mk.new
$(v) echo "EXTRACXXFLAGS = -Wframe-larger-than=1200" >> $(SKETCHBOOK)/module.mk.new $(v) echo "EXTRACXXFLAGS = -Wframe-larger-than=1300" >> $(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) 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 $(v) rm -f $(SKETCHBOOK)/module.mk.new
px4-v1: $(BUILDROOT)/make.flags CHECK_MODULES $(PX4_ROOT)/Archives/px4fmu-v1.export $(SKETCHCPP) module_mk px4-io-v1 px4-v1: $(BUILDROOT)/make.flags CHECK_MODULES $(MAVLINK_HEADERS) $(PX4_ROOT)/Archives/px4fmu-v1.export $(SKETCHCPP) module_mk px4-io-v1
$(RULEHDR) $(RULEHDR)
$(v) rm -f $(PX4_ROOT)/makefiles/$(PX4_V1_CONFIG_FILE) $(v) rm -f $(PX4_ROOT)/makefiles/$(PX4_V1_CONFIG_FILE)
$(v) cp $(PX4_V1_CONFIG_FILE) $(PX4_ROOT)/makefiles/nuttx/ $(v) cp $(PX4_V1_CONFIG_FILE) $(PX4_ROOT)/makefiles/nuttx/
$(v) $(PX4_MAKE) px4fmu-v1_APM $(v) $(PX4_MAKE) px4fmu-v1_APM
$(v) /bin/rm -f $(SKETCH)-v1.px4 $(v) /bin/rm -f $(SKETCH)-v1.px4
$(v) arm-none-eabi-size $(PX4_ROOT)/Build/px4fmu-v1_APM.build/firmware.elf
$(v) cp $(PX4_ROOT)/Images/px4fmu-v1_APM.px4 $(SKETCH)-v1.px4 $(v) cp $(PX4_ROOT)/Images/px4fmu-v1_APM.px4 $(SKETCH)-v1.px4
$(v) $(SKETCHBOOK)/Tools/scripts/add_git_hashes.py $(HASHADDER_FLAGS) "$(SKETCH)-v1.px4" "$(SKETCH)-v1.px4" $(v) $(SKETCHBOOK)/Tools/scripts/add_git_hashes.py $(HASHADDER_FLAGS) "$(SKETCH)-v1.px4" "$(SKETCH)-v1.px4"
$(v) echo "PX4 $(SKETCH) Firmware is in $(SKETCH)-v1.px4" $(v) echo "PX4 $(SKETCH) Firmware is in $(SKETCH)-v1.px4"
px4-v2: $(BUILDROOT)/make.flags CHECK_MODULES $(PX4_ROOT)/Archives/px4fmu-v2.export $(SKETCHCPP) module_mk px4-io-v2 px4-v2: $(BUILDROOT)/make.flags CHECK_MODULES $(MAVLINK_HEADERS) $(PX4_ROOT)/Archives/px4fmu-v2.export $(SKETCHCPP) module_mk px4-io-v2
$(RULEHDR) $(RULEHDR)
$(v) rm -f $(PX4_ROOT)/makefiles/$(PX4_V2_CONFIG_FILE) $(v) rm -f $(PX4_ROOT)/makefiles/$(PX4_V2_CONFIG_FILE)
$(v) cp $(PX4_V2_CONFIG_FILE) $(PX4_ROOT)/makefiles/nuttx/ $(v) cp $(PX4_V2_CONFIG_FILE) $(PX4_ROOT)/makefiles/nuttx/
$(PX4_MAKE) px4fmu-v2_APM $(PX4_MAKE) px4fmu-v2_APM
$(v) /bin/rm -f $(SKETCH)-v2.px4 $(v) /bin/rm -f $(SKETCH)-v2.px4
$(v) arm-none-eabi-size $(PX4_ROOT)/Build/px4fmu-v2_APM.build/firmware.elf
$(v) cp $(PX4_ROOT)/Images/px4fmu-v2_APM.px4 $(SKETCH)-v2.px4 $(v) cp $(PX4_ROOT)/Images/px4fmu-v2_APM.px4 $(SKETCH)-v2.px4
$(v) $(SKETCHBOOK)/Tools/scripts/add_git_hashes.py $(HASHADDER_FLAGS) "$(SKETCH)-v2.px4" "$(SKETCH)-v2.px4" $(v) $(SKETCHBOOK)/Tools/scripts/add_git_hashes.py $(HASHADDER_FLAGS) "$(SKETCH)-v2.px4" "$(SKETCH)-v2.px4"
$(v) echo "PX4 $(SKETCH) Firmware is in $(SKETCH)-v2.px4" $(v) echo "PX4 $(SKETCH) Firmware is in $(SKETCH)-v2.px4"
px4: px4-v1 px4-v2 px4-v4: $(BUILDROOT)/make.flags CHECK_MODULES $(MAVLINK_HEADERS) $(PX4_ROOT)/Archives/px4fmu-v4.export $(SKETCHCPP) module_mk
$(RULEHDR)
$(v) rm -f $(PX4_ROOT)/makefiles/$(PX4_V4_CONFIG_FILE)
$(v) cp $(PX4_V4_CONFIG_FILE) $(PX4_ROOT)/makefiles/nuttx/
$(PX4_MAKE) px4fmu-v4_APM
$(v) /bin/rm -f $(SKETCH)-v4.px4
$(v) arm-none-eabi-size $(PX4_ROOT)/Build/px4fmu-v4_APM.build/firmware.elf
$(v) cp $(PX4_ROOT)/Images/px4fmu-v4_APM.px4 $(SKETCH)-v4.px4
$(v) $(SKETCHBOOK)/Tools/scripts/add_git_hashes.py $(HASHADDER_FLAGS) "$(SKETCH)-v4.px4" "$(SKETCH)-v4.px4"
$(v) echo "PX4 $(SKETCH) Firmware is in $(SKETCH)-v4.px4"
px4: px4-v1 px4-v2 px4-v4
px4-clean: clean CHECK_MODULES px4-archives-clean px4-cleandep px4-clean: clean CHECK_MODULES px4-archives-clean px4-cleandep
$(v) /bin/rm -rf $(PX4_ROOT)/makefiles/build $(PX4_ROOT)/Build $(v) /bin/rm -rf $(PX4_ROOT)/makefiles/build $(PX4_ROOT)/Build $(PX4_ROOT)/Images/*.px4 $(PX4_ROOT)/Images/*.bin
$(v) /bin/rm -rf $(PX4_ROOT)/src/modules/uORB/topics $(PX4_ROOT)/src/platforms/nuttx/px4_messages
px4-cleandep: clean px4-cleandep: clean
$(v) find $(PX4_ROOT)/Build -type f -name '*.d' | xargs rm -f $(v) find $(PX4_ROOT)/Build -type f -name '*.d' | xargs rm -f
$(v) find $(UAVCAN_DIRECTORY) -type f -name '*.d' | xargs rm -f
$(v) find $(SKETCHBOOK)/$(SKETCH) -type f -name '*.d' | xargs rm -f $(v) find $(SKETCHBOOK)/$(SKETCH) -type f -name '*.d' | xargs rm -f
px4-v2-upload-solo: px4-v2
scp $(SKETCH)-v2.px4 root@10.1.1.10:/tmp/
ssh root@10.1.1.10 PYTHONUNBUFFERED=1 loadPixhawk.py /tmp/ArduCopter-v2.px4
ssh root@10.1.1.10 rm /tmp/ArduCopter-v2.px4;
px4-v1-upload: px4-v1 px4-v1-upload: px4-v1
$(RULEHDR) $(RULEHDR)
$(v) $(PX4_MAKE) px4fmu-v1_APM upload $(v) $(PX4_MAKE) px4fmu-v1_APM upload
@ -116,13 +138,17 @@ px4-v2-upload: px4-v2
$(RULEHDR) $(RULEHDR)
$(v) $(PX4_MAKE) px4fmu-v2_APM upload $(v) $(PX4_MAKE) px4fmu-v2_APM upload
px4-v4-upload: px4-v4
$(RULEHDR)
$(v) $(PX4_MAKE) px4fmu-v4_APM upload
px4-upload: px4-v1-upload px4-upload: px4-v1-upload
px4-archives-clean: px4-archives-clean:
$(v) /bin/rm -rf $(PX4_ROOT)/Archives $(v) /bin/rm -rf $(PX4_ROOT)/Archives
px4-io-v1: $(PX4_ROOT)/Archives/px4io-v1.export px4-io-v1: $(PX4_ROOT)/Archives/px4io-v1.export
$(v) make -C $(PX4_ROOT) px4io-v1_default $(v)+ $(MAKE) -C $(PX4_ROOT) -f $(PX4_ROOT)/Makefile.make px4io-v1_default
$(v) /bin/rm -f px4io-v1.bin $(v) /bin/rm -f px4io-v1.bin
$(v) cp $(PX4_ROOT)/Images/px4io-v1_default.bin px4io-v1.bin $(v) cp $(PX4_ROOT)/Images/px4io-v1_default.bin px4io-v1.bin
$(v) cp $(PX4_ROOT)/Build/px4io-v1_default.build/firmware.elf px4io-v1.elf $(v) cp $(PX4_ROOT)/Build/px4io-v1_default.build/firmware.elf px4io-v1.elf
@ -136,7 +162,7 @@ px4-io-v1: $(PX4_ROOT)/Archives/px4io-v1.export
px4-io-v2: $(PX4_ROOT)/Archives/px4io-v2.export px4-io-v2: $(PX4_ROOT)/Archives/px4io-v2.export
$(v) make -C $(PX4_ROOT) px4io-v2_default $(v)+ $(MAKE) -C $(PX4_ROOT) -f $(PX4_ROOT)/Makefile.make px4io-v2_default
$(v) /bin/rm -f px4io-v2.bin $(v) /bin/rm -f px4io-v2.bin
$(v) cp $(PX4_ROOT)/Build/px4io-v2_default.build/firmware.bin px4io-v2.bin $(v) cp $(PX4_ROOT)/Build/px4io-v2_default.build/firmware.bin px4io-v2.bin
$(v) cp $(PX4_ROOT)/Images/px4io-v2_default.bin px4io-v2.bin $(v) cp $(PX4_ROOT)/Images/px4io-v2_default.bin px4io-v2.bin
@ -151,6 +177,20 @@ px4-io-v2: $(PX4_ROOT)/Archives/px4io-v2.export
px4-io: px4-io-v1 px4-io-v2 px4-io: px4-io-v1 px4-io-v2
# These targets can't run in parallel because they all need to generate a tool
# to generate the config.h inside them. This could trigger races if done in
# parallel, trying to generate the tool and replacing it while the header is already
# being generated
#
# We could serialize inside PX4Firmware, but it's easier to serialize here
# while maintaining the rest of the build parallelized
.NOTPARALLEL: \
$(PX4_ROOT)/Archives/px4fmu-v1.export \
$(PX4_ROOT)/Archives/px4fmu-v2.export \
$(PX4_ROOT)/Archives/px4fmu-v4.export \
$(PX4_ROOT)/Archives/px4io-v1.export \
$(PX4_ROOT)/Archives/px4io-v2.export
$(PX4_ROOT)/Archives/px4fmu-v1.export: $(PX4_ROOT)/Archives/px4fmu-v1.export:
$(v) $(PX4_MAKE_ARCHIVES) BOARDS="px4fmu-v1" $(v) $(PX4_MAKE_ARCHIVES) BOARDS="px4fmu-v1"
@ -158,6 +198,9 @@ $(PX4_ROOT)/Archives/px4fmu-v1.export:
$(PX4_ROOT)/Archives/px4fmu-v2.export: $(PX4_ROOT)/Archives/px4fmu-v2.export:
$(v) $(PX4_MAKE_ARCHIVES) BOARDS="px4fmu-v2" $(v) $(PX4_MAKE_ARCHIVES) BOARDS="px4fmu-v2"
$(PX4_ROOT)/Archives/px4fmu-v4.export:
$(v) $(PX4_MAKE_ARCHIVES) BOARDS="px4fmu-v4"
$(PX4_ROOT)/Archives/px4io-v1.export: $(PX4_ROOT)/Archives/px4io-v1.export:
$(v) $(PX4_MAKE_ARCHIVES) BOARDS="px4io-v1" $(v) $(PX4_MAKE_ARCHIVES) BOARDS="px4io-v1"
@ -165,4 +208,4 @@ $(PX4_ROOT)/Archives/px4io-v2.export:
$(v) $(PX4_MAKE_ARCHIVES) BOARDS="px4io-v2" $(v) $(PX4_MAKE_ARCHIVES) BOARDS="px4io-v2"
px4-archives: px4-archives:
$(v) $(PX4_MAKE_ARCHIVES) BOARDS="px4io-v1 px4io-v2 px4fmu-v1 px4fmu-v2" $(v) $(PX4_MAKE_ARCHIVES) BOARDS="px4io-v1 px4io-v2 px4fmu-v1 px4fmu-v2 px4fmu-v4"

View File

@ -2,7 +2,7 @@
# Sketch # Sketch
# #
SRCSUFFIXES = *.cpp *.c *.S SRCSUFFIXES = *.cpp
MAKE_INC=$(wildcard $(SRCROOT)/make.inc) MAKE_INC=$(wildcard $(SRCROOT)/make.inc)
ifeq (,$(MAKE_INC)) ifeq (,$(MAKE_INC))
@ -21,6 +21,53 @@ SKETCHOBJS := $(addsuffix .o,$(basename $(SKETCHOBJS)))
include $(MAKE_INC) include $(MAKE_INC)
LIBTOKENS := $(LIBRARIES) LIBTOKENS := $(LIBRARIES)
# HAL and board specific libraries are included here.
LIBTOKENS += \
AP_HAL \
AP_HAL_Empty
ifeq ($(HAL_BOARD),HAL_BOARD_APM1)
LIBTOKENS += \
AP_HAL_APM
endif
ifeq ($(HAL_BOARD),HAL_BOARD_APM2)
LIBTOKENS += \
AP_HAL_APM
endif
ifeq ($(HAL_BOARD),HAL_BOARD_SITL)
LIBTOKENS += \
AP_HAL_SITL \
SITL
endif
ifeq ($(HAL_BOARD),HAL_BOARD_LINUX)
LIBTOKENS += \
AP_HAL_Linux
endif
ifeq ($(HAL_BOARD),HAL_BOARD_PX4)
LIBTOKENS += \
AP_HAL_PX4
endif
ifeq ($(HAL_BOARD),HAL_BOARD_VRBRAIN)
LIBTOKENS += \
AP_HAL_VRBRAIN
endif
ifeq ($(HAL_BOARD),HAL_BOARD_FLYMAPLE)
LIBTOKENS += \
AP_HAL_FLYMAPLE
endif
ifeq ($(HAL_BOARD),HAL_BOARD_QURT)
LIBTOKENS += \
AP_HAL_QURT
endif
# #
# Find sketchbook libraries referenced by the sketch. # Find sketchbook libraries referenced by the sketch.
# #
@ -31,7 +78,7 @@ SKETCHLIBNAMES := $(notdir $(SKETCHLIBS))
SKETCHLIBSRCDIRS := $(SKETCHLIBS) $(addsuffix /utility,$(SKETCHLIBS)) SKETCHLIBSRCDIRS := $(SKETCHLIBS) $(addsuffix /utility,$(SKETCHLIBS))
SKETCHLIBSRCS := $(wildcard $(foreach suffix,$(SRCSUFFIXES),$(addsuffix /$(suffix),$(SKETCHLIBSRCDIRS)))) SKETCHLIBSRCS := $(wildcard $(foreach suffix,$(SRCSUFFIXES),$(addsuffix /$(suffix),$(SKETCHLIBSRCDIRS))))
SKETCHLIBOBJS := $(addsuffix .o,$(basename $(subst $(SKETCHBOOK),$(BUILDROOT),$(SKETCHLIBSRCS)))) SKETCHLIBOBJS := $(addsuffix .o,$(basename $(subst $(SKETCHBOOK),$(BUILDROOT),$(SKETCHLIBSRCS))))
SKETCHLIBINCLUDES := -I$(SKETCHBOOK)/libraries/ SKETCHLIBINCLUDES := -I$(SKETCHBOOK)/libraries/ -I$(BUILDROOT)/libraries/ -I$(BUILDROOT)/libraries/GCS_MAVLink/
SKETCHLIBSRCSRELATIVE := $(subst $(SKETCHBOOK)/,,$(SKETCHLIBSRCS)) SKETCHLIBSRCSRELATIVE := $(subst $(SKETCHBOOK)/,,$(SKETCHLIBSRCS))
ifeq ($(VERBOSE),) ifeq ($(VERBOSE),)

View File

@ -9,18 +9,8 @@ sitl-arm: HAL_BOARD = HAL_BOARD_SITL
sitl-arm: TOOLCHAIN = RPI sitl-arm: TOOLCHAIN = RPI
sitl-arm: all sitl-arm: all
apm1: HAL_BOARD = HAL_BOARD_APM1 apm1 apm1-1280 apm2 apm2beta:
apm1: TOOLCHAIN = AVR $(error $@ is deprecated on master branch; use master-AVR)
apm1: all
apm1-1280: HAL_BOARD = HAL_BOARD_APM1
apm1-1280: TOOLCHAIN = AVR
apm1-1280: all
apm1-1280: BOARD = mega
apm2: HAL_BOARD = HAL_BOARD_APM2
apm2: TOOLCHAIN = AVR
apm2: all
flymaple: HAL_BOARD = HAL_BOARD_FLYMAPLE flymaple: HAL_BOARD = HAL_BOARD_FLYMAPLE
flymaple: TOOLCHAIN = ARM flymaple: TOOLCHAIN = ARM
@ -32,9 +22,9 @@ linux: HAL_BOARD = HAL_BOARD_LINUX
linux: TOOLCHAIN = NATIVE linux: TOOLCHAIN = NATIVE
linux: all linux: all
erle: HAL_BOARD = HAL_BOARD_LINUX erleboard: HAL_BOARD = HAL_BOARD_LINUX
erle: TOOLCHAIN = BBONE erleboard: TOOLCHAIN = BBONE
erle: all erleboard: all
zynq: HAL_BOARD = HAL_BOARD_LINUX zynq: HAL_BOARD = HAL_BOARD_LINUX
zynq: TOOLCHAIN = ZYNQ zynq: TOOLCHAIN = ZYNQ
@ -48,20 +38,49 @@ pxf: all
bebop: HAL_BOARD = HAL_BOARD_LINUX bebop: HAL_BOARD = HAL_BOARD_LINUX
bebop: TOOLCHAIN = BBONE bebop: TOOLCHAIN = BBONE
bebop: LDFLAGS += "-static"
bebop: all bebop: all
minlure: HAL_BOARD = HAL_BOARD_LINUX
minlure: TOOLCHAIN = NATIVE
minlure: all
navio: HAL_BOARD = HAL_BOARD_LINUX navio: HAL_BOARD = HAL_BOARD_LINUX
navio: TOOLCHAIN = RPI navio: TOOLCHAIN = RPI
navio: all navio: all
raspilot: HAL_BOARD = HAL_BOARD_LINUX
raspilot: TOOLCHAIN = RPI
raspilot: all
erlebrain2: HAL_BOARD = HAL_BOARD_LINUX
erlebrain2: TOOLCHAIN = RPI
erlebrain2: all
bbbmini: HAL_BOARD = HAL_BOARD_LINUX bbbmini: HAL_BOARD = HAL_BOARD_LINUX
bbbmini: TOOLCHAIN = BBONE bbbmini: TOOLCHAIN = BBONE
bbbmini: all bbbmini: all
bhat: HAL_BOARD = HAL_BOARD_LINUX
bhat: TOOLCHAIN = RPI
bhat: all
qflight: HAL_BOARD = HAL_BOARD_LINUX
qflight: TOOLCHAIN = QFLIGHT
qflight: all
empty: HAL_BOARD = HAL_BOARD_EMPTY empty: HAL_BOARD = HAL_BOARD_EMPTY
empty: TOOLCHAIN = AVR empty: TOOLCHAIN = AVR
empty: all empty: all
qurt: HAL_BOARD = HAL_BOARD_QURT
qurt: TOOLCHAIN = QURT
qurt: all
pxfmini: HAL_BOARD = HAL_BOARD_LINUX
pxfmini: TOOLCHAIN = RPI
pxfmini: all
# cope with HIL targets # cope with HIL targets
%-hil: EXTRAFLAGS += "-DHIL_MODE=HIL_MODE_SENSORS " %-hil: EXTRAFLAGS += "-DHIL_MODE=HIL_MODE_SENSORS "
%-hilsensors: EXTRAFLAGS += "-DHIL_MODE=HIL_MODE_SENSORS " %-hilsensors: EXTRAFLAGS += "-DHIL_MODE=HIL_MODE_SENSORS "
@ -72,12 +91,16 @@ empty: all
# support debug build # support debug build
%-debug: OPTFLAGS = -g -O0 %-debug: OPTFLAGS = -g -O0
# support address sanitiser
%-asan: OPTFLAGS = -g -O0 -fsanitize=address -fno-omit-frame-pointer
%-asan: LDFLAGS += -fsanitize=address
# cope with -nologging # cope with -nologging
%-nologging: EXTRAFLAGS += "-DLOGGING_ENABLED=DISABLED " %-nologging: EXTRAFLAGS += "-DLOGGING_ENABLED=DISABLED "
# cope with copter and hil targets # cope with copter and hil targets
FRAMES = quad tri hexa y6 octa octa-quad heli single coax obc nologging FRAMES = quad tri hexa y6 octa octa-quad heli single coax obc nologging
BOARDS = apm1 apm2 apm2beta apm1-1280 px4 px4-v1 px4-v2 sitl flymaple linux vrbrain vrbrain-v40 vrbrain-v45 vrbrainv-50 vrbrain-v51 vrbrain-v52 vrubrain-v51 vrubrain-v52 vrhero-v10 erle pxf navio bbbmini BOARDS = apm1 apm2 apm2beta apm1-1280 px4 px4-v1 px4-v2 px4-v4 sitl flymaple linux vrbrain vrbrain-v40 vrbrain-v45 vrbrainv-50 vrbrain-v51 vrbrain-v52 vrubrain-v51 vrubrain-v52 vrhero-v10 erle pxf navio raspilot bbbmini minlure erlebrain2 bhat qflight pxfmini
define frame_template define frame_template
$(1)-$(2) : EXTRAFLAGS += "-DFRAME_CONFIG=$(shell echo $(2) | tr a-z A-Z | sed s/-/_/g)_FRAME " $(1)-$(2) : EXTRAFLAGS += "-DFRAME_CONFIG=$(shell echo $(2) | tr a-z A-Z | sed s/-/_/g)_FRAME "
@ -92,6 +115,7 @@ endef
define board_template define board_template
$(1)-hil : $(1) $(1)-hil : $(1)
$(1)-debug : $(1) $(1)-debug : $(1)
$(1)-asan : $(1)
$(1)-hilsensors : $(1) $(1)-hilsensors : $(1)
endef endef
@ -103,9 +127,6 @@ USED_FRAMES := $(foreach frame,$(FRAMES), $(findstring $(frame), $(MAKECMDGOALS)
$(foreach board,$(USED_BOARDS),$(eval $(call board_template,$(board)))) $(foreach board,$(USED_BOARDS),$(eval $(call board_template,$(board))))
$(foreach board,$(USED_BOARDS),$(foreach frame,$(USED_FRAMES),$(eval $(call frame_template,$(board),$(frame))))) $(foreach board,$(USED_BOARDS),$(foreach frame,$(USED_FRAMES),$(eval $(call frame_template,$(board),$(frame)))))
apm2beta: EXTRAFLAGS += "-DAPM2_BETA_HARDWARE "
apm2beta: apm2
sitl-mount: EXTRAFLAGS += "-DMOUNT=ENABLED" sitl-mount: EXTRAFLAGS += "-DMOUNT=ENABLED"
sitl-mount: sitl sitl-mount: sitl
@ -119,3 +140,4 @@ clean:
@rm -fr $(BUILDROOT) @rm -fr $(BUILDROOT)
include $(MK_DIR)/modules.mk include $(MK_DIR)/modules.mk
include $(MK_DIR)/mavgen.mk

11
mk/upload_firmware.mk Normal file
View File

@ -0,0 +1,11 @@
ifneq ($(BOARD_LINUX_HOST),)
upload: $(SKETCHELF).timestamp-upload
$(SKETCHELF).timestamp-upload: $(SKETCHELF)
scp $(SKETCHELF) $(BOARD_LINUX_HOST):
touch $@
else
upload:
@echo Check your config.mk: BOARD_LINUX_HOST should be defined to upload firmware
exit 1
endif