Building ArduPilot on Windows with waf and Bash

Warning

This build method is ONLY for Windows10 x64 and does not describe building for deprecated Arduino based flight controllers (APM1.x, 2.x). It supports most users, however you may need or prefer to use the alternate windows build process here: http://ardupilot.org/dev/docs/building-px4-with-make.html

../_images/Windows10_Ubuntu_0.jpg

Microsoft has introduced WSL - the Windows Subsystem for Linux - into Windows 10. This tutorial describes “Bash on Ubuntu on Windows”, as it is currently the only released distribution supported by WSL. Other Linux distributions, such as Fedora, are likely to be available in the future however will require slightly different setup to compile Ardupilot.

Warning

This tutorial is intended to be a “copy & paste” guide. Just follow the process step by step and be patient with yourself!

Tip

To 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

  1. First, you have to insert your local host to the /etc/hosts file:

    sudo nano /etc/hosts
    
  2. Insert this below first line:

    127.0.0.1 "hostname"
    

    (where “hostname” is your PC name)

  3. Then, take root control over the terminal:

    sudo passwd root
    su root
    
  4. Back to main directory:

    cd
    
  5. Install git:

    sudo apt-get install git
    
  6. Make a new folder for future reference (optional):

    mkdir GitHub
    cd GitHub
    
  7. Clone ardupilot git:

    git clone https://github.com/ArduPilot/ardupilot.git
    
  8. Run the install-prereqs-ubuntu.sh script:

    ./ardupilot/Tools/scripts/install-prereqs-ubuntu.sh
    
    ../_images/Windows10_Ubuntu_1.jpg
  9. We also need to install some extra tools, so we can compile for the various Ardupilot targets:

    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=4.9.3.2015q3-1trusty1
    
    sudo apt-get update
    sudo apt-get upgrade
    

Compile ArduPilot Code

  1. “Waf” is the preferred build tool for Ardupilot, and works well in Windows with Ubuntu Bash. Go to git ardupilot software:

    cd
    cd GitHub/ardupilot/
    
  2. It’s possible to get a list of supported boards on ArduPilot with the command below:

    ./waf list_boards
    
  3. Configure your board:

    ./waf configure --board target
    

    (where “target” can be px4-v2, navio, pxf,... choose from supported boards as mentioned above)

    ../_images/Windows10_Ubuntu_3.jpg
  4. Compile for your target:

    ./waf vehicle
    

    (where “vehicle” can be copter, plane, rover,...)

    ../_images/Windows10_Ubuntu_4.jpg
  5. And here you are! You have compiled your code!

Note

The released WSL does not have access to USB serial peripherals, so the –upload option in waf will not work over USB. The compiled binary must be uploaded to your flight controller using another tool, such as MissionPlanner as a “Custom Firmware”. If you wish to upload via waf, at time of writing USB serial access is only available in the Windows Insider releases of Windows Subsystem for Linux (WSL), which requires you to join the Windows Insider program. https://insider.windows.com/GettingStarted For network connected flight controllers, such as linux targets, –upload does function as described here: https://github.com/ArduPilot/ardupilot/blob/master/BUILD.md

Tip

if you want to unhide Ubuntu system folder on Windows, 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.