mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
Fix RPi2 build system
This commit is contained in:
committed by
Lorenz Meier
parent
02ba3317e9
commit
529460d573
@@ -528,6 +528,24 @@ function(px4_add_adb_push)
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function(px4_add_scp_push)
|
||||
px4_parse_function_args(
|
||||
NAME px4_add_upload
|
||||
ONE_VALUE OS BOARD OUT DEST
|
||||
MULTI_VALUE FILES DEPENDS
|
||||
REQUIRED OS BOARD OUT FILES DEPENDS DEST
|
||||
ARGN ${ARGN})
|
||||
|
||||
add_custom_target(${OUT}
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/Tools/scp_upload.sh ${FILES} ${DEST}
|
||||
DEPENDS ${DEPENDS}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "uploading ${BUNDLE}"
|
||||
VERBATIM
|
||||
USES_TERMINAL
|
||||
)
|
||||
endfunction()
|
||||
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
|
||||
@@ -1,59 +1,109 @@
|
||||
include(posix/px4_impl_posix)
|
||||
|
||||
if ("${RPI_TOOLCHAIN_DIR}" STREQUAL "")
|
||||
set(RPI_TOOLCHAIN_DIR /opt/rpi_toolchain)
|
||||
endif()
|
||||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf-raspbian.cmake)
|
||||
|
||||
set(CMAKE_PROGRAM_PATH
|
||||
"${RPI_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf-raspbian/bin"
|
||||
${CMAKE_PROGRAM_PATH}
|
||||
)
|
||||
|
||||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake)
|
||||
# This definition allows to differentiate if this just the usual POSIX build
|
||||
# or if it is for the RPi.
|
||||
add_definitions(
|
||||
-D__PX4_POSIX_RPI2
|
||||
)
|
||||
|
||||
set(config_module_list
|
||||
#
|
||||
# Board support modules
|
||||
#
|
||||
drivers/device
|
||||
platforms/common
|
||||
platforms/posix/px4_layer
|
||||
platforms/posix/work_queue
|
||||
modules/sensors
|
||||
platforms/posix/drivers/df_mpu9250_wrapper
|
||||
platforms/posix/drivers/df_bmp280_wrapper
|
||||
platforms/posix/drivers/df_hmc5883_wrapper
|
||||
platforms/posix/drivers/df_trone_wrapper
|
||||
platforms/posix/drivers/df_isl29501_wrapper
|
||||
|
||||
#
|
||||
# System commands
|
||||
#
|
||||
systemcmds/param
|
||||
systemcmds/mixer
|
||||
systemcmds/ver
|
||||
systemcmds/esc_calib
|
||||
systemcmds/reboot
|
||||
systemcmds/topic_listener
|
||||
systemcmds/perf
|
||||
modules/uORB
|
||||
modules/param
|
||||
modules/systemlib
|
||||
modules/systemlib/mixer
|
||||
modules/sensors
|
||||
modules/mavlink
|
||||
|
||||
#
|
||||
# Estimation modules (EKF/ SO3 / other filters)
|
||||
#
|
||||
#modules/attitude_estimator_ekf
|
||||
modules/ekf_att_pos_estimator
|
||||
modules/attitude_estimator_q
|
||||
modules/position_estimator_inav
|
||||
modules/navigator
|
||||
modules/vtol_att_control
|
||||
modules/mc_pos_control
|
||||
modules/local_position_estimator
|
||||
modules/ekf2
|
||||
|
||||
#
|
||||
# Vehicle Control
|
||||
#
|
||||
modules/mc_att_control
|
||||
modules/land_detector
|
||||
modules/mc_pos_control
|
||||
modules/fw_att_control
|
||||
modules/fw_pos_control_l1
|
||||
modules/dataman
|
||||
modules/fw_pos_control_l1
|
||||
modules/vtol_att_control
|
||||
|
||||
#
|
||||
# Library modules
|
||||
#
|
||||
modules/sdlog2
|
||||
modules/logger
|
||||
modules/commander
|
||||
modules/load_mon
|
||||
modules/param
|
||||
modules/systemlib
|
||||
modules/systemlib/mixer
|
||||
modules/uORB
|
||||
modules/dataman
|
||||
modules/land_detector
|
||||
modules/navigator
|
||||
modules/mavlink
|
||||
|
||||
#
|
||||
# PX4 drivers
|
||||
#
|
||||
|
||||
#
|
||||
# Libraries
|
||||
#
|
||||
lib/controllib
|
||||
lib/mathlib
|
||||
lib/mathlib/math/filter
|
||||
lib/conversion
|
||||
lib/ecl
|
||||
lib/external_lgpl
|
||||
lib/geo
|
||||
lib/ecl
|
||||
lib/geo_lookup
|
||||
lib/launchdetection
|
||||
lib/external_lgpl
|
||||
lib/conversion
|
||||
lib/terrain_estimation
|
||||
lib/runway_takeoff
|
||||
lib/tailsitter_recovery
|
||||
lib/DriverFramework/framework
|
||||
)
|
||||
|
||||
#
|
||||
# POSIX
|
||||
#
|
||||
platforms/common
|
||||
platforms/posix/px4_layer
|
||||
platforms/posix/work_queue
|
||||
|
||||
)
|
||||
|
||||
set(config_df_driver_list
|
||||
mpu9250
|
||||
bmp280
|
||||
hmc5883
|
||||
trone
|
||||
isl29501
|
||||
)
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
# defines:
|
||||
#
|
||||
# NM
|
||||
# OBJCOPY
|
||||
# LD
|
||||
# CXX_COMPILER
|
||||
# C_COMPILER
|
||||
# CMAKE_SYSTEM_NAME
|
||||
# CMAKE_SYSTEM_VERSION
|
||||
# GENROMFS
|
||||
# LINKER_FLAGS
|
||||
# CMAKE_EXE_LINKER_FLAGS
|
||||
# CMAKE_FIND_ROOT_PATH
|
||||
# CMAKE_FIND_ROOT_PATH_MODE_PROGRAM
|
||||
# CMAKE_FIND_ROOT_PATH_MODE_LIBRARY
|
||||
# CMAKE_FIND_ROOT_PATH_MODE_INCLUDE
|
||||
|
||||
include(CMakeForceCompiler)
|
||||
|
||||
if ("$ENV{RPI_TOOLCHAIN_DIR}" STREQUAL "")
|
||||
message(FATAL_ERROR "RPI_TOOLCHAIN_DIR not set")
|
||||
else()
|
||||
set(RPI_TOOLCHAIN_DIR $ENV{RPI_TOOLCHAIN_DIR})
|
||||
endif()
|
||||
|
||||
# this one is important
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
|
||||
#this one not so much
|
||||
set(CMAKE_SYSTEM_VERSION 1)
|
||||
|
||||
# specify the cross compiler
|
||||
find_program(C_COMPILER arm-linux-gnueabihf-gcc
|
||||
PATHS ${RPI_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf-raspbian/bin
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
if(NOT C_COMPILER)
|
||||
message(FATAL_ERROR "could not find arm-linux-gnueabihf-gcc compiler")
|
||||
endif()
|
||||
cmake_force_c_compiler(${C_COMPILER} GNU)
|
||||
|
||||
find_program(CXX_COMPILER arm-linux-gnueabihf-g++
|
||||
PATHS ${RPI_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf-raspbian/bin
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
if(NOT CXX_COMPILER)
|
||||
message(FATAL_ERROR "could not find arm-linux-gnueabihf-g++ compiler")
|
||||
endif()
|
||||
cmake_force_cxx_compiler(${CXX_COMPILER} GNU)
|
||||
|
||||
# compiler tools
|
||||
foreach(tool objcopy nm ld)
|
||||
string(TOUPPER ${tool} TOOL)
|
||||
find_program(${TOOL} arm-linux-gnueabihf-${tool}
|
||||
PATHS ${RPI_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf-raspbian/bin
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if(NOT ${TOOL})
|
||||
message(FATAL_ERROR "could not find arm-linux-gnueabihf-${tool}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# os tools
|
||||
foreach(tool echo patch grep rm mkdir nm genromfs cp touch make unzip)
|
||||
string(TOUPPER ${tool} TOOL)
|
||||
find_program(${TOOL} ${tool})
|
||||
if(NOT ${TOOL})
|
||||
message(FATAL_ERROR "could not find ${TOOL}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(LINKER_FLAGS "-Wl,-gc-sections")
|
||||
set(CMAKE_EXE_LINKER_FLAGS ${LINKER_FLAGS})
|
||||
set(CMAKE_C_FLAGS ${C_FLAGS})
|
||||
set(CMAKE_CXX_LINKER_FLAGS ${C_FLAGS})
|
||||
|
||||
# where is the target environment
|
||||
set(CMAKE_FIND_ROOT_PATH get_file_component(${C_COMPILER} PATH))
|
||||
|
||||
# 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)
|
||||
Reference in New Issue
Block a user