ubuntu配置px4編譯環境


一、主要參考的內容

px4的開發者手冊

https://dev.px4.io/zh/setup/dev_env_linux.html

其中有的shell指令

權限設置

警告:永遠不要使用sudo來修復權限問題,否則會帶來更多的權限問題,需要重裝系統來解決。

把用戶添加到用戶組 "dialout":

 
sudo usermod -a -G dialout $USER 

然后注銷后,重新登錄,因為重新登錄后所做的改變才會有效。

安裝

更新包列表,安裝下面編譯PX4的依賴包。PX4主要支持的系列:

提示:安裝Ninja Build System可以比make更快進行編譯。如果安裝了它就會自動選擇使用它進行編譯。

 
sudo add-apt-repository ppa:george-edison55/cmake-3.x -y
sudo apt-get update
# 必備軟件 sudo apt-get install python-argparse git-core wget zip \ python-empy qtcreator cmake build-essential genromfs -y # 仿真工具 sudo add-apt-repository ppa:openjdk-r/ppa sudo apt-get update sudo apt-get install openjdk-8-jre sudo apt-get install ant protobuf-compiler libeigen3-dev libopencv-dev openjdk-8-jdk openjdk-8-jre 

樹莓派

樹莓派開發者應該從下面地址下載樹莓派Linux工具鏈。安裝腳本會自動安裝交叉編譯工具鏈。如果想要用原生樹莓派工具鏈在樹莓派上直接編譯,參見這里

 
git clone https://github.com/pixhawk/rpi_toolchain.git cd rpi_toolchain ./install_cross.sh 

在工具鏈安裝過程中需要輸入密碼。

如果不想把工具鏈安裝在默認位置/opt/rpi_toolchain,可以執行./install_cross.sh <PATH>向安裝腳本傳入其它地址。安裝腳本會自動配置需要的環境變量。

最后,運行以下命令更新環境變量:

source ~/.profile

Raspberry Pi 2 開發板

以下命令編譯生成Raspbian(posix_pi2_release)版本的固件。

cd Firmware make posix_rpi2_release # for cross-compiler build 

"mainapp"可執行文件位於目錄build_posix_rpi2_release/src/firmware/posix下。 將其復制到RPi(用你的RPi的IP或主機名替換YOUR_PI,關於如何訪問你的RPi,查看介紹)

然后使用以下命令設置你的RPi的IP(或主機名):

export AUTOPILOT_HOST=192.168.X.X 

並上傳:

cd Firmware make posix_rpi_cross upload # for cross-compiler build 

然后,通過ssh連接並運行它(以root權限):

sudo ./px4 px4.config

 

二、自己的添加和總結

make posix_rpi_cross后出現的問題:

-- CMAKE_MODULE_PATH: /home/myfly2/src/myFirmware/Firmware/cmake
-- Build Type: RelWithDebInfo
-- PX4 VERSION: v1.6.5-114-g4ccbeb4
-- CONFIG: posix-rpi-cross
-- CMAKE_INSTALL_PREFIX: /usr
-- The CXX compiler identification is unknown
-- The C compiler identification is unknown
-- The ASM compiler identification is unknown
-- Found assembler: arm-linux-gnueabihf-gcc
CMake Error at CMakeLists.txt:275 (project):
  The CMAKE_CXX_COMPILER:

    arm-linux-gnueabihf-g++

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.


CMake Error at CMakeLists.txt:275 (project):
  The CMAKE_C_COMPILER:

    arm-linux-gnueabihf-gcc

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.


CMake Error at CMakeLists.txt:275 (project):
  The CMAKE_ASM_COMPILER:

    arm-linux-gnueabihf-gcc

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "ASM" or the CMake cache entry CMAKE_ASM_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.


-- Warning: Did not find file Compiler/-ASM
-- Configuring incomplete, errors occurred!
See also "/home/myfly2/src/myFirmware/Firmware/build_posix_rpi_cross/CMakeFiles/CMakeOutput.log".
See also "/home/myfly2/src/myFirmware/Firmware/build_posix_rpi_cross/CMakeFiles/CMakeError.log".
/bin/sh: 1: cd: can't cd to /home/myfly2/src/myFirmware/Firmware/build_posix_rpi_cross
Makefile:158: recipe for target 'posix_rpi_cross' failed
make: *** [posix_rpi_cross] Error 2

 

解決辦法:

修改~/.profile,增加環境:

export RPI_TOOLCHAIN_DIR=/opt/rpi_toolchain/gcc-linaro-arm-linux-gnueabihf-raspbian
export PATH=$RPI_TOOLCHAIN_DIR/bin:$PATH
export AUTOPILOT_HOST=192.168.1.105

然后:

source ~/.profile

 

繼續出現問題2:

-- CMAKE_MODULE_PATH: /home/myfly2/src/myFirmware/Firmware/cmake
-- Build Type: RelWithDebInfo
-- PX4 VERSION: v1.6.5-114-g4ccbeb4
-- CONFIG: posix-rpi-cross
-- CMAKE_INSTALL_PREFIX: /usr
-- The CXX compiler identification is GNU 4.8.3
-- The C compiler identification is GNU 4.8.3
-- The ASM compiler identification is GNU
-- Found assembler: /opt/rpi_toolchain/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc
-- Check for working CXX compiler: /opt/rpi_toolchain/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++
-- Check for working CXX compiler: /opt/rpi_toolchain/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /opt/rpi_toolchain/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc
-- Check for working C compiler: /opt/rpi_toolchain/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PythonInterp: /usr/bin/python (found version "2.7.12") 
CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
  couldn't find python module jinja2:

          

  for debian systems try:         

      sudo apt-get install python-jinja2         

  or for all other OSs/debian:         

      sudo -H pip install jinja2

   (missing:  PY_JINJA2) 
Call Stack (most recent call first):
  /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
  cmake/common/px4_base.cmake:621 (find_package_handle_standard_args)
  CMakeLists.txt:295 (px4_find_python_module)


-- Configuring incomplete, errors occurred!
See also "/home/myfly2/src/myFirmware/Firmware/build_posix_rpi_cross/CMakeFiles/CMakeOutput.log".
/bin/sh: 1: cd: can't cd to /home/myfly2/src/myFirmware/Firmware/build_posix_rpi_cross
Makefile:158: recipe for target 'posix_rpi_cross' failed
make: *** [posix_rpi_cross] Error 2

這個問題少了jinja2:

sudo apt-get install python-jinja2  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM