Building ArduPilot for Pixhawk/PX4 on Linux with Make

This article shows how to build ArduPilot for Pixhawk, Pixhawk2, PixRacer and the original PX4 (obsolete) on Linux with Make.


The commands for building Pixhawk and Pixhawk2 are identical (make px4-v2). Building for Pixracer is the same except make px4-v4 is used. For the older (obsolete) PX4 use make px4-v1.

Quick start

For Ubuntu, follow these steps to build the code. For other distributions, see the advanced instructions below.


Install git:

sudo apt-get -qq -y install git

Clone the source:

git clone
cd ardupilot
git submodule update --init --recursive

Run the script:

Tools/scripts/ -y

Reload the path (log-out and log-in to make permanent):

. ~/.profile


The commands below show how to build for Pixhawk/Pixhawk2 on the different platforms. To build for Pixracer replace make px4-v2 with make px4-v4. For the original (obsolete) PX4 use make px4-v1.

Build for Copter:

cd ArduCopter
make px4-v2

Build for Plane:

cd ArduPlane
make px4-v2

Build for Rover:

cd APMrover2
make px4-v2

Build for Antenna Tracker:

cd AntennaTracker
make px4-v2


To build for a Pixhawk2/Pixhawk/PX4 target on Linux you need the following tools and git repositories:

  • The gcc-arm cross-compiler from here
  • The ardupilot git repository from
  • gnu make, gawk and associated standard Linux build tools
  • On Ubuntu you will need to install the genromfs package.
  • On a 64 bit system you will also need to have installed libc6-i386.


You need to make your user a member of the dialout group:

sudo usermod -a -G dialout $USER

You will need to log out and then log back in for the group change to take effect.

Also, it’s worth mentioning here that you want to ensure that the modemmanager package is not installed and the modem-manager process is not running.

Directory Layout

The ardupilot, PX4NuttX and PX4Firmware git checkouts all need to be in the same directory. The makefile looks in the directory above the ardupilot directory to find the PX4NuttX and PX4Firmware trees.


You need the specific gcc-arm cross-compiler linked above. You need to unpack it:

tar -xjvf gcc-arm-none-eabi-4_9-2015q3-20150921-linux.tar.bz2

and then add the bin directory from the tarball to your $PATH by editing the $HOME/.bashrc file and adding a line like this to the end:

export PATH=$PATH:/home/your_username/bin/gcc-arm-none-eabi-4_9-2015q3/bin

ccache for faster builds

Installing ccache will speed up your builds a lot. Once you install it (for example with “sudo apt-get install ccache”) you should link the compiler into /usr/lib/ccache like this:

cd /usr/lib/ccache
sudo ln -s /usr/bin/ccache arm-none-eabi-g++
sudo ln -s /usr/bin/ccache arm-none-eabi-gcc

Then add /usr/lib/ccache to the front of your $PATH


One you have the 3 git trees and compiler setup you do the build in your vehicle directory. For example, if building Plane then do this:

cd ArduPlane
make px4

That will build two files ArduPlane-v1.px4 and ArduPlane-v2.px4. The v1 file is for PX4v1, the v2 file is for PX4v2 (the Pixhawk).

You can also build for just one board by using “make px4-v1” or “make px4-v2”.

The first time you build it will take quite a long time as it builds the px4 archives. Subsequent builds will be faster (especially if you setup ccache correctly).

Loading firmware

To load the firmware onto the board use

make px4-v1-upload


make px4-v2-upload

After it says “waiting for bootloader” plugin your PX4 on USB.

If upload consistently fails in the erase step then check if you are running ‘modemmanager’ which can take control of the PX4 USB port. Removing modemmanager can help.


If there have been updates to the PX4NuttX or PX4Firmware git submodules you may need to do a full clean build. To do that use:

make px4-clean

that will remove the PX4NuttX archives so you can do a build from scratch