Linux下px4开发环境的搭建

安装依据
http://dev.px4.io/en/setup/dev_env_linux_ubuntu.html

安装脚本执行

选择快捷脚本ubuntu_sim_nuttx.sh安装,内容如下:

#!/bin/bash

## Bash script for setting up a PX4 development environment for Pixhawk/NuttX targets on Ubuntu LTS (16.04).
## It can be used for installing simulators and the NuttX toolchain.
##
## Installs:
## - Common dependencies libraries, tools, and Gazebo8 simulator as defined in `ubuntu_sim.sh`
## - NuttX toolchain (i.e. gcc compiler)

echo "Downloading dependent script 'ubuntu_sim.sh'"
# Source the ubuntu_sim.sh script directly from github
ubuntu_sim=$(wget https://raw.githubusercontent.com/PX4/Devguide/master/build_scripts/ubuntu_sim.sh -O -)
wget_return_code=$?
# If there was an error downloading the dependent script, we must warn the user and exit at this point.
if [[ $wget_return_code -ne 0 ]]; then echo "Error downloading 'ubuntu_sim.sh'. Sorry but I cannot proceed further :("; exit 1; fi
# Otherwise source the downloaded script.
. <(echo "${ubuntu_sim}")

# NuttX
sudo apt-get install python-serial openocd \
    flex bison libncurses5-dev autoconf texinfo \
    libftdi-dev libtool zlib1g-dev -y

# Clean up old GCC
sudo apt-get remove gcc-arm-none-eabi gdb-arm-none-eabi binutils-arm-none-eabi gcc-arm-embedded -y
sudo add-apt-repository --remove ppa:team-gcc-arm-embedded/ppa -y


# GNU Arm Embedded Toolchain: 7-2017-q4-major December 18, 2017
gcc_dir=$HOME/gcc-arm-none-eabi-7-2017-q4-major
echo "Installing GCC to: $gcc_dir"
if [ -d "$gcc_dir" ]
then
    echo " GCC already installed."
else
    pushd .
    cd ~    
    wget https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/7-2017q4/gcc-arm-none-eabi-7-2017-q4-major-linux.tar.bz2
    tar -jxf gcc-arm-none-eabi-7-2017-q4-major-linux.tar.bz2
    exportline="export PATH=$HOME/gcc-arm-none-eabi-7-2017-q4-major/bin:\$PATH"
    if grep -Fxq "$exportline" ~/.profile; then echo " GCC path already set." ; else echo $exportline >> ~/.profile; fi
    . ~/.profile
    popd
fi


# Go to the firmware directory
cd $clone_dir/Firmware

#Reboot the computer (required before building)
echo RESTART YOUR COMPUTER to complete installation of PX4 development toolchain

Make the user a member of the group “dialout” (this only has to be
done once):
1.Open a terminal and enter the following command: sudo usermod -a -G dialout $USER

2.Logout and login again (the change is only made after a new login).

更改用户等级,增加dialout组:

sudo usermod -a -G dialout xxx

先touch一个ubuntu_sim_nuttx.sh文件,把脚本内容复制进去,然后在终端里source这个脚本文件,最好可以去弄,其中一个文件下载会特别费劲。
脚本结束后,按提示reboot。

touch ubuntu_sim_nuttx.sh
……
source ubuntu_sim_nuttx.sh

这个地方提示Python可能会出问题,先看看。
Linux下px4开发环境的搭建_第1张图片
Permission Setup
这里提示不要用 sudo 修正权限问题,强调用户要是 dialout组成员。

官网提示要卸载USB设备的管理器,但是脚本里已经执行过了

Remove the modemmanager Ubuntu comes with a serial modem manager which
interferes heavily with any robotics related use of a serial port (or
USB serial). It can removed/deinstalled without side effects: sudo
apt-get remove modemmanager

还有一些库的安装:

Common Dependencies Update the package list and install the following
dependencies for all PX4 build targets.

sudo apt-get update -y
sudo apt-get install git zip qtcreator cmake build-essential genromfs ninja-build exiftool vim-common -y

Required python packages

sudo apt-get install python-argparse python-empy python-toml python-numpy python-yaml python-dev python-pip -y
sudo -H pip install --upgrade pip 
sudo -H pip install pandas jinja2 pyserial cerberus

多数软件包都已经是最新的版本了,但是.sh文件到底干了什么有待考察
Linux下px4开发环境的搭建_第2张图片
Linux下px4开发环境的搭建_第3张图片

You may also wish to install pyulog. This is is a useful python package that contains scripts to parse ULogfiles and display them.

optional python tools

sudo -H pip install pyulog

Ninja Build System

sudo apt-get install ninja-build -y

然而这个也已经安好了……

sudo apt-get install ninja-build -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
ninja-build is already the newest version (1.5.1-0.1ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

make的时候会发现一些错误,之前就一直卡在这里了
Linux下px4开发环境的搭建_第4张图片
cmake的错误:
提示 arm-none-eabi-gcc等工具,不是全路径,也不在PATH环境里面
检查最前面的安装脚本,有关arm-gcc的安装过程如下:

GNU Arm Embedded Toolchain: 7-2017-q4-major December 18, 2017 gcc_dir=$HOME/gcc-arm-none-eabi-7-2017-q4-major echo “Installing GCC
to: g c c d i r " i f [ − d " gcc_dir" if [ -d " gccdir"if[d"gcc_dir” ] then
echo " GCC already installed." else
pushd .
cd ~
wget https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/7-2017q4/gcc-arm-none-eabi-7-2017-q4-major-linux.tar.bz2
tar -jxf gcc-arm-none-eabi-7-2017-q4-major-linux.tar.bz2
exportline=“export PATH=$HOME/gcc-arm-none-eabi-7-2017-q4-major/bin:$PATH”
if grep -Fxq “$exportline” ~/.profile; then echo " GCC path already set." ; else echo $exportline >> ~/.profile; fi
. ~/.profile
popd fi

可知,安装过程就是wget , tar , 再设置.profile当中的PATH这三步。
检查 ~/gcc-arm-none-eabi-7-2017-q4-major/bin ,发现没这个目录。
下载的tar.bz2文件其实不完整,所以用迅雷下载后再手工解压,问题解决。。。

这个问题来源是.sh里面
wget https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/7-2017q4/gcc-arm-none-eabi-7-2017-q4-major-linux.tar.bz2

这一句废了,下载下来的东西是坏的,直接解压缩就发现压缩包已经损坏了

所以在Windows下面用迅雷先下载好拷过来,发现大小差了很多。
Linux下px4开发环境的搭建_第5张图片
最后在选择编译版本的时候
make px4_fmu-v3_default
make px4_fmu-v3_default upload

最后得到的结果:

strange@strange-Alienware-13-R3:~/src/Firmware$ make px4_fmu-v3_default
-- PX4 config file: /home/strange/src/Firmware/boards/px4/fmu-v3/default.cmake
-- PX4 config: px4_fmu-v3_default
-- PX4 platform: nuttx
-- PX4 lockstep: disabled
-- PX4 version: v1.9.0-beta1-29-gcdb6aca
-- cmake build type: MinSizeRel
-- The CXX compiler identification is GNU 7.2.1
-- The C compiler identification is GNU 7.2.1
-- The ASM compiler identification is GNU
-- Found assembler: /home/strange/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-gcc
-- Check for working CXX compiler using: Ninja
-- Check for working CXX compiler using: Ninja -- 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 using: Ninja
-- Check for working C compiler using: Ninja -- 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") 
-- Found PY_jinja2: /usr/local/lib/python2.7/dist-packages/jinja2  
-- PX4 ECL: Very lightweight Estimation & Control Library v0.9.0-623-g721f5e6
-- Building and including px4_io-v2_default
-- Using C++11
-- Release build type: MinSizeRel
-- Adding UAVCAN STM32 platform driver
-- ROMFS: px4fmu_common
-- ROMFS: Adding rc.board_defaults
-- ROMFS: Adding rc.board_sensors
-- Configuring done
-- Generating done
-- Build files have been written to: /home/strange/src/Firmware/build/px4_fmu-v3_default
ninja: Entering directory `/home/strange/src/Firmware/build/px4_fmu-v3_default'
[10/1134] git submodule platforms/nuttx/NuttX/nuttx
[16/1134] git submodule src/lib/ecl
[17/1134] git submodule src/drivers/gps/devices
[18/1134] git submodule src/drivers/uavcan/libuavcan
[19/1134] git submodule mavlink/include/mavlink/v2.0
[20/1134] git submodule platforms/nuttx/NuttX/apps
[71/1134] Performing configure step for 'px4io_firmware'
-- PX4 config file: /home/strange/src/Firmware/boards/px4/io-v2/default.cmake
-- PX4 config: px4_io-v2_default
-- PX4 platform: nuttx
-- PX4 lockstep: disabled
-- PX4 version: v1.9.0-beta1-29-gcdb6aca
-- cmake build type: MinSizeRel
-- The CXX compiler identification is GNU 7.2.1
-- The C compiler identification is GNU 7.2.1
-- The ASM compiler identification is GNU
-- Found assembler: /home/strange/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-gcc
-- Check for working CXX compiler using: Ninja
-- Check for working CXX compiler using: Ninja -- 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 using: Ninja
-- Check for working C compiler using: Ninja -- 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") 
-- Found PY_jinja2: /usr/local/lib/python2.7/dist-packages/jinja2  
-- PX4 ECL: Very lightweight Estimation & Control Library v0.9.0-623-g721f5e6
-- Configuring done
-- Generating done
-- Build files have been written to: /home/strange/src/Firmware/build/px4_fmu-v3_default/external/Build/px4io_firmware
[170/1134] Performing build step for 'px4io_firmware'
[7/215] git submodule platforms/nuttx/NuttX/nuttx
[9/215] git submodule platforms/nuttx/NuttX/apps
[215/215] Creating px4_io-v2_default.px4
[1134/1134] Creating px4_fmu-v3_default.px4
strange@strange-Alienware-13-R3:~/src/Firmware$ make px4_fmu-v3_default upload
ninja: Entering directory `/home/strange/src/Firmware/build/px4_fmu-v3_default'
[3/3] uploading px4
Loaded firmware for board id: 9,0 size: 1615444 bytes (77.64%), waiting for the bootloader...


Found board id: 9,0 bootloader version: 5 on /dev/serial/by-id/usb-3D_Robotics_PX4_BL_FMU_v2.x_0-if00
sn: 0037001b3236511737353639
chip: 20016419
family: STM32F42x
revision: 3
flash: 2080768 bytes
Windowed mode: False

Erase  : [====================] 100.0%
Program: [====================] 100.0%
Verify : [====================] 100.0%
Rebooting. Elapsed Time 28.789

你可能感兴趣的:(Ubuntu,px4,pixhawk开发环境,无人机,飞控)