Building ArduPilot on Windows with Bash¶
This build method is EXPERIMENTAL for windows, although it can work well for some users, you may prefer to look at the more tested/proven windows build process here: http://ardupilot.org/dev/docs/building-px4-with-make.html
This article shows how to build ArduPilot on Windows10, using the new “Bash on Ubuntu on Windows”.
Since Windows 10 has Ubuntu as his new partner, it is possible to compile Ardupilot (apm1/apm2, Pixhawk/PX4, SITL...) in Windows without adding any strange thing: just install “Bash on Ubuntu on Windows” and follow next tutorial.
This tutorial is intended to be a “copy & paste” approach. Just follow text step by step and be patient with yourself.
“Bash on Ubuntu on Windows” only works under Windows10 x64.
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 APM1/APM2.x off the master branch (you will need to build off a supported release branch).
For install “Bash on Ubuntu on Windows” there are many tutorials on the web. An example is here: <http://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/>`__.
Setup Ardupilot Dev Enviromment for Ubuntu bash on Windows 10¶
First, you have to insert your local host to the /etc/hosts file:
sudo nano /etc/hosts
Insert this below first line:
(where “hostname” is your PC name)
Then, take root control over the bash:
sudo passwd root su root
Back to main directory:
sudo apt-get install git
Install Arduino Core (for APM1/APM2 support):
sudo apt-get install make gawk arduino-core
Make a new folder for future reference:
mkdir GitHub cd GitHub
Clone ardupilot git:
git clone https://github.com/ArduPilot/ardupilot.git
Run the install-prereqs-ubuntu.sh script:
At this point, we need to install some extra tools, because for now, Ubuntu bash on Windows only supports native x64 programs:
cd sudo add-apt-repository ppa:george-edison55/cmake-3.x -y sudo apt-get update sudo apt-get install cmake sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install g++-4.9 sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded sudo apt-get update sudo apt-get install gcc-arm-none-eabi=18.104.22.1685q3-1trusty1 sudo apt-get update sudo apt-get upgrade
Now you have a nice compiler under Windows 10 thanks to Ubuntu.Next step is to prove it!
Compile ArduPilot Code¶
For apm1/apm2 support is necesary to make a “config.mk” file (for compile ArduCopter 3.2.1), so navigate to main ardupilot git folder:
cd cd GitHub/ardupilot
Is necesary to select correct branch (last supported release branch):
git checkout ArduCopter-3.2.1 cd ArduCopter make configure
If everything is ok, compile the code:
cd ArduCopter make apm1
Otherwise, if you want to compile last ArduPlane compatible code whith apm1/2 (ArduPlane 3.4), you need to preserve above commented “config.mk” file and change your git branch:
cd cd GitHub/ardupilot git checkout ArduPlane-release-AVR
If everything is ok, compile the code:
cd ArduPlane make apm1
If you want to compile Pixhawk/PX4 code, “config.mk” file is not necesary. So if you have compiled apm1/apm2 code, you have to remove it:
cd cd GitHub/ardupilot rm config.mk
Now, select correct branch (for example, master branch):
cd cd GitHub/ardupilot git checkout master
Navigate to your desired Ardupilot vehicle folder, in this case (complete path):
cd cd GitHub/ardupilot/vehicle
(where “vehicle” can be ArduCopter, ArduPlane, ArduRover,...)
In your vehicle folder, type “make” and press enter for see supported targets for compile. Just type “make” and your target for compile it, in this case:
vehicle make board
(where “board” can be px4-v2, navio, pxf,... Must see supported targets as mentioned above)
If everything is ok, you will see a message like this (depends of your target): PX4 ArduCopter Firmware is in ArduCopter-v2.px4
The new method of compilation “Waf” is also supported. Go to git ardupilot software:
cd cd GitHub/ardupilot/
It’s possible to get a list of supported boards on ArduPilot with the command below:
Configure your board:
./waf configure --board target
(where “target” can be px4-v2, navio, pxf,... Must see supported boards as mentioned above)
Compile for your target:
(where “vehicle” can be copter, plane, rover,...)
And here you are! You have compiled your code!
if you want to unhide Ubuntu system folder on Windwos, open a command prompt as administrator, navigate to Ubuntu system path (C:UsersusernameAppDataLocal) and change the folder attributes. So (where “username” is your user name):
cd C:\Users\username\AppData\Local attrib -s -h lxss
You can make a direct access to “lxss” folder on your desktop for a quick navigation.