Using Bash on Windows for ArduPilot development

This is a crosspost from drones-discuss, but hopefully it is of interest here as well:

Just wanted you to know that I’ve downloaded the preview build of Windows 10 with Linux usermode enabled. This is a OS feature that can be enabled, and essentially runs the Ubuntu Userspace in a separate process and then emulates calls down to the OS. This is not the same as running Linux in a VM. More details can be found in this video: https://channel9.msdn.com/events/Build/2016/P488

Anyways, using Ubuntu on WIndows I have successfully compiled the arducopter source using gcc, and I can also run sitl (linux-based), mavproxy (linux-based) while communicating with FlightGear (Windows) and python-dronekit (Windows). For me this means I no longer have to spin up a VM or mess with cygwin when testing python code using python-dronekit.

I’ve recorded a little walkthru and uploaded it to youtube here: https://www.youtube.com/watch?v=fxyagN6SNVI

1 Like

very nice!
do the graphical elements of mavproxy work in the linux env? I mean console, map, graphs etc

I haven’t tried, but I would assume no. The Linux instance is only meant for text-based stuff, tho I know someone hacked Firefox to run within the Linux instance.

That’s hilarious. … i did exactly this last week, and reported on my findings to the dev skype channel. Good to see you’ve documented it better than I did.

this works for SITL, i was trying to build px4-v2, fails on symlink and the compiler architecture.

be sure not to try compiling inside /mnt/c/ or /mnt/d/ as those filesystems don’t support symlinks or proper case sensitivity… I used /root, but /tmp would do. also, I went searching for ( and found ) a ‘ppa’ for a 64bit compiled version of gcc-arm-non-eabi, and used that instead of the 32bit version that’s installed by the prerequisites script, and after doing that it allowed me to build for other targets ok. I was thinking of writing a custom .sh script to install the windows10 prerequisites but haven’t got that far yet.

replying to myself here… here’s the three non-standard PPAs I installed:
add-apt-repository ppa:george-edison55/cmake-3.x -y
sudo apt-get update
apt-get install cmake

add-apt-repository ppa:ubuntu-toolchain-r/test ( for gcc 4.9 )
sudo apt-get update
sudo apt-get install g+±4.9

add-apt-repository ppa:terry.guo/gcc-arm-embedded
sudo apt-get update
apt-get install gcc-arm-none-eabi=4.9.3.2015q3-1trusty1

I also had to remove the pre-installed version/s of gcc … for got the exact commands for that.

A custom .sh script for this setup would be really good! I’ll try and get a first version PRed during the next couple of days.

@DavidBuzz
I was following the wiki for WSL however when I tried to execute this command
sudo apt-get install gcc-arm-none-eabi=4.9.3.2015q3-1trusty1
I got the error “version 4.9.3.2015q3-1trusty1 was not found”.

How should I proceed?
Thanks in advance for your help!!
Bill

hi bill, I think you should proceed by doing the following:
1 - identify what has changed since a year ago and fix the issue that prevents you from proceeding.
2 - update the developer wiki with a new pull request so that people coming after you don’t stumble on the same fault
3 - post a message here letting us know that you’ve resolved the problem!.

David,
That is the problem. I’m not proficient enough in linux to figure out how to fix the problem. I just saw a post on the development team group regarding the wiki and that it worked like a charm. I will query that user to see if they had a similar problem.

Thanks,
Bill

google says that maybe this page might help: ( no guarantees , I’ve not tried it)
https://launchpad.net/gcc-arm-embedded/+announcement/13824

What would be the recommended development process/IDE when using Bash on Windows?

Everywhere I look they recommend to develop and edit files in the windows file system("/mnt/c" from bash) using windows tools, like VSCode, and then compiling and running commands from Bash. However, when I have tried this I get compilation errors, which seems to be a common problem. Is there a solution to this compilation errors, or another method for easily working on files the Bash file system?

Hi,

Having played around with Bash on Windows + SITL/Mavproxy, I know that it is possible to install VSCode within Bash and run it on an X Windows environment (e.g. XcSrV). Then you can edit directly within bash without having to touch the Windows File System. You can give it a try and see if it works.

It works perfectly.Just install XcSrv or MobaXterm and start VSCode from bash.

Editing in VSCode for Windows and having source files in /mnt/c or similar only partially works because submodules will have absolute paths (/mnt/c…) which cannot be interpreted by the git plugin in VSCode for Windows.