Skip to content

Commit

Permalink
boards/modalai: separate voxl2 builds into two board builds instead o…
Browse files Browse the repository at this point in the history
…f single board build with different variants

* Made voxl2 apps processor and slpi dsp processor builds into separate board builds so that they can
more easily be configured independently.

* Removed board specific link library command from px4_config.cmake and moved it to a more generic
board specific solution that can be used by any board that needs custom link libraries.

* Removed redundant cmake command for Qurt

* Removed unused definition from Qurt cmake file

* Removed unnecessary QURT_LIB cmake function

* Reorganized the voxl2 build structure to avoid 4 level board directories.

* Reverted cmake files to remove 4 level board naming code

* Updated documentation
  • Loading branch information
katzfey authored Nov 15, 2022
1 parent 22420a7 commit 796fa8b
Show file tree
Hide file tree
Showing 21 changed files with 172 additions and 157 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
)
51 changes: 51 additions & 0 deletions boards/modalai/voxl2-slpi/src/board_config.h
Original file line number Diff line number Diff line change
@@ -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 <system_config.h>
#include <px4_platform_common/board_common.h>
35 changes: 35 additions & 0 deletions boards/modalai/voxl2-slpi/src/init.c
Original file line number Diff line number Diff line change
@@ -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
17 changes: 12 additions & 5 deletions boards/modalai/voxl2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand All @@ -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
Expand Down Expand Up @@ -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:
```
Expand Down
11 changes: 0 additions & 11 deletions boards/modalai/voxl2/build-qurt.sh

This file was deleted.

7 changes: 7 additions & 0 deletions boards/modalai/voxl2/cmake/link_libraries.cmake
Original file line number Diff line number Diff line change
@@ -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}
)
43 changes: 0 additions & 43 deletions boards/modalai/voxl2/cmake/voxl2_qurt.cmake

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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 ***"
11 changes: 11 additions & 0 deletions boards/modalai/voxl2/scripts/build-slpi.sh
Original file line number Diff line number Diff line change
@@ -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 ***"
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
7 changes: 3 additions & 4 deletions boards/modalai/voxl2/src/board_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <system_config.h>
#include <px4_platform_common/board_common.h>
File renamed without changes.
File renamed without changes.
6 changes: 1 addition & 5 deletions cmake/kconfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 4 additions & 8 deletions platforms/posix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
19 changes: 12 additions & 7 deletions platforms/qurt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
23 changes: 23 additions & 0 deletions platforms/qurt/cmake/px4_impl_os.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 796fa8b

Please sign in to comment.