diff --git a/boards/modalai/voxl2/qurt.px4board b/boards/modalai/voxl2-slpi/default.px4board similarity index 100% rename from boards/modalai/voxl2/qurt.px4board rename to boards/modalai/voxl2-slpi/default.px4board diff --git a/boards/modalai/voxl2/cmake/voxl2_posix.cmake b/boards/modalai/voxl2-slpi/src/CMakeLists.txt similarity index 74% rename from boards/modalai/voxl2/cmake/voxl2_posix.cmake rename to boards/modalai/voxl2-slpi/src/CMakeLists.txt index 2f4b12420d..b2ef3aacd2 100644 --- a/boards/modalai/voxl2/cmake/voxl2_posix.cmake +++ b/boards/modalai/voxl2-slpi/src/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2022 ModalAI, Inc. All rights reserved. +# 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 @@ -30,25 +30,8 @@ # 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) +add_library(drivers_board + board_config.h + init.c + ) diff --git a/boards/modalai/voxl2-slpi/src/board_config.h b/boards/modalai/voxl2-slpi/src/board_config.h new file mode 100644 index 0000000000..6c57100198 --- /dev/null +++ b/boards/modalai/voxl2-slpi/src/board_config.h @@ -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 +#define ORB_COMMUNICATOR 1 +/* + * I2C buses + */ +#define PX4_NUMBER_I2C_BUSES 3 + +#include +#include diff --git a/boards/modalai/voxl2-slpi/src/init.c b/boards/modalai/voxl2-slpi/src/init.c new file mode 100644 index 0000000000..f9a71ffaa2 --- /dev/null +++ b/boards/modalai/voxl2-slpi/src/init.c @@ -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 diff --git a/boards/modalai/voxl2/README.md b/boards/modalai/voxl2/README.md index 0004f8e28c..02d7f6fc5a 100644 --- a/boards/modalai/voxl2/README.md +++ b/boards/modalai/voxl2/README.md @@ -25,10 +25,10 @@ The full instructions are available here: - 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 +px4$ boards/modalai/voxl2/scripts/run-docker.sh +root@9373fa1401b8:/usr/local/workspace# boards/modalai/voxl2/scripts/clean.sh +root@9373fa1401b8:/usr/local/workspace# boards/modalai/voxl2/scripts/build-apps.sh +root@9373fa1401b8:/usr/local/workspace# boards/modalai/voxl2/scripts/build-slpi.sh root@9373fa1401b8:/usr/local/workspace# exit ``` @@ -37,7 +37,7 @@ root@9373fa1401b8:/usr/local/workspace# exit 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 +px4$ boards/modalai/voxl2/scripts/install-voxl.sh ``` ## Running PX4 on VOXL 2 @@ -66,10 +66,17 @@ INFO [px4] Startup script returned successfully pxh> ``` +## Notes + +You cannot cleanly shutdown PX4 with the shutdown command on VOXL 2. You have +to power cycle the board and restart everything. + ## Tips Start with a VOXL 2 that only has the system image installed, not the SDK +Run the command ```voxl-px4 -s``` on target to run the self-test + In order to see DSP specific debug messages the mini-dm tool in the Hexagon SDK can be used: ``` diff --git a/boards/modalai/voxl2/build-qurt.sh b/boards/modalai/voxl2/build-qurt.sh deleted file mode 100755 index 2e29d4f28e..0000000000 --- a/boards/modalai/voxl2/build-qurt.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/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 ***" diff --git a/boards/modalai/voxl2/cmake/link_libraries.cmake b/boards/modalai/voxl2/cmake/link_libraries.cmake new file mode 100644 index 0000000000..42c9feae35 --- /dev/null +++ b/boards/modalai/voxl2/cmake/link_libraries.cmake @@ -0,0 +1,7 @@ + +# libfc_sensor.so is provided in the Docker build environment +target_link_libraries(px4 PRIVATE + /home/libfc_sensor.so + px4_layer + ${module_libraries} +) diff --git a/boards/modalai/voxl2/cmake/voxl2_qurt.cmake b/boards/modalai/voxl2/cmake/voxl2_qurt.cmake deleted file mode 100644 index 948fca5f16..0000000000 --- a/boards/modalai/voxl2/cmake/voxl2_qurt.cmake +++ /dev/null @@ -1,43 +0,0 @@ -############################################################################ -# -# 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) diff --git a/boards/modalai/voxl2/build-posix.sh b/boards/modalai/voxl2/scripts/build-apps.sh similarity index 50% rename from boards/modalai/voxl2/build-posix.sh rename to boards/modalai/voxl2/scripts/build-apps.sh index 675cec87fe..28b6a8d99b 100755 --- a/boards/modalai/voxl2/build-posix.sh +++ b/boards/modalai/voxl2/scripts/build-apps.sh @@ -1,12 +1,11 @@ #!/bin/bash -echo "*** Starting posix build ***" +echo "*** Starting apps processor build ***" source /home/build-env.sh -make modalai_voxl2_default +make modalai_voxl2 cat build/modalai_voxl2_default/src/lib/version/build_git_version.h - -echo "*** End of posix build ***" +echo "*** End of apps processor build ***" diff --git a/boards/modalai/voxl2/scripts/build-slpi.sh b/boards/modalai/voxl2/scripts/build-slpi.sh new file mode 100755 index 0000000000..4c05f8f4f1 --- /dev/null +++ b/boards/modalai/voxl2/scripts/build-slpi.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +echo "*** Starting qurt slpi build ***" + +source /home/build-env.sh + +make modalai_voxl2-slpi + +cat build/modalai_voxl2-slpi_default/src/lib/version/build_git_version.h + +echo "*** End of qurt slpi build ***" diff --git a/boards/modalai/voxl2/clean.sh b/boards/modalai/voxl2/scripts/clean.sh similarity index 100% rename from boards/modalai/voxl2/clean.sh rename to boards/modalai/voxl2/scripts/clean.sh diff --git a/boards/modalai/voxl2/install-voxl.sh b/boards/modalai/voxl2/scripts/install-voxl.sh similarity index 53% rename from boards/modalai/voxl2/install-voxl.sh rename to boards/modalai/voxl2/scripts/install-voxl.sh index a316c3691b..db746fffee 100755 --- a/boards/modalai/voxl2/install-voxl.sh +++ b/boards/modalai/voxl2/scripts/install-voxl.sh @@ -1,19 +1,19 @@ #!/bin/bash -# Push qurt image to voxl2 -adb push build/modalai_voxl2_qurt/platforms/qurt/libpx4.so /usr/lib/rfsa/adsp +# Push slpi image to voxl2 +adb push build/modalai_voxl2-slpi_default/platforms/qurt/libpx4.so /usr/lib/rfsa/adsp -# Push posix image to voxl2 +# Push apps processor 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 push boards/modalai/voxl2/target/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 push boards/modalai/voxl2/target/voxl-px4.config /etc/modalai adb shell sync diff --git a/boards/modalai/voxl2/run-docker.sh b/boards/modalai/voxl2/scripts/run-docker.sh similarity index 100% rename from boards/modalai/voxl2/run-docker.sh rename to boards/modalai/voxl2/scripts/run-docker.sh diff --git a/boards/modalai/voxl2/src/board_config.h b/boards/modalai/voxl2/src/board_config.h index 6c57100198..eb67c2e8f6 100644 --- a/boards/modalai/voxl2/src/board_config.h +++ b/boards/modalai/voxl2/src/board_config.h @@ -42,10 +42,9 @@ #define BOARD_HAS_NO_RESET #define BOARD_HAS_NO_BOOTLOADER #define ORB_COMMUNICATOR 1 -/* - * I2C buses - */ -#define PX4_NUMBER_I2C_BUSES 3 + +// Define this as empty since there are no I2C buses +#define BOARD_I2C_BUS_CLOCK_INIT #include #include diff --git a/boards/modalai/voxl2/voxl-px4 b/boards/modalai/voxl2/target/voxl-px4 similarity index 100% rename from boards/modalai/voxl2/voxl-px4 rename to boards/modalai/voxl2/target/voxl-px4 diff --git a/boards/modalai/voxl2/voxl-px4.config b/boards/modalai/voxl2/target/voxl-px4.config similarity index 100% rename from boards/modalai/voxl2/voxl-px4.config rename to boards/modalai/voxl2/target/voxl-px4.config diff --git a/cmake/kconfig.cmake b/cmake/kconfig.cmake index 377da1ddd5..37b500e284 100644 --- a/cmake/kconfig.cmake +++ b/cmake/kconfig.cmake @@ -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 "qurt" OR ${LABEL} MATCHES "recovery" OR ${LABEL} MATCHES "bootloader" OR ${LABEL} MATCHES "canbootloader") + if(${LABEL} MATCHES "default" 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,10 +228,6 @@ 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) diff --git a/platforms/posix/CMakeLists.txt b/platforms/posix/CMakeLists.txt index feebe51b74..5dc709457f 100644 --- a/platforms/posix/CMakeLists.txt +++ b/platforms/posix/CMakeLists.txt @@ -97,18 +97,14 @@ if(EXISTS "${PX4_BOARD_DIR}/cmake/upload.cmake") include(${PX4_BOARD_DIR}/cmake/upload.cmake) endif() +# board defined link libraries +if(EXISTS "${PX4_BOARD_DIR}/cmake/link_libraries.cmake") + include(${PX4_BOARD_DIR}/cmake/link_libraries.cmake) +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) diff --git a/platforms/qurt/CMakeLists.txt b/platforms/qurt/CMakeLists.txt index 1c7e2bc869..446d0160d5 100644 --- a/platforms/qurt/CMakeLists.txt +++ b/platforms/qurt/CMakeLists.txt @@ -33,11 +33,16 @@ get_property(module_libraries GLOBAL PROPERTY PX4_MODULE_LIBRARIES) -QURT_LIB(LIB_NAME px4 - SOURCES - ${PX4_SOURCE_DIR}/platforms/qurt/unresolved_symbols.c - LINK_LIBS - modules__muorb__slpi - ${module_libraries} - px4_layer +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ) + +add_library(px4 SHARED + ${PX4_SOURCE_DIR}/platforms/qurt/unresolved_symbols.c + ) + +target_link_libraries(px4 + modules__muorb__slpi + ${module_libraries} + px4_layer ) diff --git a/platforms/qurt/cmake/px4_impl_os.cmake b/platforms/qurt/cmake/px4_impl_os.cmake index 09b606040b..62ce1738d6 100644 --- a/platforms/qurt/cmake/px4_impl_os.cmake +++ b/platforms/qurt/cmake/px4_impl_os.cmake @@ -31,6 +31,29 @@ # ############################################################################ +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) + +include(Toolchain-qurt) +include(qurt_reqs) + +include_directories(${HEXAGON_SDK_INCLUDES}) + +add_definitions(-DORB_COMMUNICATOR) + +set(DISABLE_PARAMS_MODULE_SCOPING TRUE) + #============================================================================= # # Defined functions in this file diff --git a/platforms/qurt/cmake/qurt_reqs.cmake b/platforms/qurt/cmake/qurt_reqs.cmake index 3717645703..c832e07c81 100644 --- a/platforms/qurt/cmake/qurt_reqs.cmake +++ b/platforms/qurt/cmake/qurt_reqs.cmake @@ -176,46 +176,3 @@ list2string(CMAKE_EXE_LINKER_FLAGS ) 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()