一.基本信息:
1.软件系统:
Ubuntu 14.04 64bit
2.源码位置:
https://github.com/PX4/Firmware
3.参考博客:
(1)libing403的博客
(2)yangcs2009的博客
二.编译过程:
1.权限设置:
// 把用户添加到用户组“dialout”:
sudo usermod -a -G dialout $USER
2.安装依赖包:
(1)安装相应依赖:
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 apt-get install ant protobuf-compiler libeigen3-dev libopencv-dev openjdk-7-jdk openjdk-7-jre clang-3.5 lldb-3.5 -y
(2)Ubuntu配备了一系列代理管理,这会严重干扰任何机器人相关的串口(或usb串口),卸载掉它也不会有什么影响:
sudo apt-get remove modemmanager
(3)继续安装相关依赖包:
sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded -y
sudo apt-get update
sudo apt-get install python-serial openocd flex bison libncurses5-dev autoconf texinfo build-essential libftdi-dev libtool zlib1g-dev python-empy gcc-arm-none-eabi -y
3.安装编译工具cmake:
(1)下载cmake:
(2)安装cmake:
cd /usr/local
tar -zxv -f cmake-3.2.2.tar.gz
cd cmake-3.2.2
./configure
make
make install
mv cmake-3.2.2 cmake
(3)添加环境变量:
// 打开profile文件:
vi /etc/profile
// 在文件末尾追加以下两行代码:
PATH=/usr/local/cmake/bin:$PATH
export PATH
// 使修改生效并添加环境变量:
source /etc/profile
echo $PATH
(4)检验是否安装成功:
cmake --version
注意:cmake出现问题,如:
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
这种情况请make clean或者重新安装cmake,重新安装方法如下:
wget https://cmake.org/files/v3.4/cmake-3.4.3-Linux-x86_64.sh
chmod +x cmake-3.4.3-Linux-x86_64.sh
sudo mkdir /opt/cmake-3.4.3
sudo ./cmake-3.4.3-Linux-x86_64.sh --prefix=/opt/cmake-3.4.3 --exclude-subdir
export PATH=/opt/cmake-3.4.3/bin:$PATH
4.安装genromfs:
sudo apt-get instrall genromfs
5.编译代码:
mkdir -p ~/src
cd ~/src
git clone https://github.com/PX4/Firmware.git
cd Firmware
git submodule update --init --recursive
make px4fmu-v2_default
6.上传程序:
make px4fmu-v2_default upload
注意:如果编译或者upload显示未安装cmake或者cmake需要更新,说明cmake的全局路径没有配置,需要执行如下命令:
export PATH=/opt/cmake-3.4.3/bin:$PATH