Setting up the waf Build Environment on Windows10 using WSL¶
These setup instructions describe how to setup “Bash on Ubuntu on Windows” (aka “Windows Subsystem for Linux”) which allows building with waf. Alternative setup instructions for building with make are here.
Starting with the Fall Creators Update (Windows 10 version 1803), enabling the Developer Mode is not longer required for using WSL.
Enable Ubuntu on Windows which includes the following steps (original How-To Geek’s instructions here):
Under Control Panel >> Programs >> Turn Windows features on or off, enable “Windows Subsystem for Linux
Open the Microsoft Store and install Ubuntu 18.04 (Direct link: https://www.microsoft.com/en-us/p/ubuntu-1804-lts/9n9tngvndl3q)
Push the Launch button which will open a Bash terminal and ask for a username and password
From withing the Ubuntu bash terminal, update your system to the latest packages:
sudo apt-get update && sudo apt-get upgrade
Copy the Ardupilot source files to your local Ubuntu filesystem by cloning the git repository and updating the submodules. (Accessing the source files on your Windows filesystem won’t work because the must be kept on the native WSl filesystem)
git clone https://github.com/ardupilot/ardupilot.git
git submodule update --init --recursive
run the Tools/environment_install/install-prereqs-ubuntu.sh script:
- You will be asked for your Ubuntu root password which is the password provided in step 1 (above). Respond with “Y” if it asks if you wish to install a package.
Build with Waf¶
You should now be able to start the “Ubuntu” application from your Windows Start menu and build with waf as described in BUILD.md.
As of Windows 10 Build 16176 (April 2017), WSL (Windows Subsystem Linux) has support for access to USB serial peripherals. If you have not updated, please do so. That will allow you to compile and upload directly with the waf –upload option. You can also upload using a ground station. For example Mission Planner’s Initial Setup >> Install Firmware screen has a “Load custom firmware” link on the bottom right. If this link is not visible, open Config/Tuning >> Planner and set the “Layout” to “Advanced”.
For network connected flight controllers, such as linux targets, –upload does function as described in BUILD.md
You can run XWindows applications (including SITL) by installing VcXsrv on Windows. For code editing you can install VSCode inside WSL.
If you want to unhide Ubuntu system folder on Windows, open a command prompt as administrator, navigate to Ubuntu system path (C:\Users\username\AppData\Local) and change the folder attributes. So (where “username” is your user name):
cd C:\Users\username\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState attrib -s -h rootfs
You can make a direct access to “lxss” folder on your desktop for a quick navigation.
Windows 10 includes “Windows Defender” virus scanner. It will slow down WSL quite a bit. Disabling greating improves disk performance but increases your risk to viruses so disable at your own risk. Here is one of many resources/videos that show you how to disable it: https://www.youtube.com/watch?v=FmjblGay3AM