设为首页 收藏本站
查看: 1534|回复: 0

[经验分享] ubuntu配置px4编译环境

[复制链接]

尚未签到

发表于 2017-11-22 18:39:05 | 显示全部楼层 |阅读模式
一、主要参考的内容
  px4的开发者手册
  https://dev.px4.io/zh/setup/dev_env_linux.html
  其中有的shell指令

权限设置

  警告:永远不要使用sudo来修复权限问题,否则会带来更多的权限问题,需要重装系统来解决。

  把用户添加到用户组 "dialout":



sudo usermod -a -G dialout $USER

  然后注销后,重新登录,因为重新登录后所做的改变才会有效。

安装
  更新包列表,安装下面编译PX4的依赖包。PX4主要支持的系列:


  • NuttX based hardware: Pixhawk, Pixfalcon, Pixracer, Crazyflie, Intel® Aero Ready to Fly Drone
  • Qualcomm Snapdragon Flight hardware
  • Linux-based hardware: Raspberry Pi 2/3, Parrot Bebop
  • Host simulation: jMAVSim SITL and Gazebo SITL

  提示:安装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

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-409597-1-1.html 上篇帖子: 【fail2ban】使用fail2ban进行攻击防范 下篇帖子: 享受Python和PHP动态类型检查语言的快感
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表