initial board and platform support for the ModalAI VOXL 2 (POSIX + QuRT)

This commit is contained in:
Eric Katzfey 2022-09-23 09:03:05 -07:00 committed by GitHub
parent e6b292b693
commit d30ccb2b1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 1599 additions and 9 deletions

View File

@ -0,0 +1,91 @@
# PX4 on VOXL 2
VOXL 2 from ModalAI can be used as a companion computer to a flight control board
but it can also run PX4 directly.
## Overview
When running PX4 directly on the QRB5165 SoC it runs partially on the Sensor Low Power Island (SLPI) DSP (aka sdsp) and partially on the application processor (ARM64 / aarch64).
The portion running on the DSP hosts the flight critical portions of PX4 such as
the IMU, barometer, magnetometer, GPS, ESC, and power management drivers, and the
state estimation. The DSP acts as the real time portion of the system. Non flight
critical applications such as Mavlink, logging, and commander are running on the
ARM CPU cluster (aka apps proc). The DSP and ARM CPU cluster communicate via a
Qualcomm proprietary shared memory interface.
## Build environment
In order to build for this platform both the Qualcomm Hexagon (DSP) toolchain and the Linaro ARM64 toolchain need to be installed. The (nearly) complete setup including the ARM64 toolchain is provided in the base Docker image provided by ModalAI, but since ModalAI is not allowed to redistribute the Qualcomm Hexagon DSP SDK this must be added by the end user.
The full instructions are available here:
- https://gitlab.com/voxl-public/rb5-flight/rb5-flight-px4-build-docker
## Build overview
- Clone the repo (Don't forget to update and initialize all submodules)
- In the top level directory
```
px4$ boards/modalai/voxl2/run-docker.sh
root@9373fa1401b8:/usr/local/workspace# boards/modalai/voxl2/clean.sh
root@9373fa1401b8:/usr/local/workspace# boards/modalai/voxl2/build-posix.sh
root@9373fa1401b8:/usr/local/workspace# boards/modalai/voxl2/build-qurt.sh
root@9373fa1401b8:/usr/local/workspace# exit
```
## Install and run on VOXL 2
Once the DSP and Linux images have been built they can be installed on a VOXL 2
board using ADB. There is a script to do this.
```
px4$ boards/modalai/voxl2/install-voxl.sh
```
## Running PX4 on VOXL 2
After installing PX4 on the board, open a terminal on VOXL 2 using ADB shell.
PX4 can be run using a start script.
```
root@m0054:/# voxl-px4
Found DSP signature file
/
INFO [px4] mlockall() enabled. PX4's virtual address space is locked into RAM.
INFO [px4] assuming working directory is rootfs, no symlinks needed.
______ __ __ ___
| ___ \ \ \ / / / |
| |_/ / \ V / / /| |
| __/ / \ / /_| |
| | / /^\ \ \___ |
\_| \/ \/ |_/
px4 starting.
INFO [px4] Calling startup script: /bin/sh /etc/modalai/voxl-px4.config 0
INFO [muorb] muorb protobuf initalize method succeeded
INFO [px4] Startup script returned successfully
pxh>
```
## Tips
Start with a VOXL 2 that only has the system image installed, not the SDK
In order to see DSP specific debug messages the mini-dm tool in the Hexagon SDK
can be used:
```
modalai@modalai-XPS-15-9570:/local/mnt/workspace/Qualcomm/Hexagon_SDK/4.1.0.4/tools/debug/mini-dm/Ubuntu18$ sudo ./mini-dm
[sudo] password for modalai:
Running mini-dm version: 3.2
Completed processing command line ---
Connecting to the only usbport connected
mini-dm is waiting for a DMSS connection...
DMSS is connected. Running mini-dm...
------------Mini-dm is ready to log-------------
[08500/02] 06:21.030 0069:01: SDSP: Creating new instance. 0355 sns_flight_controller_sensor.
[08500/02] 06:21.030 0069:01: SDSP: Creating data streams 0292 sns_flight_controller_sensor_
[08500/02] 06:21.030 0069:01: SDSP: Configuring devices 0305 sns_flight_controller_sensor_
[08500/02] 06:21.030 0069:01: SDSP: Flight controller sensor instance initialized 0344 sns_flight_controller_sensor_
[08500/01] 06:21.092 0069:01: SDSP: Hello, world! 0000 test
[08500/02] 06:21.092 006a:01: SDSP: CPU Utilization: 0.04, wait percentage 99.94 0162 sns_flight_controller_sensor.
[08500/02] 06:21.092 006a:01: SDSP: Got interrupt registered event 0082 sns_flight_controller_sensor_
```

View File

@ -0,0 +1,12 @@
#!/bin/bash
echo "*** Starting posix build ***"
source /home/build-env.sh
make modalai_voxl2_default
cat build/modalai_voxl2_default/src/lib/version/build_git_version.h
echo "*** End of posix build ***"

View File

@ -0,0 +1,11 @@
#!/bin/bash
echo "*** Starting qurt build ***"
source /home/build-env.sh
make modalai_voxl2_qurt
cat build/modalai_voxl2_default/src/lib/version/build_git_version.h
echo "*** End of qurt build ***"

5
boards/modalai/voxl2/clean.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
# Clean out the build artifacts
source /home/build-env.sh
make clean

View File

@ -0,0 +1,54 @@
############################################################################
#
# Copyright (c) 2022 ModalAI, Inc. 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.
#
############################################################################
#
# Overview:
# Voxl2 PX4 is built in 2 parts, the part that runs on the
# application (apps) processor, and the library that is loaded on the DSP.
#
############################################################################
include(px4_git)
list(APPEND CMAKE_MODULE_PATH
"${PX4_SOURCE_DIR}/platforms/posix/cmake"
)
# set(DISABLE_PARAMS_MODULE_SCOPING TRUE)
add_definitions(-DORB_COMMUNICATOR)
set(CONFIG_PARAM_SERVER "1")
add_definitions( -D__PX4_LINUX )
include(CMakeParseArguments)

View File

@ -0,0 +1,43 @@
############################################################################
#
# Copyright (c) 2022 ModalAI, Inc. All rights reserved.
#
############################################################################
#
# This cmake config builds for QURT which is the operating system running on
# the DSP side of VOXL 2
#
# Required environment variables:
# HEXAGON_TOOLS_ROOT
# HEXAGON_SDK_ROOT
#
############################################################################
if ("$ENV{HEXAGON_SDK_ROOT}" STREQUAL "")
message(FATAL_ERROR "Enviroment variable HEXAGON_SDK_ROOT must be set")
else()
set(HEXAGON_SDK_ROOT $ENV{HEXAGON_SDK_ROOT})
endif()
if ("$ENV{HEXAGON_TOOLS_ROOT}" STREQUAL "")
message(FATAL_ERROR "Environment variable HEXAGON_TOOLS_ROOT must be set")
else()
set(HEXAGON_TOOLS_ROOT $ENV{HEXAGON_TOOLS_ROOT})
endif()
include(px4_git)
list(APPEND CMAKE_MODULE_PATH
"${PX4_SOURCE_DIR}/platforms/qurt/cmake"
)
include(Toolchain-qurt)
include(qurt_reqs)
include_directories(${HEXAGON_SDK_INCLUDES})
add_definitions(-DORB_COMMUNICATOR)
set(CONFIG_PARAM_CLIENT "1")
set(DISABLE_PARAMS_MODULE_SCOPING TRUE)

View File

@ -0,0 +1,4 @@
CONFIG_PLATFORM_POSIX=y
CONFIG_BOARD_LINUX=y
CONFIG_BOARD_TOOLCHAIN="aarch64-linux-gnu"
CONFIG_MODULES_MUORB_APPS=y

View File

@ -0,0 +1,19 @@
#!/bin/bash
# Push qurt image to voxl2
adb push build/modalai_voxl2_qurt/platforms/qurt/libpx4.so /usr/lib/rfsa/adsp
# Push posix image to voxl2
adb push build/modalai_voxl2_default/bin/px4 /usr/bin
# Push scripts to voxl2
adb push build/modalai_voxl2_default/bin/px4-alias.sh /usr/bin
adb push boards/modalai/voxl2/voxl-px4 /usr/bin
adb shell chmod a+x /usr/bin/px4-alias.sh
adb shell chmod a+x /usr/bin/voxl-px4
# Push configuration file
adb shell mkdir -p /etc/modalai
adb push boards/modalai/voxl2/voxl-px4.config /etc/modalai
adb shell sync

View File

@ -0,0 +1,3 @@
CONFIG_PLATFORM_QURT=y
CONFIG_BOARD_TOOLCHAIN="qurt"
CONFIG_MODULES_MUORB_SLPI=y

View File

@ -0,0 +1,4 @@
#!/bin/bash
# Run this from the px4 project top level directory
docker run -it --rm -v `pwd`:/usr/local/workspace rb5-flight-px4-build-docker

View File

@ -0,0 +1,37 @@
############################################################################
#
# Copyright (c) 2022 ModalAI, Inc. 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.
#
############################################################################
add_library(drivers_board
board_config.h
init.c
)

View File

@ -0,0 +1,51 @@
/****************************************************************************
*
* Copyright (c) 2022 ModalAI, Inc. 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 board_config.h
*
* VOXL2 internal definitions
*/
#pragma once
#define BOARD_HAS_NO_RESET
#define BOARD_HAS_NO_BOOTLOADER
/*
* I2C buses
*/
#define PX4_NUMBER_I2C_BUSES 3
#include <system_config.h>
#include <px4_platform_common/board_common.h>

View File

@ -0,0 +1,35 @@
/****************************************************************************
*
* Copyright (C) 2022 ModalAI, Inc. 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.
*
****************************************************************************/
#include "board_config.h"
// Place holder for VOXL2-specific early startup code

View File

@ -0,0 +1,36 @@
#!/bin/bash
# Make sure that the SLPI DSP test signature is there otherwise px4 cannot run
# on the DSP
if /bin/ls /usr/lib/rfsa/adsp/testsig-*.so &> /dev/null; then
/bin/echo "Found DSP signature file"
else
/bin/echo "Error, could not find DSP signature file"
# Look for the DSP signature generation script
if [ -f /share/modalai/qrb5165-slpi-test-sig/generate-test-sig.sh ]; then
/bin/echo "Attempting to generate the DSP signature file"
# Automatically generate the test signature so that px4 can run on SLPI DSP
/share/modalai/qrb5165-slpi-test-sig/generate-test-sig.sh
else
/bin/echo "Could not find the DSP signature file generation script"
fi
exit 0
fi
# Make sure to setup all of the needed px4 aliases.
cd /usr/bin
/bin/ln -f -s px4 px4-muorb
/bin/ln -f -s px4 px4-uorb
cd -
DAEMON=" "
while getopts "d" flag
do
case "${flag}" in
# Use -d to put PX4 into daemon mode
d) DAEMON="-d";;
esac
done
px4 $DAEMON -s /etc/modalai/voxl-px4.config

