Building ArduPilot for Pixhawk/PX4 on Windows with Make¶
This article shows how to build ArduPilot for Pixhawk 2, Pixhawk and PX4 on Windows with Make.
The commands for building Pixhawk are (
make px4-v2). Building for Pixhawk2.1 is the same except
make px4-v3 is used. Building for Pixracer is the same except
make px4-v4 is used. For the older (obsolete) PX4 use
Install GitHub for Windows
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
Clone the ardupilot repository onto your machine:
- Go to the GitHub/ArduPilot/ardupilot web page and click the Clone in Desktop button
- Warning: be careful that the directory path is less than about 50 characters. For example “C:\Users\rmackay9\Documents\GitHub\ardupilot” is short enough but “C:\Users\rmackay9\Documents\GitHub\rmackay9-ardupilot” is too long. This limit is because during compiling temporary files are created with much much longer paths which can exceed Windows’ 260 character path limit.
Initialise and update submodules
git submodule update --init --recursive
Download and install the PX4 toolchain by running the pixhawk_toolchain_installer_latest.exe
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:
Build the firmware by entering one of the following commands:
||Build the Pixhawk firmware for a quad|
||Build the Pixhawk2.1 firmware for a quad|
||Build the PixRacer firmware for quad|
||Build both PX4 (obsolete) and PixHawk firmware for a quadcopter|
||“clean” the ardupilot directory|
||“clean” the PX4Firmware and PX4NuttX directories so the next build will completely rebuild them|
||“clean” .d and .o files from the PX4Firmware and PX4NuttX directories. faster but less complete rebuild compared to “px4-clean”|
||Build and upload the Pixhawk firmware for a quad (i.e. no need to upload using a ground station)|
The firmware will be created in the ArduCopter directory with the .px4 file extension.
- Upload the firmware using the Mission Planner Initial Setup | Install Firmware screen’s Load custom firmware link
ArduPilot imports addition projects (PX4Firmware, PX4NuttX, uavcan) as git submodules when you build the project. If you built the project before the change to submodules you may get errors. See Git Submodules for troubleshooting information.
You can ignore any mesages regarding PX4Firmware and PX4Nuttx hashes. Those are useful labels for developers but optional and sometimes the build system can’t find them on your system. As long as it says “Firmware is in..” followed by a .px4 file then you have a successful build which you can safely load onto your aircraft.
Hints for speeding up compile time¶
Anti virus protection is likely to slow the compile times especially for PX4 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