Linux开发环境

官网英文原文地址:http://dev.px4.io/starting-installing-linux.html

我们使用Debian / Ubuntu LTS 作为Linux的标准支持版本,但是也支持Cent OS 和 Arch Linux的发行版本

权限设置

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

把用户添加到用户组 “dialout”:

  1. sudo usermod -a -G dialout $USER

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

安装

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

提示:安装Ninja Build System可以比make更快进行编译。如果安装了它就会自动选择使用它进行编译。

  1. sudo add-apt-repository ppa:george-edison55/cmake-3.x -y
  2. sudo apt-get update
  3. # 必备软件
  4. sudo apt-get install python-argparse git-core wget zip \
  5. python-empy qtcreator cmake build-essential genromfs -y
  6. # 仿真工具
  7. sudo add-apt-repository ppa:openjdk-r/ppa
  8. sudo apt-get update
  9. sudo apt-get install openjdk-8-jre
  10. sudo apt-get install ant protobuf-compiler libeigen3-dev libopencv-dev openjdk-8-jdk openjdk-8-jre clang-3.5 lldb-3.5 -y

基于NuttX的硬件

Ubuntu配备了一系列代理管理,这会严重干扰任何机器人相关的串口(或usb串口),卸载掉它也不会有什么影响:

  1. sudo apt-get remove modemmanager

更新包列表和安装下面的依赖包。务必安装指定的版本的包

  1. sudo apt-get install python-serial openocd \
  2. flex bison libncurses5-dev autoconf texinfo build-essential \
  3. libftdi-dev libtool zlib1g-dev \
  4. python-empy -y

在添加arm-none-eabi工具链之前,请确保删除残余。

  1. sudo apt-get remove gcc-arm-none-eabi gdb-arm-none-eabi binutils-arm-none-eabi gcc-arm-embedded
  2. sudo add-apt-repository --remove ppa:team-gcc-arm-embedded/ppa

如果gcc-arm-none-eabi版本导致PX4/Firmware编译错误,请参考the bare metal installation instructions 手动安装4.9或者5.4版本的arm-none-eabi工具链。

骁龙

工具链安装

  1. sudo apt-get install android-tools-adb android-tools-fastboot fakechroot fakeroot unzip xz-utils wget python python-empy -y
  1. git clone https://github.com/ATLFlight/cross_toolchain.git

Get the Hexagon SDK 3.0 from QDN: https://developer.qualcomm.com/download/hexagon/hexagon-sdk-v3-linux.bin

This will require a QDN login. You will have to register if you do not already have an account.

Now move the following files in the download folder of the cross toolchain as follows:

  1. mv ~/Downloads/hexagon-sdk-v3-linux.bin cross_toolchain/downloads

Install the toolchain and SDK like this:

  1. cd cross_toolchain
  2. ./installv3.sh
  3. cd ..

Follow the instructions to set up the development environment. If you accept all the install defaults you can at any time re-run the following to get the env setup. It will only install missing components.

After this the tools and SDK will have been installed to “$HOME/Qualcomm/…”. Append the following to your ~/.bashrc:

  1. export HEXAGON_SDK_ROOT="${HOME}/Qualcomm/Hexagon_SDK/3.0"
  2. export HEXAGON_TOOLS_ROOT="${HOME}/Qualcomm/HEXAGON_Tools/7.2.12/Tools"
  3. export PATH="${HEXAGON_SDK_ROOT}/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf_linux/bin:$PATH"

Load the new configuration:

  1. source ~/.bashrc

Sysroot Installation

A sysroot is required to provide the libraries and header files needed to cross compile applications for the Snapdragon Flight applications processor.

The qrlSDK sysroot provies the required header files and libraries for the camera, GPU, etc.

Download the file Flight_3.1.1_qrlSDK.zip and save it in cross_toolchain/download/.

  1. cd cross_toolchain
  2. unset HEXAGON_ARM_SYSROOT
  3. ./qrlinux_sysroot.sh

Append the following to your ~/.bashrc:

  1. export HEXAGON_ARM_SYSROOT=${HOME}/Qualcomm/qrlinux_v3.1.1_sysroot

Load the new configuration:

  1. source ~/.bashrc

For more sysroot options see Sysroot Installation

升级ADSP固件

在构建,烧写以及运行代码之前,还需要升级ADSP固件

参考

GettingStarted是另外一个工具链安装向导。HelloWorldDSPAL tests可以用来验证工具链安装和DSP镜像。

DSP的信息可以通过mini-dm查看。

  1. $HOME/Qualcomm/Hexagon_SDK/2.0/tools/mini-dm/Linux_Debug/mini-dm

Note: Alternatively, especially on Mac, you can also use nano-dm.

树莓派

树莓派开发者应该从下面地址下载树莓派Linux工具链。安装脚本会自动安装交叉编译工具链。如果想要用原生树莓派工具链在树莓派上直接编译,参见这里

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

在工具链安装过程中需要输入密码。

如果不想把工具链安装在默认位置/opt/rpi_toolchain,可以执行./install_cross.sh <PATH>向安装脚本传入其它地址。安装脚本会自动配置需要的环境变量。

Finally, run the following command to update the environmental variables:

  1. source ~/.profile

Parrot Bebop

Developers working with the Parrot Bebop should install the RPi Linux Toolchain. Follow the
description under Raspberry Pi hardware.

Next, install ADB.

sh sudo apt-get install android-tools-adb -y`

完成

继续,进行第一次构建!