View File

@ -0,0 +1,6 @@
#!/bin/sh
# PX4 commands need the 'px4-' prefix in bash.
# (px4-alias.sh is expected to be in the PATH)
. px4-alias.sh
muorb start

View File

@ -34,7 +34,7 @@ if(EXISTS ${BOARD_DEFCONFIG})
# Depend on BOARD_DEFCONFIG so that we reconfigure on config change
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${BOARD_DEFCONFIG})
if(${LABEL} MATCHES "default" OR ${LABEL} MATCHES "recovery" OR ${LABEL} MATCHES "bootloader" OR ${LABEL} MATCHES "canbootloader")
if(${LABEL} MATCHES "default" OR ${LABEL} MATCHES "qurt" OR ${LABEL} MATCHES "recovery" OR ${LABEL} MATCHES "bootloader" OR ${LABEL} MATCHES "canbootloader")
# Generate boardconfig from saved defconfig
execute_process(COMMAND ${CMAKE_COMMAND} -E env ${COMMON_KCONFIG_ENV_SETTINGS}
${DEFCONFIG_PATH} ${BOARD_DEFCONFIG}
@ -228,6 +228,10 @@ if(EXISTS ${BOARD_DEFCONFIG})
# platform-specific include path
include_directories(${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/src/px4/common/include)
if(PLATFORM STREQUAL "qurt")
include(${PX4_SOURCE_DIR}/boards/modalai/voxl2/cmake/voxl2_qurt.cmake)
endif()
endif()
if(ARCHITECTURE)

View File

@ -44,7 +44,11 @@ function(px4_add_library target)
target_compile_definitions(${target} PRIVATE MODULE_NAME="${target}")
# all PX4 libraries have access to parameters and uORB
add_dependencies(${target} uorb_headers parameters)
# TODO: Exclusion of qurt is temporary until these modules
# build cleanly.
if(NOT ${PLATFORM} MATCHES "qurt")
add_dependencies(${target} uorb_headers parameters)
endif()
target_link_libraries(${target} PRIVATE prebuild_targets)
set_property(GLOBAL APPEND PROPERTY PX4_MODULE_PATHS ${CMAKE_CURRENT_SOURCE_DIR})

View File

@ -409,7 +409,7 @@ public:
* @param instance ORB instance
* @return OK if the topic exists, PX4_ERROR otherwise.
*/
static int orb_exists(const struct orb_metadata *meta, int instance);
int orb_exists(const struct orb_metadata *meta, int instance);
/**
* Set the minimum interval between which updates are seen for a subscription.

View File

@ -101,6 +101,14 @@ endif()
if("${PX4_BOARD}" MATCHES "beaglebone_blue")
target_link_libraries(px4 PRIVATE robotics_cape)
elseif("${PX4_BOARD}" MATCHES "modalai_voxl2")
# libfc_sensor.so is provided in the Docker build environment
target_link_libraries(px4 PRIVATE
/home/libfc_sensor.so
px4_layer
${module_libraries}
)
elseif("${PX4_BOARD}" MATCHES "emlid_navio2")
target_link_libraries(px4 PRIVATE atomic)

View File

@ -1,13 +1,22 @@
# arm-linux-gnueabihf-gcc toolchain
set(triple aarch64-linux-gnu)
if("${PX4_BOARD}" MATCHES "modalai_voxl2")
set(CMAKE_LIBRARY_ARCHITECTURE ${ARM_CROSS_GCC_ROOT}/bin/${triple})
set(TOOLCHAIN_PREFIX ${ARM_CROSS_GCC_ROOT}/bin/${triple})
set(ARM_CROSS_GCC_ROOT $ENV{ARM_CROSS_GCC_ROOT})
set(HEXAGON_ARM_SYSROOT $ENV{HEXAGON_ARM_SYSROOT})
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-gc-sections -Wl,-rpath-link,${HEXAGON_ARM_SYSROOT}/usr/lib/aarch64-linux-gnu -Wl,-rpath-link,${HEXAGON_ARM_SYSROOT}/lib/aarch64-linux-gnu")
else()
set(CMAKE_LIBRARY_ARCHITECTURE ${triple})
set(TOOLCHAIN_PREFIX ${triple})
endif()
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_SYSTEM_VERSION 1)
set(triple aarch64-linux-gnu)
set(CMAKE_LIBRARY_ARCHITECTURE ${triple})
set(TOOLCHAIN_PREFIX ${triple})
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_C_COMPILER_TARGET ${triple})

View File

@ -0,0 +1,41 @@
############################################################################
#
# Copyright (c) 2022 ModalAI, Inc. 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.
#
############################################################################
set(module_libraries modules__muorb__slpi)
QURT_LIB(LIB_NAME px4
SOURCES
${PX4_SOURCE_DIR}/platforms/qurt/unresolved_symbols.c
LINK_LIBS
${module_libraries}
)

View File

@ -0,0 +1,71 @@
#
# Copyright (c) 2022 ModalAI, Inc. 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 ATLFlight 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.
#
include(CMakeForceCompiler)
set(V_ARCH "v66")
set(CROSSDEV "hexagon-")
set(HEXAGON_BIN ${HEXAGON_TOOLS_ROOT}/bin)
set(CMAKE_C_COMPILER ${HEXAGON_BIN}/${CROSSDEV}clang)
set(CMAKE_CXX_COMPILER ${HEXAGON_BIN}/${CROSSDEV}clang++)
set(CMAKE_AR ${HEXAGON_BIN}/${CROSSDEV}ar CACHE FILEPATH "Archiver")
SET(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> qcD <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qcD <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_RANLIB ${HEXAGON_BIN}/${CROSSDEV}ranlib)
set(CMAKE_OBJDUMP ${HEXAGON_BIN}/${CROSSDEV}objdump)
set(CMAKE_OBJCOPY ${HEXAGON_BIN}/${CROSSDEV}objcopy)
set(HEXAGON_LINK ${HEXAGON_BIN}/${CROSSDEV}link)
set(HEXAGON_ARCH_FLAGS
-march=hexagon
-mcpu=hexagonv66)
set(CMAKE_SKIP_RPATH TRUE CACHE BOOL SKIP_RPATH FORCE)
# where is the target environment
set(CMAKE_FIND_ROOT_PATH get_file_component(${C_COMPILER} PATH))
set(CMAKE_C_COMPILER_ID, "Clang")
set(CMAKE_CXX_COMPILER_ID, "Clang")
# search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
macro(__linux_compiler_gnu lang)
set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "")
endmacro()

View File

@ -0,0 +1,185 @@
############################################################################
#
# Copyright (c) 2022 ModalAI, Inc. 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.
#
############################################################################
#=============================================================================
#
# Defined functions in this file
#
# OS Specific Functions
#
# * px4_qurt_generate_builtin_commands
#
# Required OS Inteface Functions
#
# * px4_os_add_flags
# * px4_os_determine_build_chip
# * px4_os_prebuild_targets
#
#=============================================================================
#
# px4_qurt_generate_builtin_commands
#
# This function generates the builtin_commands.c src for qurt
#
# Usage:
# px4_qurt_generate_builtin_commands(
# MODULE_LIST <in-list>
# OUT <file>)
#
# Input:
# MODULE_LIST : list of modules
#
# Output:
# OUT : stem of generated apps.cpp/apps.h ("apps").
#
# Example:
# px4_qurt_generate_builtin_commands(
# OUT <generated-src> MODULE_LIST px4_simple_app)
#
function(px4_qurt_generate_builtin_commands)
px4_parse_function_args(
NAME px4_qurt_generate_builtin_commands
ONE_VALUE OUT
MULTI_VALUE MODULE_LIST
REQUIRED MODULE_LIST OUT
ARGN ${ARGN})
set(builtin_apps_string)
set(builtin_apps_decl_string)
set(command_count 0)
foreach(module ${MODULE_LIST})
foreach(property MAIN STACK_MAIN PRIORITY)
get_target_property(${property} ${module} ${property})
endforeach()
if (MAIN)
set(builtin_apps_string
"${builtin_apps_string}\tapps[\"${MAIN}\"] = ${MAIN}_main;\n")
set(builtin_apps_decl_string
"${builtin_apps_decl_string}int ${MAIN}_main(int argc, char *argv[]);\n")
math(EXPR command_count "${command_count}+1")
endif()
endforeach()
configure_file(${PX4_SOURCE_DIR}/platforms/common/apps.cpp.in ${OUT}.cpp)
configure_file(${PX4_SOURCE_DIR}/platforms/common/apps.h.in ${OUT}.h)
endfunction()
#=============================================================================
#
# px4_os_add_flags
#
# Set the qurt build flags.
#
# Usage:
# px4_os_add_flags()
#
function(px4_os_add_flags)
set(DSPAL_ROOT platforms/qurt/dspal)
include_directories(
${DSPAL_ROOT}/include
${DSPAL_ROOT}/sys
${DSPAL_ROOT}/sys/sys
platforms/posix/include
platforms/qurt/include
)
add_definitions(
-D__PX4_POSIX
-D__PX4_QURT
)
add_compile_options(
-fPIC
-fmath-errno
-Wno-unknown-warning-option
-Wno-cast-align
)
# Clear -rdynamic flag which fails for hexagon
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
endfunction()
#=============================================================================
#
# px4_os_determine_build_chip
#
# Sets PX4_CHIP and PX4_CHIP_MANUFACTURER.
#
# Usage:
# px4_os_determine_build_chip()
#
function(px4_os_determine_build_chip)
# always use generic chip and chip manufacturer
set(PX4_CHIP "generic" CACHE STRING "PX4 Chip" FORCE)
set(PX4_CHIP_MANUFACTURER "generic" CACHE STRING "PX4 Chip Manufacturer" FORCE)
endfunction()
#=============================================================================
#
# px4_os_prebuild_targets
#
# This function generates os dependent targets
#
# Usage:
# px4_os_prebuild_targets(
# OUT <out-list_of_targets>
# BOARD <in-string>
# )
#
# Input:
# BOARD : board
#
# Output:
# OUT : the target list
#
# Example:
# px4_os_prebuild_targets(OUT target_list BOARD px4_fmu-v2)
#
function(px4_os_prebuild_targets)
px4_parse_function_args(
NAME px4_os_prebuild_targets
ONE_VALUE OUT BOARD
REQUIRED OUT
ARGN ${ARGN})
add_library(prebuild_targets INTERFACE)
add_dependencies(prebuild_targets DEPENDS uorb_headers)
endfunction()

View File

@ -0,0 +1,222 @@
############################################################################
#
# Copyright (c) 2022 ModalAI, Inc. 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.
#
############################################################################
set(HEXAGON_SDK_INCLUDES
${HEXAGON_SDK_ROOT}/incs
${HEXAGON_SDK_ROOT}/incs/stddef
${HEXAGON_SDK_ROOT}/rtos/qurt/computev66/include/qurt
# ${HEXAGON_SDK_ROOT}/rtos/qurt/computev66/include/posix
${HEXAGON_SDK_ROOT}/tools/HEXAGON_Tools/8.4.05/Tools/target/hexagon/include
)
set(TOOLSLIB ${HEXAGON_TOOLS_ROOT}/target/hexagon/lib/${V_ARCH}/G0/pic)
set(HEXAGON_ARCH_FLAGS
-march=hexagon
-mcpu=hexagon${V_ARCH}
)
macro (list2string out in)
set(list ${ARGV})
list(REMOVE_ITEM list ${out})
foreach(item ${list})
set(${out} "${${out}} ${item}")
endforeach()
endmacro(list2string)
set(HEXAGON_START_LINK_FLAGS)
list2string(HEXAGON_START_LINK_FLAGS
${HEXAGON_ARCH_FLAGS}
-shared
-call_shared
-G0
${TOOLSLIB}/initS.o
"-o <TARGET>"
-L${TOOLSLIB}
-Bsymbolic
${TOOLSLIB}/libgcc.a
--wrap=malloc
--wrap=calloc
--wrap=free
--wrap=realloc
--wrap=memalign
--wrap=__stack_chk_fail
-lc
"-soname=<TARGET_SONAME>"
)
set(HEXAGON_END_LINK_FLAGS)
list2string(HEXAGON_END_LINK_FLAGS
--start-group
-lgcc
--end-group
${TOOLSLIB}/finiS.o
)
set(CMAKE_C_CREATE_SHARED_LIBRARY
"${HEXAGON_LINK} ${HEXAGON_START_LINK_FLAGS} --start-group --whole-archive <OBJECTS> <LINK_LIBRARIES> --end-group ${HEXAGON_END_LINK_FLAGS}")
set(CMAKE_CXX_CREATE_SHARED_LIBRARY
"${HEXAGON_LINK} ${HEXAGON_START_LINK_FLAGS} --start-group ${TOOLSLIB}/libc++.so.1 ${TOOLSLIB}/libc++abi.so.1 ${HEXAGON_SDK_ROOT}/libs/weak_refs/ship/hexagon_toolv84/weak_refs.so --end-group --start-group --whole-archive <OBJECTS> <LINK_LIBRARIES> --end-group ${HEXAGON_END_LINK_FLAGS}")
set(DYNAMIC_LIBS -Wl,${TOOLSLIB}/libc++.a)
# Base CPU flags for each of the supported architectures.
set(ARCHCPUFLAGS
-m${V_ARCH}
-G0
)
add_definitions(
-D __QURT
-D _PROVIDE_POSIX_TIME_DECLS
-D _TIMER_T
-D _HAS_C9X
-D restrict=__restrict__
-D noreturn_function=
)
# Language-specific flags
set(ARCHCFLAGS
-D__CUSTOM_FILE_IO__
)
set(ARCHCXXFLAGS
-DCONFIG_WCHAR_BUILTIN
-D__CUSTOM_FILE_IO__
)
exec_program(${CMAKE_CXX_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR} ARGS -print-libgcc-file-name OUTPUT_VARIABLE LIBGCC)
exec_program(${CMAKE_CXX_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR} ARGS -print-file-name=libm.a OUTPUT_VARIABLE LIBM)
set(EXTRA_LIBS ${EXTRA_LIBS} ${LIBM})
# Full optimization and Link Time Optimization (LTO)
set(QURT_OPTIMIZATION_FLAGS -O3 -flto)
# Flags we pass to the C compiler
list2string(CFLAGS
${ARCHCFLAGS}
${ARCHCPUFLAGS}
${QURT_OPTIMIZATION_FLAGS}
${HEXAGON_INCLUDE_DIRS}
)
# Flags we pass to the C++ compiler
list2string(CXXFLAGS
-Wno-inconsistent-missing-override
${ARCHCXXFLAGS}
${ARCHCPUFLAGS}
${QURT_OPTIMIZATION_FLAGS}
${HEXAGON_INCLUDE_DIRS}
)
# Set cmake flags
list2string(QURT_CMAKE_C_FLAGS
${CMAKE_C_FLAGS}
${CFLAGS}
)
set(CMAKE_C_FLAGS "${QURT_CMAKE_C_FLAGS}")
list2string(QURT_CMAKE_CXX_FLAGS
${CMAKE_CXX_FLAGS}
${CXXFLAGS}
)
set(CMAKE_CXX_FLAGS ${QURT_CMAKE_CXX_FLAGS})
# Flags we pass to the linker
# CMake make test builds of apps to validate the compiler
# These settings enable CMake to build the required test apps
list2string(CMAKE_EXE_LINKER_FLAGS
-m${V_ARCH}
-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
${DYNAMIC_LIBS}
-lc
${EXTRALDFLAGS}
)
include (CMakeParseArguments)
# Process DSP files
function (QURT_LIB)
set(options)
set(oneValueArgs LIB_NAME)
set(multiValueArgs SOURCES LINK_LIBS INCS FLAGS)
cmake_parse_arguments(QURT_LIB "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
)
if ("${QURT_LIB_SOURCES}" STREQUAL "")
message(FATAL_ERROR "QURT_LIB called without SOURCES")
else()
# Build lib that is run on the DSP
add_library(${QURT_LIB_LIB_NAME} SHARED
${QURT_LIB_SOURCES}
)
if (NOT "${QURT_LIB_FLAGS}" STREQUAL "")
set_target_properties(${QURT_LIB_LIB_NAME} PROPERTIES COMPILE_FLAGS "${QURT_LIB_FLAGS}")
endif()
if (NOT "${QURT_LIB_INCS}" STREQUAL "")
target_include_directories(${QURT_LIB_LIB_NAME} PUBLIC ${QURT_LIB_INCS})
endif()
target_link_libraries(${QURT_LIB_LIB_NAME}
${QURT_LIB_LINK_LIBS}
)
endif()
set(DSPLIB_TARGET_PATH "/usr/lib/rfsa/adsp/")
# Add a rule to load the files onto the target that run in the DSP
add_custom_target(lib${QURT_LIB_LIB_NAME}-load
DEPENDS ${QURT_LIB_LIB_NAME}
COMMAND adb wait-for-device
COMMAND adb push lib${QURT_LIB_LIB_NAME}.so ${DSPLIB_TARGET_PATH}
COMMAND echo "Pushed lib${QURT_LIB_LIB_NAME}.so and dependencies to ${DSPLIB_TARGET_PATH}"
)
endfunction()

View File

@ -0,0 +1,34 @@
############################################################################
#
# Copyright (c) 2022 ModalAI, Inc. 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.
#
############################################################################
# Placeholder

View File

@ -0,0 +1,30 @@
#include <time.h>
void qurt_free(void *ptr);
__attribute__((visibility("default"))) void free(void *ptr)
{
qurt_free(ptr);
// ptr = 0;
}
__attribute__((visibility("default"))) void *malloc(size_t size)
{
return (void *) 0;
}
__attribute__((visibility("default"))) void *calloc(size_t nmemb, size_t size)
{
return (void *) 0;
}
__attribute__((visibility("default"))) void *realloc(void *ptr, size_t size)
{
return (void *) 0;
}
__attribute__((visibility("default"))) int nanosleep(const struct timespec *req, struct timespec *rem)
{
return -1;
}

View File

@ -91,11 +91,13 @@
/* We can't poison clock_settime/clock_gettime because they are
* used in DriverFramework. */
#if !defined(__PX4_NUTTX)
#if !defined(__PX4_NUTTX) && !defined(__PX4_QURT)
#include <pthread.h>
// We can't include this for NuttX otherwise we get conflicts for read/write
// symbols in cannode.
#endif // !defined(__PX4_NUTTX)
// We can't include this for Qurt because it uses it's own thread primitives
#endif // !defined(__PX4_NUTTX) && !defined(__PX4_QURT)
#define system_pthread_cond_timedwait pthread_cond_timedwait
/* We can't poison pthread_cond_timedwait because it seems to be used in the
* <string> include. */

View File

@ -82,6 +82,7 @@ endif()
if(CONFIG_BOARD_IO)
set(board_with_io_arg --board-with-io)
endif()
add_custom_command(OUTPUT ${generated_serial_params_file} ${generated_module_params_file}
COMMAND ${CMAKE_COMMAND} -E make_directory ${generated_params_dir}
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/serial/generate_config.py

View File

@ -0,0 +1,3 @@
menu "MUORB"
rsource "*/Kconfig"
endmenu #MUORB

View File

@ -0,0 +1,42 @@
############################################################################
#
# Copyright (c) 2022 ModalAI, Inc. 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.
#
############################################################################
px4_add_module(
MODULE modules__muorb__apps
MAIN muorb
COMPILE_FLAGS
-Wno-cast-align # TODO: fix and enable
SRCS
uORBAppsProtobufChannel.cpp
muorb_main.cpp
)

View File

@ -0,0 +1,5 @@
menuconfig MODULES_MUORB_APPS
bool "apps"
default n
---help---
Enable support for muorb apps

View File

@ -0,0 +1,69 @@
/****************************************************************************
*
* Copyright (C) 2022 ModalAI, Inc. 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.
*
****************************************************************************/
#ifndef FC_SENSOR_H
#define FC_SENSOR_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdbool.h>
typedef void (*fc_receive_cb)(const char *topic,
const uint8_t *data,
uint32_t length_in_bytes);
typedef void (*fc_advertise_cb)(const char *topic);
typedef void (*fc_add_subscription_cb)(const char *topic);
typedef void (*fc_remove_subscription_cb)(const char *topic);
typedef struct {
fc_receive_cb rx_callback;
fc_advertise_cb ad_callback;
fc_add_subscription_cb sub_callback;
fc_remove_subscription_cb remove_sub_callback;
} fc_callbacks;
int fc_sensor_initialize(bool enable_debug_messages, fc_callbacks *callbacks);
int fc_sensor_advertise(const char *topic);
int fc_sensor_subscribe(const char *topic);
int fc_sensor_unsubscribe(const char *topic);
int fc_sensor_send_data(const char *topic,
const uint8_t *data,
uint32_t length_in_bytes);
#ifdef __cplusplus
}
#endif
#endif // FC_SENSOR_H

View File

@ -0,0 +1,90 @@
/****************************************************************************
*
* Copyright (c) 2022 ModalAI, Inc. 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.
*
****************************************************************************/
#include <string.h>
#include "uORBAppsProtobufChannel.hpp"
extern "C" { __EXPORT int muorb_main(int argc, char *argv[]); }
static void usage()
{
PX4_INFO("Usage: muorb 'start', 'stop', 'status'");
}
static bool enable_debug = false;
int
muorb_main(int argc, char *argv[])
{
if (argc < 2) {
usage();
return -EINVAL;
}
// TODO: Add an optional start parameter to control debug messages
if (!strcmp(argv[1], "start")) {
if (uORB::AppsProtobufChannel::isInstance()) {
PX4_WARN("muorb already started");
} else {
// Register the protobuf channel with UORB.
uORB::AppsProtobufChannel *channel = uORB::AppsProtobufChannel::GetInstance();
if (channel) {
if (channel->Initialize(enable_debug)) {
return OK;
}
}
}
} else if (!strcmp(argv[1], "stop")) {
if (uORB::AppsProtobufChannel::isInstance() == false) {
PX4_WARN("muorb not running");
}
return OK;
} else if (!strcmp(argv[1], "status")) {
if (uORB::AppsProtobufChannel::isInstance()) {
PX4_INFO("muorb initialized");
} else {
PX4_INFO("muorb not running");
}
return OK;
}
usage();
return -EINVAL;
}

View File

@ -0,0 +1,86 @@
/****************************************************************************
*
* Copyright (C) 2022 ModalAI, Inc. 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.
*
****************************************************************************/
#include "uORBAppsProtobufChannel.hpp"
#include <string.h>
#include "fc_sensor.h"
// Initialize the static members
uORB::AppsProtobufChannel *uORB::AppsProtobufChannel::_InstancePtr = nullptr;
void uORB::AppsProtobufChannel::ReceiveCallback(const char *topic,
const uint8_t *data,
uint32_t length_in_bytes)
{
if (strcmp(topic, "slpi_debug") == 0) {
PX4_INFO("SLPI: %s", (const char *) data);
} else if (strcmp(topic, "slpi_error") == 0) {
PX4_ERR("SLPI: %s", (const char *) data);
} else {
PX4_INFO("Got received data callback for topic %s", topic);
}
}
void uORB::AppsProtobufChannel::AdvertiseCallback(const char *topic)
{
PX4_INFO("Got advertisement callback for topic %s", topic);
}
void uORB::AppsProtobufChannel::SubscribeCallback(const char *topic)
{
PX4_INFO("Got subscription callback for topic %s", topic);
}
void uORB::AppsProtobufChannel::UnsubscribeCallback(const char *topic)
{
PX4_INFO("Got remove subscription callback for topic %s", topic);
}
bool uORB::AppsProtobufChannel::Initialize(bool enable_debug)
{
fc_callbacks cb = {&ReceiveCallback, &AdvertiseCallback,
&SubscribeCallback, &UnsubscribeCallback
};
if (fc_sensor_initialize(enable_debug, &cb) != 0) {
PX4_ERR("Error calling the muorb protobuf initalize method");
} else {
PX4_INFO("muorb protobuf initalize method succeeded");
}
return true;
}

View File

@ -0,0 +1,87 @@
/****************************************************************************
*
* Copyright (C) 2022 ModalAI, Inc. 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.
*
****************************************************************************/
#ifndef _uORBAppsProtobufChannel_hpp_
#define _uORBAppsProtobufChannel_hpp_
#include <stdint.h>
#include <string>
#include <px4_platform_common/log.h>
namespace uORB
{
class AppsProtobufChannel;
}
class uORB::AppsProtobufChannel
{
public:
/**
* static method to get the IChannel Implementor.
*/
static uORB::AppsProtobufChannel *GetInstance()
{
if (_InstancePtr == nullptr) {
_InstancePtr = new uORB::AppsProtobufChannel();
}
return _InstancePtr;
}
/**
* Static method to check if there is an instance.
*/
static bool isInstance()
{
return (_InstancePtr != nullptr);
}
bool Initialize(bool enable_debug);
private: // data members
static uORB::AppsProtobufChannel *_InstancePtr;
private://class members.
/// constructor.
AppsProtobufChannel() {};
static void ReceiveCallback(const char *topic,
const uint8_t *data,
uint32_t length_in_bytes);
static void AdvertiseCallback(const char *topic);
static void SubscribeCallback(const char *topic);
static void UnsubscribeCallback(const char *topic);
};
#endif /* _uORBAppsProtobufChannel_hpp_ */

View File

@ -0,0 +1,37 @@
############################################################################
#
# Copyright (c) 2022 ModalAI, Inc. 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.
#
############################################################################
px4_add_library(modules__muorb__slpi
uORBProtobufChannel.cpp
)
#target_include_directories(modules__muorb__slpi PRIVATE ${PX4_SOURCE_DIR}/src/modules/uORB)

View File

@ -0,0 +1,5 @@
menuconfig MODULES_MUORB_SLPI
bool "muorb_slpi"
default n
---help---
Enable support for muorb slpi

View File

@ -0,0 +1,64 @@
/****************************************************************************
*
* Copyright (C) 2022 ModalAI, Inc. 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.
*
****************************************************************************/
#include "uORBProtobufChannel.hpp"
// TODO: Move this out of here once we have it placed properly
extern "C" void HAP_debug(const char *msg, int level, const char *filename, int line);
int px4muorb_orb_initialize(fc_func_ptrs *func_ptrs, int32_t clock_offset_us)
{
HAP_debug("Hello, world!", 1, "test", 0);
return 0;
}
int px4muorb_topic_advertised(const char *topic_name)
{
return 0;
}
int px4muorb_add_subscriber(const char *topic_name)
{
return 0;
}
int px4muorb_remove_subscriber(const char *topic_name)
{
return 0;
}
int px4muorb_send_topic_data(const char *topic_name, const uint8_t *data,
int data_len_in_bytes)
{
return 0;
}

View File

@ -0,0 +1,80 @@
/****************************************************************************
*
* Copyright (C) 2022 ModalAI, Inc. 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.
*
****************************************************************************/
#ifndef _uORBProtobufChannel_hpp_
#define _uORBProtobufChannel_hpp_
#include <stdint.h>
#include <stdio.h>
//#include <unistd.h>
// TODO: This has to be defined in the slpi_proc build and in the PX4 build.
// Make it accessible from one file to both builds.
typedef struct {
int (*advertise_func_ptr)(const char *topic_name);
int (*subscribe_func_ptr)(const char *topic_name);
int (*unsubscribe_func_ptr)(const char *topic_name);
int (*topic_data_func_ptr)(const char *name, const uint8_t *data, int data_len_in_bytes);
// device::SPI::_config_spi_bus_func_t config_spi_bus;
// device::SPI::_spi_transfer_func_t spi_transfer;
int (*_config_spi_bus_func_t)();
int (*_spi_transfer_func_t)(int, const uint8_t *, uint8_t *, const unsigned);
// device::I2C::_config_i2c_bus_func_t config_i2c_bus;
// device::I2C::_set_i2c_address_func_t set_i2c_address;
// device::I2C::_i2c_transfer_func_t i2c_transfer;
int (*_config_i2c_bus_func_t)(uint8_t, uint8_t, uint32_t);
int (*_set_i2c_address_func_t)(int, uint8_t);
int (*_i2c_transfer_func_t)(int, const uint8_t *, const unsigned, uint8_t *, const unsigned);
// open_uart_func_t open_uart_func;
// write_uart_func_t write_uart_func;
// read_uart_func_t read_uart_func;
int (*open_uart_func_t)(uint8_t, uint32_t);
int (*write_uart_func_t)(int, const void *, size_t);
int (*read_uart_func_t)(int, void *, size_t);
int (*register_interrupt_callback)(int (*)(int, void *, void *), void *arg);
} fc_func_ptrs;
extern "C" {
int px4muorb_orb_initialize(fc_func_ptrs *func_ptrs, int32_t clock_offset_us) __EXPORT;
int px4muorb_topic_advertised(const char *name) __EXPORT;
int px4muorb_add_subscriber(const char *name) __EXPORT;
int px4muorb_remove_subscriber(const char *name) __EXPORT;
int px4muorb_send_topic_data(const char *name, const uint8_t *data, int data_len_in_bytes) __EXPORT;
}
#endif /* _uORBProtobufChannel_hpp_ */