Building ArduPilot for APM2.x on Windows with Make

This article shows how to build ArduPilot for APM2.x on Windows with Make.

Tip

The approach described here is useful if you want to develop using Eclipse. Building ArduPilot for APM2.x on Windows with Arduino shows an alternative method for building ArduPilot for APM2.x.

Warning

Copter 3.3 firmware (and later) and builds after Plane 3.4.0 no longer fit on APM boards. Plane, Rover and AntennaTracker builds can still be installed at time of writing but you can no longer build APM2.x off the master branch (you will need to build off a supported release branch, or for the keen developer, from the AVR-master branch master-AVR and the tags from there. see: https://github.com/ArduPilot/ardupilot/tree/master-AVR ).

The last Copter firmware that can be built on APM 2.x can be downloaded from here.

Overview

These instructions use the PX4 Toolchain along with the Arduino Tools to set up an environment in which you can build for APM2.x targets with make. They have been tested on Windows 10 to build the ArduCopter-3.2.1 branch.

Note

This article replaces previous instructions to use a basic Cygwin installation with the GNU sed, make and awk packages installed. The pre-built environment from the PX4 Toolchain is a lot easier to set up.

Build instructions

  1. Install GitHub for Windows

  2. Ensure your github settings are set to leave line endings untouched.

    • The “Git Shell (or Bash)” terminal was also installed when you installed Git. Click on your new “Git Shell (or Bash)” Icon and type in the following in the Git “MINGW32” Terminal window:

      git config --global core.autocrlf false
      
  3. Get the source code onto your machine

    • In the Git “MINGW32” Terminal window navigate to where you want to put the source code and clone the repo

      git clone --recurse-submodules https://github.com/ArduPilot/ardupilot.git
      cd ardupilot
      
    • Checkout the branch you want to build (the last branch you can use for Copter is shown below):

      git checkout ArduCopter-3.2.1
      
  4. Install the special ArduPilot Arduino package. This contains gcc 4.8.2 and Eclipse “Luna”.

    • Download the installation zip: ArduPilot-Arduino-1.0.3-gcc-4.8.2-windows.zip

    • Unzip the file to the root of the C drive

      Note

      You can install

      anywhere. Later on we update config.mk to tell the build system where the tools are located.

  5. Download and install the PX4 toolchain by running the px4_toolchain_installer_v14_win.exe

  6. Open the PX4Console and navigate to the target vehicle directory:

    • Start the PX4Console. This can be found under Start | All Programs | PX4 Toolchain (Windows 7 machine) or you can directly run C:\px4\toolchain\msys\1.0\px4_console.bat

    • Navigate to the vehicle-specific ArduPilot directory in the PX4Console. For example, to build Copter, navigate to:

      cd /c/Users/<username>/Documents/GitHub/ardupilot/ArduCopter
      
  7. Configure the build system to find the Arduino tools:

    • Enter the following command on the PX4Console to create /ardupilot/config.mk.

      make configure
      
    • Open config.mk (created in the directory above ArduCopter) and define the ARDUINO variable as shown:

      ARDUINO = C:/arduino-1.0.3-windows
      

      Note

      You must specify the drive letter and use forward

      slashes for the path.

  8. Build the firmware by entering the following command on the PX4Console:

    make apm2
    

    Tip

    This command can take several minutes before it is obvious that something is happening!

    The firmware will be created in a subfolder of the user’s temp directory. For example you will find ArduCopter.hex in C:\Users\*YourUserNameHere*\AppData\Local\Temp\ArduCopter.build.

  9. Upload the firmware using the Mission Planner Initial Setup | Install Firmware screen’s Load custom firmware link

Hints for speeding up compile time

Anti virus protection is likely to slow the compile times especially for Pixhawk so it is recommended that the folders containing the ArduPilot source code is excluded from your virus protections real-time scan.

The first scan after a make px4-clean will be very slow as it rebuilds everything