2018-11-16 13:52:37 -04:00
|
|
|
############################################################################
|
|
|
|
#
|
2018-11-23 11:01:03 -04:00
|
|
|
# Copyright (c) 2018 PX4 Development Team. All rights reserved.
|
2018-11-16 13:52:37 -04:00
|
|
|
#
|
|
|
|
# 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(px4_base)
|
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
#
|
|
|
|
# px4_add_board
|
|
|
|
#
|
|
|
|
# This function creates a PX4 board.
|
|
|
|
#
|
|
|
|
# Usage:
|
2018-11-23 11:55:18 -04:00
|
|
|
# px4_add_board(
|
|
|
|
# PLATFORM <string>
|
|
|
|
# VENDOR <string>
|
|
|
|
# MODEL <string>
|
|
|
|
# [ LABEL <string> ]
|
|
|
|
# [ TOOLCHAIN <string> ]
|
2018-11-23 13:39:44 -04:00
|
|
|
# [ ARCHITECTURE <string> ]
|
2018-11-23 11:55:18 -04:00
|
|
|
# [ ROMFSROOT <string> ]
|
|
|
|
# [ IO <string> ]
|
|
|
|
# [ BOOTLOADER <string> ]
|
|
|
|
# [ UAVCAN_INTERFACES <string> ]
|
|
|
|
# [ DRIVERS <list> ]
|
|
|
|
# [ MODULES <list> ]
|
|
|
|
# [ SYSTEMCMDS <list> ]
|
|
|
|
# [ EXAMPLES <list> ]
|
|
|
|
# [ SERIAL_PORTS <list> ]
|
|
|
|
# [ DF_DRIVERS <list> ]
|
|
|
|
# [ CONSTRAINED_FLASH ]
|
|
|
|
# [ TESTING ]
|
2018-11-16 13:52:37 -04:00
|
|
|
# )
|
|
|
|
#
|
|
|
|
# Input:
|
2018-11-23 11:55:18 -04:00
|
|
|
# PLATFORM : PX4 platform name (posix, nuttx, qurt)
|
|
|
|
# VENDOR : name of board vendor/manufacturer/brand/etc
|
|
|
|
# MODEL : name of board model
|
|
|
|
# LABEL : optional label, set to default if not specified
|
|
|
|
# TOOLCHAIN : cmake toolchain
|
2018-11-23 13:39:44 -04:00
|
|
|
# ARCHITECTURE : name of the CPU CMake is building for (used by the toolchain)
|
2018-11-23 11:55:18 -04:00
|
|
|
# ROMFSROOT : relative path to the ROMFS root directory (currently NuttX only)
|
|
|
|
# IO : name of IO board to be built and included in the ROMFS (requires a valid ROMFSROOT)
|
|
|
|
# BOOTLOADER : bootloader file to include for flashing via bl_update (currently NuttX only)
|
|
|
|
# UAVCAN_INTERFACES : number of interfaces for UAVCAN
|
|
|
|
# DRIVERS : list of drivers to build for this board (relative to src/drivers)
|
|
|
|
# MODULES : list of modules to build for this board (relative to src/modules)
|
|
|
|
# SYSTEMCMDS : list of system commands to build for this board (relative to src/systemcmds)
|
|
|
|
# EXAMPLES : list of example modules to build for this board (relative to src/examples)
|
|
|
|
# SERIAL_PORTS : mapping of user configurable serial ports and param facing name
|
|
|
|
# DF_DRIVERS : list of DriverFramework device drivers (includes DriverFramework driver and wrapper)
|
|
|
|
# CONSTRAINED_FLASH : flag to enable constrained flash options (eg limit init script status text)
|
|
|
|
# TESTING : flag to enable automatic inclusion of PX4 testing modules
|
2018-11-16 13:52:37 -04:00
|
|
|
#
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# px4_add_board(
|
2018-11-23 11:55:18 -04:00
|
|
|
# PLATFORM nuttx
|
|
|
|
# VENDOR px4
|
|
|
|
# MODEL fmu-v5
|
|
|
|
# TOOLCHAIN arm-none-eabi
|
2018-11-23 13:39:44 -04:00
|
|
|
# ARCHITECTURE cortex-m7
|
2018-11-23 11:55:18 -04:00
|
|
|
# ROMFSROOT px4fmu_common
|
|
|
|
# IO px4_io-v2_default
|
|
|
|
# SERIAL_PORTS
|
|
|
|
# GPS1:/dev/ttyS0
|
|
|
|
# TEL1:/dev/ttyS1
|
|
|
|
# TEL2:/dev/ttyS2
|
|
|
|
# TEL4:/dev/ttyS3
|
|
|
|
# DRIVERS
|
|
|
|
# barometer/ms5611
|
|
|
|
# gps
|
|
|
|
# imu/bmi055
|
|
|
|
# imu/mpu6000
|
|
|
|
# magnetometer/ist8310
|
|
|
|
# px4fmu
|
|
|
|
# px4io
|
|
|
|
# rgbled
|
|
|
|
# MODULES
|
|
|
|
# commander
|
|
|
|
# ekf2
|
|
|
|
# land_detector
|
|
|
|
# mavlink
|
|
|
|
# mc_att_control
|
|
|
|
# mc_pos_control
|
|
|
|
# navigator
|
|
|
|
# sensors
|
|
|
|
# MODULES
|
|
|
|
# mixer
|
|
|
|
# mtd
|
|
|
|
# param
|
|
|
|
# perf
|
|
|
|
# pwm
|
|
|
|
# reboot
|
|
|
|
# shutdown
|
|
|
|
# top
|
|
|
|
# topic_listener
|
|
|
|
# tune_control
|
2018-11-16 13:52:37 -04:00
|
|
|
# )
|
|
|
|
#
|
|
|
|
function(px4_add_board)
|
|
|
|
|
|
|
|
px4_parse_function_args(
|
|
|
|
NAME px4_add_board
|
|
|
|
ONE_VALUE
|
2018-11-23 11:55:18 -04:00
|
|
|
PLATFORM
|
2018-11-16 13:52:37 -04:00
|
|
|
VENDOR
|
|
|
|
MODEL
|
|
|
|
LABEL
|
|
|
|
TOOLCHAIN
|
2018-11-23 13:39:44 -04:00
|
|
|
ARCHITECTURE
|
2018-11-16 13:52:37 -04:00
|
|
|
ROMFSROOT
|
|
|
|
IO
|
|
|
|
BOOTLOADER
|
|
|
|
UAVCAN_INTERFACES
|
|
|
|
MULTI_VALUE
|
|
|
|
DRIVERS
|
|
|
|
MODULES
|
|
|
|
SYSTEMCMDS
|
|
|
|
EXAMPLES
|
|
|
|
SERIAL_PORTS
|
2018-11-23 11:55:18 -04:00
|
|
|
DF_DRIVERS
|
2018-11-16 13:52:37 -04:00
|
|
|
OPTIONS
|
|
|
|
CONSTRAINED_FLASH
|
|
|
|
TESTING
|
|
|
|
REQUIRED
|
|
|
|
PLATFORM
|
|
|
|
VENDOR
|
|
|
|
MODEL
|
|
|
|
ARGN ${ARGN})
|
|
|
|
|
|
|
|
set(PX4_BOARD_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE STRING "PX4 board directory" FORCE)
|
2018-11-23 13:39:44 -04:00
|
|
|
include_directories(${PX4_BOARD_DIR}/src)
|
|
|
|
|
|
|
|
set(PX4_BOARD ${VENDOR}_${MODEL} CACHE STRING "PX4 board" FORCE)
|
|
|
|
|
|
|
|
# board name is uppercase with no underscores when used as a define
|
|
|
|
string(TOUPPER ${PX4_BOARD} PX4_BOARD_NAME)
|
|
|
|
string(REPLACE "-" "_" PX4_BOARD_NAME ${PX4_BOARD_NAME})
|
|
|
|
set(PX4_BOARD_NAME ${PX4_BOARD_NAME} CACHE STRING "PX4 board define" FORCE)
|
2018-11-16 13:52:37 -04:00
|
|
|
|
|
|
|
set(PX4_BOARD_VENDOR ${VENDOR} CACHE STRING "PX4 board vendor" FORCE)
|
|
|
|
set(PX4_BOARD_MODEL ${MODEL} CACHE STRING "PX4 board model" FORCE)
|
|
|
|
|
|
|
|
if(LABEL)
|
|
|
|
set(PX4_BOARD_LABEL ${LABEL} CACHE STRING "PX4 board label" FORCE)
|
|
|
|
else()
|
|
|
|
set(PX4_BOARD_LABEL "default" CACHE STRING "PX4 board label" FORCE)
|
|
|
|
endif()
|
|
|
|
|
2018-11-23 13:39:44 -04:00
|
|
|
set(PX4_CONFIG "${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_${PX4_BOARD_LABEL}" CACHE STRING "PX4 config" FORCE)
|
|
|
|
|
2018-11-16 13:52:37 -04:00
|
|
|
# set OS, and append specific platform module path
|
|
|
|
set(PX4_PLATFORM ${PLATFORM} CACHE STRING "PX4 board OS" FORCE)
|
2018-11-23 11:55:18 -04:00
|
|
|
list(APPEND CMAKE_MODULE_PATH ${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/cmake)
|
2018-11-16 13:52:37 -04:00
|
|
|
|
2018-11-23 13:39:44 -04:00
|
|
|
if(ARCHITECTURE)
|
|
|
|
set(CMAKE_SYSTEM_PROCESSOR ${ARCHITECTURE} CACHE INTERNAL "system processor" FORCE)
|
2018-11-16 13:52:37 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(TOOLCHAIN)
|
2018-11-23 11:01:03 -04:00
|
|
|
set(CMAKE_TOOLCHAIN_FILE Toolchain-${TOOLCHAIN} CACHE INTERNAL "toolchain file" FORCE)
|
2018-11-16 13:52:37 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(BOOTLOADER)
|
|
|
|
set(config_bl_file ${BOOTLOADER} CACHE INTERNAL "bootloader" FORCE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(SERIAL_PORTS)
|
|
|
|
set(board_serial_ports ${SERIAL_PORTS} PARENT_SCOPE)
|
|
|
|
endif()
|
|
|
|
|
2018-11-23 11:01:03 -04:00
|
|
|
# ROMFS
|
2018-11-23 11:55:18 -04:00
|
|
|
if(ROMFSROOT)
|
|
|
|
set(config_romfs_root ${ROMFSROOT} CACHE INTERNAL "ROMFS root" FORCE)
|
2018-11-23 11:01:03 -04:00
|
|
|
|
2018-11-23 11:55:18 -04:00
|
|
|
# IO board (placed in ROMFS)
|
|
|
|
if(IO)
|
|
|
|
set(config_io_board ${IO} CACHE INTERNAL "IO" FORCE)
|
|
|
|
endif()
|
2018-11-23 11:01:03 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(UAVCAN_INTERFACES)
|
|
|
|
set(config_uavcan_num_ifaces ${UAVCAN_INTERFACES} CACHE INTERNAL "UAVCAN interfaces" FORCE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# OPTIONS
|
2018-11-16 13:52:37 -04:00
|
|
|
|
2018-11-23 11:01:03 -04:00
|
|
|
if(CONSTRAINED_FLASH)
|
|
|
|
set(px4_constrained_flash_build "1" CACHE INTERNAL "constrained flash build" FORCE)
|
|
|
|
endif()
|
2018-11-16 13:52:37 -04:00
|
|
|
|
2018-11-23 11:01:03 -04:00
|
|
|
if(TESTING)
|
|
|
|
set(PX4_TESTING "1" CACHE INTERNAL "testing enabled" FORCE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include(px4_impl_os)
|
|
|
|
px4_os_prebuild_targets(OUT prebuild_targets BOARD ${PX4_BOARD})
|
|
|
|
|
|
|
|
|
|
|
|
###########################################################################
|
2018-11-16 13:52:37 -04:00
|
|
|
# Modules (includes drivers, examples, modules, systemcmds)
|
|
|
|
set(config_module_list)
|
|
|
|
|
|
|
|
if(DRIVERS)
|
|
|
|
foreach(driver ${DRIVERS})
|
|
|
|
list(APPEND config_module_list drivers/${driver})
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(MODULES)
|
|
|
|
foreach(module ${MODULES})
|
|
|
|
list(APPEND config_module_list modules/${module})
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(SYSTEMCMDS)
|
|
|
|
foreach(systemcmd ${SYSTEMCMDS})
|
|
|
|
list(APPEND config_module_list systemcmds/${systemcmd})
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(EXAMPLES)
|
|
|
|
foreach(example ${EXAMPLES})
|
|
|
|
list(APPEND config_module_list examples/${example})
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# DriverFramework drivers
|
|
|
|
if(DF_DRIVERS)
|
|
|
|
set(config_df_driver_list)
|
|
|
|
foreach(driver ${DF_DRIVERS})
|
|
|
|
list(APPEND config_df_driver_list ${driver})
|
2018-12-01 13:54:41 -04:00
|
|
|
|
2018-12-07 05:17:49 -04:00
|
|
|
if(EXISTS "${PX4_SOURCE_DIR}/src/platforms/posix/drivers/df_${driver}_wrapper")
|
2018-12-01 13:54:41 -04:00
|
|
|
list(APPEND config_module_list platforms/posix/drivers/df_${driver}_wrapper)
|
|
|
|
endif()
|
2018-11-16 13:52:37 -04:00
|
|
|
endforeach()
|
|
|
|
set(config_df_driver_list ${config_df_driver_list} PARENT_SCOPE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# add board config directory src to build modules
|
|
|
|
file(RELATIVE_PATH board_support_src_rel ${PX4_SOURCE_DIR}/src ${PX4_BOARD_DIR})
|
|
|
|
list(APPEND config_module_list ${board_support_src_rel}/src)
|
|
|
|
|
|
|
|
set(config_module_list ${config_module_list} PARENT_SCOPE)
|
|
|
|
|
|
|
|
endfunction()
|