编译环境准备

​ Ardupilot源码下载和PX4 toolchain工具链下载

​ (见https://www.cnblogs.com/BlogsOfLei/p/7707485.html)

注意:最新版本的github已经支持下载工程项目中的子模块。如果喜欢git bash终端指令下载,可见:

https://www.cnblogs.com/BlogsOfLei/p/8624650.html

终端编译

​ 打开终端PX4 Console,进入固件对用的文件下。此处以编译四旋翼固件为例,如下图:

Make编译Ardupilot源码的两种方法-LMLPHP

​ make px4-v2编译选项,选择编译px4-v2固件,回车确定,等待编译完成。编译成功得到的固件在ArduCopter文件下,名称为***.px4。

编译选项说明

make px4-v3Build The Cube firmware for a quad
make px4-v4Build the PixRacer firmware for quad
make px4Build both PX4 (obsolete) and PixHawk firmware for a quadcopter
make clean“clean” the ardupilot directory
make px4-clean“clean” the PX4Firmware and PX4NuttX directories so the next build will completely rebuild them
make px4-cleandep“clean” .d and .o files from the PX4Firmware and PX4NuttX directories. faster but less complete rebuild compared to “px4-clean”
make px4-v2-uploadBuild and upload the Pixhawk firmware for a quad (i.e. no need to upload using a ground station)

Eclipse 编译

  Make编译Ardupilot源码的两种方法-LMLPHP

  • 新加编译选项

  Make编译Ardupilot源码的两种方法-LMLPHP

  • 点击编译选项进行编译,等待编译完成。编译成功后,生成的目标文件位于ArduCopter目录文件下,格式为***.px4。

04-25 12:11