diff --git a/makefiles/firmware.mk b/makefiles/firmware.mk index 814bf8b8d6..5f5447da6b 100644 --- a/makefiles/firmware.mk +++ b/makefiles/firmware.mk @@ -363,6 +363,9 @@ endif ifeq ($(PX4_TARGET_OS),linux) include $(MK_DIR)/linux_elf.mk endif +ifeq ($(PX4_TARGET_OS),qurt) +include $(MK_DIR)/qurt_elf.mk +endif # # DEP_INCLUDES is defined by the toolchain include in terms of $(OBJS) diff --git a/makefiles/firmware_qurt.mk b/makefiles/firmware_qurt.mk new file mode 100644 index 0000000000..6acec4e733 --- /dev/null +++ b/makefiles/firmware_qurt.mk @@ -0,0 +1,56 @@ +# +# Copyright (c) 2012-2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +# +# Built products +# +FIRMWARES = $(foreach config,$(KNOWN_CONFIGS),$(BUILD_DIR)$(config).build/firmware.a) + +all: $(FIRMWARES) + +# +# Generate FIRMWARES. +# +.PHONY: $(FIRMWARES) +$(BUILD_DIR)%.build/firmware.a: config = $(patsubst $(BUILD_DIR)%.build/firmware.a,%,$@) +$(BUILD_DIR)%.build/firmware.a: work_dir = $(BUILD_DIR)$(config).build/ +$(FIRMWARES): $(BUILD_DIR)%.build/firmware.a: generateuorbtopicheaders + @$(ECHO) %%%% + @$(ECHO) %%%% Building $(config) in $(work_dir) + @$(ECHO) %%%% + $(Q) $(MKDIR) -p $(work_dir) + $(Q) $(MAKE) -r -C $(work_dir) \ + -f $(PX4_MK_DIR)firmware.mk \ + CONFIG=$(config) \ + WORK_DIR=$(work_dir) \ + $(FIRMWARE_GOAL) + + diff --git a/makefiles/qurt.mk b/makefiles/qurt.mk new file mode 100644 index 0000000000..919dcc4aba --- /dev/null +++ b/makefiles/qurt.mk @@ -0,0 +1,40 @@ +# +# Copyright (C) 2015 Mark Charlebois. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +# +# Rules and definitions related to handling the Linux specific impl when +# building firmware. +# + +MODULES += \ + platforms/common \ + platforms/linux/px4_layer + diff --git a/makefiles/qurt_elf.mk b/makefiles/qurt_elf.mk new file mode 100644 index 0000000000..701d731ef3 --- /dev/null +++ b/makefiles/qurt_elf.mk @@ -0,0 +1,73 @@ +# +# Copyright (C) 2012 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +# +# Makefile for PX4 Linux based firmware images. +# + +################################################################################ +# Build rules +################################################################################ + +# +# What we're going to build. +# +PRODUCT_SHARED_LIB = $(WORK_DIR)firmware.a +PRODUCT_SHARED_PRELINK = $(WORK_DIR)firmware.o + +.PHONY: firmware +firmware: $(PRODUCT_SHARED_LIB) $(WORK_DIR)mainapp + +# +# Built product rules +# + +$(PRODUCT_SHARED_PRELINK): $(OBJS) $(MODULE_OBJS) $(LIBRARY_LIBS) $(GLOBAL_DEPS) $(LINK_DEPS) $(MODULE_MKFILES) + $(call PRELINKF,$@,$(OBJS) $(MODULE_OBJS) $(LIBRARY_LIBS)) + +$(PRODUCT_SHARED_LIB): $(PRODUCT_SHARED_PRELINK) + $(call LINK_A,$@,$(PRODUCT_SHARED_PRELINK)) + +MAIN = $(PX4_BASE)/src/platforms/linux/main.cpp +$(WORK_DIR)mainapp: $(PRODUCT_SHARED_LIB) + $(PX4_BASE)/Tools/linux_apps.py > apps.h + $(call LINK,$@, -I. $(MAIN) $(PRODUCT_SHARED_LIB)) + +# +# Utility rules +# + +.PHONY: clean +clean: $(MODULE_CLEANS) + @$(ECHO) %% cleaning + $(Q) $(REMOVE) $(PRODUCT_ELF) + $(Q) $(REMOVE) $(OBJS) $(DEP_INCLUDES) $(EXTRA_CLEANS) + diff --git a/makefiles/setup.mk b/makefiles/setup.mk index d8ba1304c9..944b2018d8 100644 --- a/makefiles/setup.mk +++ b/makefiles/setup.mk @@ -33,11 +33,9 @@ # Path and tool setup # -ifdef ($(PX4_TARGET_OS),nuttx) -export PX4_TARGET_OS = nuttx -else -export PX4_TARGET_OS = linux -endif +#export PX4_TARGET_OS = nuttx +#export PX4_TARGET_OS = linux +export PX4_TARGET_OS ?= qurt # # Some useful paths. diff --git a/makefiles/toolchain_hexagon.mk b/makefiles/toolchain_hexagon.mk new file mode 100644 index 0000000000..6b3027684e --- /dev/null +++ b/makefiles/toolchain_hexagon.mk @@ -0,0 +1,304 @@ +# +# Copyright (C) 2015 Mark Charlebois. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +# +# Definitions for a generic GNU ARM-EABI toolchain +# + +#$(info TOOLCHAIN gnu-arm-eabi) + +# Toolchain commands. Normally only used inside this file. +# +HEXAGON_TOOLS_ROOT = /opt/6.4.05 +#V_ARCH = v4 # Set for APQ8064 +V_ARCH = v5 # Set for APQ8074 +CROSSDEV = hexagon- +HEXAGON_BIN = $(addsuffix /gnu/bin,$(HEXAGON_TOOLS_ROOT)) +HEXAGON_CLANG_BIN = $(addsuffix /qc/bin,$(HEXAGON_TOOLS_ROOT)) +HEXAGON_LIB_DIR = $(HEXAGON_TOOLS_ROOT)/gnu/hexagon/lib +HEXAGON_ISS_DIR = $(HEXAGON_TOOLS_ROOT)/qc/lib/iss + + +CC = $(HEXAGON_CLANG_BIN)/$(CROSSDEV)clang +CXX = $(HEXAGON_CLANG_BIN)/$(CROSSDEV)clang++ +CPP = $(HEXAGON_CLANG_BIN)/$(CROSSDEV)clang -E +LD = $(HEXAGON_BIN)/$(CROSSDEV)ld +AR = $(HEXAGON_BIN)/$(CROSSDEV)ar rcs +NM = $(HEXAGON_BIN)/$(CROSSDEV)nm +OBJCOPY = $(HEXAGON_BIN)/$(CROSSDEV)objcopy +OBJDUMP = $(HEXAGON_BIN)/$(CROSSDEV)objdump + +# Check if the right version of the toolchain is available +# +CROSSDEV_VER_SUPPORTED = 6.4.05 +CROSSDEV_VER_FOUND = $(shell $(CC) --version | sed -n 's/^.*version \([\. 0-9]*\),.*$$/\1/p') + +ifeq (,$(findstring $(CROSSDEV_VER_FOUND), $(CROSSDEV_VER_SUPPORTED))) +$(error Unsupported version of $(CC), found: $(CROSSDEV_VER_FOUND) instead of one in: $(CROSSDEV_VER_SUPPORTED)) +endif + + +# XXX this is pulled pretty directly from the fmu Make.defs - needs cleanup + +MAXOPTIMIZATION ?= -O2 + +# Base CPU flags for each of the supported architectures. +# +_CODE = $(addprefix -G,$(V_G_THRESHOLD)) +ARCHCPUFLAGS = -m$(V_ARCH) \ + -c \ + -G0 \ + $(_CODE) + + +# Set the board flags +# +ifeq ($(CONFIG_BOARD),) +$(error Board config does not define CONFIG_BOARD) +endif +ARCHDEFINES += -DCONFIG_ARCH_BOARD_$(CONFIG_BOARD) \ + -D__PX4_QURT \ + -I$(PX4_BASE)/src/lib/eigen \ + -I$(PX4_BASE)/src/platforms/qurt/include \ + -Wno-error=shadow + +# optimisation flags +# +ARCHOPTIMIZATION = $(MAXOPTIMIZATION) \ + -g3 \ + -fno-strict-aliasing \ + -fomit-frame-pointer \ + -funsafe-math-optimizations \ + -ffunction-sections \ + -fdata-sections + +# enable precise stack overflow tracking +# note - requires corresponding support in NuttX +INSTRUMENTATIONDEFINES = $(ARCHINSTRUMENTATIONDEFINES_$(CONFIG_ARCH)) + +# Language-specific flags +# +ARCHCFLAGS = -std=gnu99 +ARCHCXXFLAGS = -fno-exceptions -fno-rtti -std=gnu++0x -fno-threadsafe-statics -D__CUSTOM_FILE_IO__ + +# Generic warnings +# +ARCHWARNINGS = -Wall \ + -Wextra \ + -Werror \ + -Wno-cast-align \ + -Wno-missing-braces \ + -Wno-strict-aliasing +# -Werror=float-conversion - works, just needs to be phased in with some effort and needs GCC 4.9+ +# -Wcast-qual - generates spurious noreturn attribute warnings, try again later +# -Wconversion - would be nice, but too many "risky-but-safe" conversions in the code +# -Wcast-align - would help catch bad casts in some cases, but generates too many false positives + +# C-specific warnings +# +ARCHCWARNINGS = $(ARCHWARNINGS) \ + -Wstrict-prototypes \ + -Wnested-externs + +# C++-specific warnings +# +ARCHWARNINGSXX = $(ARCHWARNINGS) \ + -Wno-missing-field-initializers + +# pull in *just* libm from the toolchain ... this is grody +LIBM := $(shell $(CC) $(ARCHCPUFLAGS) -print-file-name=libm.a) +EXTRA_LIBS += $(LIBM) + +# Flags we pass to the C compiler +# +CFLAGS = $(ARCHCFLAGS) \ + $(ARCHCWARNINGS) \ + $(ARCHOPTIMIZATION) \ + $(ARCHCPUFLAGS) \ + $(ARCHINCLUDES) \ + $(INSTRUMENTATIONDEFINES) \ + $(ARCHDEFINES) \ + $(EXTRADEFINES) \ + $(EXTRACFLAGS) \ + -fno-common \ + $(addprefix -I,$(INCLUDE_DIRS)) + +# Flags we pass to the C++ compiler +# +CXXFLAGS = $(ARCHCXXFLAGS) \ + $(ARCHWARNINGSXX) \ + $(ARCHOPTIMIZATION) \ + $(ARCHCPUFLAGS) \ + $(ARCHXXINCLUDES) \ + $(INSTRUMENTATIONDEFINES) \ + $(ARCHDEFINES) \ + -DCONFIG_WCHAR_BUILTIN \ + $(EXTRADEFINES) \ + $(EXTRACXXFLAGS) \ + $(addprefix -I,$(INCLUDE_DIRS)) + +ifeq (1,$(V_dynamic)) +CXX_FLAGS += -fpic -D__V_DYNAMIC__ +endif + +HEXAGON_LIB_PATH=$(HEXAGON_TOOLS_ROOT)/gnu/hexagon/lib/$(V_ARCH)/G0 +LIB_HEXAGON =$(HEXAGON_TOOLS_ROOT)/qc/lib/$(V_ARCH)/G0/libhexagon.a + +# Flags we pass to the assembler +# +AFLAGS = $(CFLAGS) -D__ASSEMBLY__ \ + $(EXTRADEFINES) \ + $(EXTRAAFLAGS) + +# Flags we pass to the linker +# +LDFLAGS += \ + -Wl,--start-group -Wl,--whole-archive -lc -lgcc -lstdc++ \ + $(LIB_HEXAGON) -Wl,--no-whole-archive -Wl,--end-group -Wl,--dynamic-linker= \ + -Wl,-E -Wl,--force-dynamic \ + $(EXTRALDFLAGS) \ + $(addprefix -T,$(LDSCRIPT)) \ + $(addprefix -L,$(LIB_DIRS)) + +# Compiler support library +# +LIBGCC := $(shell $(CC) $(ARCHCPUFLAGS) -print-libgcc-file-name) + +# Files that the final link depends on +# +LINK_DEPS += $(LDSCRIPT) + +# Files to include to get automated dependencies +# +DEP_INCLUDES = $(subst .o,.d,$(OBJS)) + +# Compile C source $1 to object $2 +# as a side-effect, generate a dependency file +# +define COMPILE + @$(ECHO) "CC: $1" + @$(MKDIR) -p $(dir $2) + $(Q) $(CCACHE) $(CC) -MD -c $(CFLAGS) $(abspath $1) -o $2 +endef + +# Compile C++ source $1 to $2 +# as a side-effect, generate a dependency file +# +define COMPILEXX + @$(ECHO) "CXX: $1" + @$(MKDIR) -p $(dir $2) + $(Q) $(CCACHE) $(CXX) -MD -c $(CXXFLAGS) $(abspath $1) -o $2 +endef + +# Assemble $1 into $2 +# +define ASSEMBLE + @$(ECHO) "AS: $1" + @$(MKDIR) -p $(dir $2) + $(Q) $(CC) -c $(AFLAGS) $(abspath $1) -o $2 +endef + +# Produce partially-linked $1 from files in $2 +# +define PRELINK + @$(ECHO) "PRELINK: $1" + @$(MKDIR) -p $(dir $1) + $(Q) $(LD) -Ur -Map $1.map -o $1 $2 && $(OBJCOPY) --localize-hidden $1 +endef + +# Update the archive $1 with the files in $2 +# +define ARCHIVE + @$(ECHO) "AR: $2" + @$(MKDIR) -p $(dir $1) + $(Q) $(AR) $1 $2 +endef + +# Link the objects in $2 into the binary $1 +# +define LINK + @$(ECHO) "LINK: $1" + @$(MKDIR) -p $(dir $1) + $(Q) $(LD) $(LDFLAGS) -Map $1.map -o $1 --start-group $2 $(LIBS) $(EXTRA_LIBS) $(LIBGCC) --end-group +endef + +# Convert $1 from a linked object to a raw binary in $2 +# +define SYM_TO_BIN + @$(ECHO) "BIN: $2" + @$(MKDIR) -p $(dir $2) + $(Q) $(OBJCOPY) -O binary $1 $2 +endef + +# Take the raw binary $1 and make it into an object file $2. +# The symbol $3 points to the beginning of the file, and $3_len +# gives its length. +# +# - compile an empty file to generate a suitable object file +# - relink the object and insert the binary file +# - extract the length +# - create const unsigned $3_len with the extracted length as its value and compile it to an object file +# - link the two generated object files together +# - 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 + _binary_$(subst /,_,$(subst .,_,$1)) +endef +define BIN_TO_OBJ + @$(ECHO) "OBJ: $2" + @$(MKDIR) -p $(dir $2) + $(Q) $(ECHO) > $2.c + $(call COMPILE,$2.c,$2.c.o) + $(Q) $(LD) -r -o $2.bin.o $2.c.o -b binary $1 + $(Q) $(ECHO) "const unsigned int $3_len = 0x`$(NM) -p --radix=x $2.bin.o | $(GREP) $(call BIN_SYM_PREFIX,$1)_size$$ | $(GREP) -o ^[0-9a-fA-F]*`;" > $2.c + $(call COMPILE,$2.c,$2.c.o) + $(Q) $(LD) -r -o $2 $2.c.o $2.bin.o + $(Q) $(OBJCOPY) $2 \ + --redefine-sym $(call BIN_SYM_PREFIX,$1)_start=$3 \ + --strip-symbol $(call BIN_SYM_PREFIX,$1)_size \ + --strip-symbol $(call BIN_SYM_PREFIX,$1)_end \ + --rename-section .data=.rodata + $(Q) $(REMOVE) $2.c $2.c.o $2.bin.o +endef diff --git a/src/platforms/px4_defines.h b/src/platforms/px4_defines.h index 1cca8e55de..ba7ae4c3c2 100644 --- a/src/platforms/px4_defines.h +++ b/src/platforms/px4_defines.h @@ -67,7 +67,7 @@ /* Get value of parameter by name, which is equal to the handle for ros */ #define PX4_PARAM_GET_BYNAME(_name, _destpt) ros::param::get(_name, *_destpt) -#elif defined(__PX4_NUTTX) || defined(__PX4_LINUX) +#elif defined(__PX4_NUTTX) || defined(__PX4_LINUX) || defined(__PX4_QURT) /* * Building for NuttX or Linux */ @@ -134,7 +134,7 @@ __END_DECLS /* Defines for ROS and Linux */ -#if defined(__PX4_ROS) || defined(__PX4_LINUX) +#if defined(__PX4_ROS) || defined(__PX4_LINUX) || defined(__PX4_QURT) #define OK 0 #define ERROR -1 diff --git a/src/platforms/px4_includes.h b/src/platforms/px4_includes.h index 8af93b2b2a..97f5bc7d6e 100644 --- a/src/platforms/px4_includes.h +++ b/src/platforms/px4_includes.h @@ -102,7 +102,7 @@ #include #include -#elif defined(__PX4_LINUX) +#elif defined(__PX4_LINUX) || defined(__PX4_QURT) #include #include #include @@ -133,5 +133,5 @@ #include #include #else -#define "No target platform defined" +#error "No target platform defined" #endif diff --git a/src/platforms/px4_tasks.h b/src/platforms/px4_tasks.h index 28289f4e55..b81f7db6a7 100644 --- a/src/platforms/px4_tasks.h +++ b/src/platforms/px4_tasks.h @@ -49,7 +49,7 @@ typedef int px4_task_t; #define px4_task_exit(x) _exit(x) -#elif defined(__PX4_LINUX) +#elif defined(__PX4_LINUX) || defined(__PX4_QURT) #include #include diff --git a/src/platforms/qurt/include/arch/board/board.h b/src/platforms/qurt/include/arch/board/board.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/platforms/qurt/include/board_config.h b/src/platforms/qurt/include/board_config.h new file mode 100644 index 0000000000..a03b8c3e20 --- /dev/null +++ b/src/platforms/qurt/include/board_config.h @@ -0,0 +1,11 @@ +#define UDID_START 0x1FFF7A10 + +/* + * I2C busses + */ +#define PX4_I2C_BUS_ESC 1 +#define PX4_SIM_BUS_TEST 2 +#define PX4_I2C_BUS_EXPANSION 3 +#define PX4_I2C_BUS_LED 3 + +#define PX4_I2C_OBDEV_LED 0x55 diff --git a/src/platforms/qurt/include/crc32.h b/src/platforms/qurt/include/crc32.h new file mode 100644 index 0000000000..bf828e3e0e --- /dev/null +++ b/src/platforms/qurt/include/crc32.h @@ -0,0 +1,83 @@ +/**************************************************************************** + * include/crc.h + * + * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __INCLUDE_CRC32_H +#define __INCLUDE_CRC32_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Name: crc32part + * + * Description: + * Continue CRC calculation on a part of the buffer. + * + ****************************************************************************/ + +EXTERN uint32_t crc32part(const uint8_t *src, size_t len, + uint32_t crc32val); + +/**************************************************************************** + * Name: crc32 + * + * Description: + * Return a 32-bit CRC of the contents of the 'src' buffer, length 'len' + * + ****************************************************************************/ + +EXTERN uint32_t crc32(const uint8_t *src, size_t len); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* __INCLUDE_CRC32_H */ diff --git a/src/platforms/qurt/include/queue.h b/src/platforms/qurt/include/queue.h new file mode 100644 index 0000000000..4d95541e02 --- /dev/null +++ b/src/platforms/qurt/include/queue.h @@ -0,0 +1,135 @@ +/************************************************************************ + * include/queue.h + * + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************/ + +#ifndef __INCLUDE_QUEUE_H +#define __INCLUDE_QUEUE_H + +/************************************************************************ + * Included Files + ************************************************************************/ + +#include + +/************************************************************************ + * Pre-processor Definitions + ************************************************************************/ + +#define sq_init(q) do { (q)->head = NULL; (q)->tail = NULL; } while (0) +#define dq_init(q) do { (q)->head = NULL; (q)->tail = NULL; } while (0) + +#define sq_next(p) ((p)->flink) +#define dq_next(p) ((p)->flink) +#define dq_prev(p) ((p)->blink) + +#define sq_empty(q) ((q)->head == NULL) +#define dq_empty(q) ((q)->head == NULL) + +#define sq_peek(q) ((q)->head) +#define dq_peek(q) ((q)->head) + +// Required for Linux +#define FAR +#ifndef NULL +#define NULL (void *)0 +#endif + +/************************************************************************ + * Global Type Declarations + ************************************************************************/ + +struct sq_entry_s +{ + FAR struct sq_entry_s *flink; +}; +typedef struct sq_entry_s sq_entry_t; + +struct dq_entry_s +{ + FAR struct dq_entry_s *flink; + FAR struct dq_entry_s *blink; +}; +typedef struct dq_entry_s dq_entry_t; + +struct sq_queue_s +{ + FAR sq_entry_t *head; + FAR sq_entry_t *tail; +}; +typedef struct sq_queue_s sq_queue_t; + +struct dq_queue_s +{ + FAR dq_entry_t *head; + FAR dq_entry_t *tail; +}; +typedef struct dq_queue_s dq_queue_t; + +/************************************************************************ + * Global Function Prototypes + ************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +EXTERN void sq_addfirst(FAR sq_entry_t *node, sq_queue_t *queue); +EXTERN void dq_addfirst(FAR dq_entry_t *node, dq_queue_t *queue); +EXTERN void sq_addlast(FAR sq_entry_t *node, sq_queue_t *queue); +EXTERN void dq_addlast(FAR dq_entry_t *node, dq_queue_t *queue); +EXTERN void sq_addafter(FAR sq_entry_t *prev, FAR sq_entry_t *node, + sq_queue_t *queue); +EXTERN void dq_addafter(FAR dq_entry_t *prev, FAR dq_entry_t *node, + dq_queue_t *queue); +EXTERN void dq_addbefore(FAR dq_entry_t *next, FAR dq_entry_t *node, + dq_queue_t *queue); + +EXTERN FAR sq_entry_t *sq_remafter(FAR sq_entry_t *node, sq_queue_t *queue); +EXTERN void sq_rem(FAR sq_entry_t *node, sq_queue_t *queue); +EXTERN void dq_rem(FAR dq_entry_t *node, dq_queue_t *queue); +EXTERN FAR sq_entry_t *sq_remlast(sq_queue_t *queue); +EXTERN FAR dq_entry_t *dq_remlast(dq_queue_t *queue); +EXTERN FAR sq_entry_t *sq_remfirst(sq_queue_t *queue); +EXTERN FAR dq_entry_t *dq_remfirst(dq_queue_t *queue); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* __INCLUDE_QUEUE_H_ */ + diff --git a/src/platforms/qurt/main.cpp b/src/platforms/qurt/main.cpp new file mode 100644 index 0000000000..8ae5ee58d5 --- /dev/null +++ b/src/platforms/qurt/main.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** + * + * Copyright (C) 2015 Mark Charlebois. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ +/** + * @file main.cpp + * Basic shell to execute builtin "apps" + * + * @author Mark Charlebois + */ + +#include +#include +#include +#include +#include + +using namespace std; + +typedef int (*px4_main_t)(int argc, char *argv[]); + +#include "apps.h" +#include "px4_middleware.h" + +void run_cmd(const vector &appargs); +void run_cmd(const vector &appargs) { + // command is appargs[0] + string command = appargs[0]; + if (apps.find(command) != apps.end()) { + const char *arg[appargs.size()+2]; + + unsigned int i = 0; + while (i < appargs.size() && appargs[i] != "") { + arg[i] = (char *)appargs[i].c_str(); + ++i; + } + arg[i] = (char *)0; + apps[command](i,(char **)arg); + } + else + { + cout << "Invalid command" << endl; + list_builtins(); + } +} + +static void process_line(string &line) +{ + vector appargs(5); + + stringstream(line) >> appargs[0] >> appargs[1] >> appargs[2] >> appargs[3] >> appargs[4]; + run_cmd(appargs); +} + +int main(int argc, char **argv) +{ + // Execute a command list of provided + if (argc == 2) { + ifstream infile(argv[1]); + + for (string line; getline(infile, line, '\n'); ) { + process_line(line); + } + } + + string mystr; + + px4::init(argc, argv, "mainapp"); + + while(1) { + cout << "Enter a command and its args:" << endl; + getline (cin,mystr); + process_line(mystr); + mystr = ""; + } +} diff --git a/src/platforms/qurt/tests/hello/hello_example.cpp b/src/platforms/qurt/tests/hello/hello_example.cpp new file mode 100644 index 0000000000..a30aeb57bc --- /dev/null +++ b/src/platforms/qurt/tests/hello/hello_example.cpp @@ -0,0 +1,61 @@ + +/**************************************************************************** + * + * Copyright (C) 2015 Mark Charlebois. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/** + * @file hello_example.cpp + * Example for Linux + * + * @author Mark Charlebois + */ + +#include "hello_example.h" +#include +#include + +px4::AppState HelloExample::appState; + +int HelloExample::main() +{ + appState.setRunning(true); + + int i=0; + while (!appState.exitRequested() && i<5) { + sleep(2); + + printf(" Doing work...\n"); + ++i; + } + + return 0; +} diff --git a/src/platforms/qurt/tests/hello/hello_example.h b/src/platforms/qurt/tests/hello/hello_example.h new file mode 100644 index 0000000000..a4ae517056 --- /dev/null +++ b/src/platforms/qurt/tests/hello/hello_example.h @@ -0,0 +1,53 @@ +/**************************************************************************** + * + * Copyright (C) 2015 Mark Charlebois. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/** + * @file hello_example.h + * Example app for Linux + * + * @author Mark Charlebois + */ +#pragma once + +#include + +class HelloExample { +public: + HelloExample() {}; + + ~HelloExample() {}; + + int main(); + + static px4::AppState appState; /* track requests to terminate app */ +}; diff --git a/src/platforms/qurt/tests/hello/hello_main.cpp b/src/platforms/qurt/tests/hello/hello_main.cpp new file mode 100644 index 0000000000..69e8c21ec0 --- /dev/null +++ b/src/platforms/qurt/tests/hello/hello_main.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** + * + * Copyright (C) 2015 Mark Charlebois. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/** + * @file hello_main.cpp + * Example for Linux + * + * @author Mark Charlebois + */ +#include +#include +#include "hello_example.h" +#include + +int PX4_MAIN(int argc, char **argv) +{ + px4::init(argc, argv, "hello"); + + printf("hello\n"); + HelloExample hello; + hello.main(); + + printf("goodbye\n"); + return 0; +} diff --git a/src/platforms/qurt/tests/hello/hello_start_linux.cpp b/src/platforms/qurt/tests/hello/hello_start_linux.cpp new file mode 100644 index 0000000000..240c5d845e --- /dev/null +++ b/src/platforms/qurt/tests/hello/hello_start_linux.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** + * + * Copyright (C) 2015 Mark Charlebois. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/** + * @file hello_start_linux.cpp + * + * @author Thomas Gubler + * @author Mark Charlebois + */ +#include "hello_example.h" +#include +#include +#include +#include +#include + +#define SCHED_DEFAULT SCHED_FIFO +#define SCHED_PRIORITY_MAX sched_get_priority_max(SCHED_FIFO) +#define SCHED_PRIORITY_DEFAULT sched_get_priority_max(SCHED_FIFO) + +static int daemon_task; /* Handle of deamon task / thread */ + +//using namespace px4; + +extern "C" __EXPORT int hello_main(int argc, char *argv[]); +int hello_main(int argc, char *argv[]) +{ + + if (argc < 2) { + printf("usage: hello {start|stop|status}\n"); + return 1; + } + + if (!strcmp(argv[1], "start")) { + + if (HelloExample::appState.isRunning()) { + printf("already running\n"); + /* this is not an error */ + return 0; + } + + daemon_task = px4_task_spawn_cmd("hello", + SCHED_DEFAULT, + SCHED_PRIORITY_MAX - 5, + 2000, + PX4_MAIN, + (argv) ? (char* const*)&argv[2] : (char* const*)NULL); + + return 0; + } + + if (!strcmp(argv[1], "stop")) { + HelloExample::appState.requestExit(); + return 0; + } + + if (!strcmp(argv[1], "status")) { + if (HelloExample::appState.isRunning()) { + printf("is running\n"); + + } else { + printf("not started\n"); + } + + return 0; + } + + printf("usage: hello_main {start|stop|status}\n"); + return 1; +} diff --git a/src/platforms/qurt/tests/hello/module.mk b/src/platforms/qurt/tests/hello/module.mk new file mode 100644 index 0000000000..730f9189e7 --- /dev/null +++ b/src/platforms/qurt/tests/hello/module.mk @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2014 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +# +# Publisher Example Application +# + +MODULE_COMMAND = hello + +SRCS = hello_main.cpp \ + hello_start_linux.cpp \ + hello_example.cpp +