Developer

3689702704?profile=original

Hello everyone!

Since Windows 10 has Ubuntu as his new partner, I have been using the new Ubuntu bash for compile the ArduPilot code. Before this, a Virtual Machine was needed if you wanted to join Linux with Windows; for all is known that this way is a bit frustrating when you want to get full integration between both platforms.

No need to say that if you are a beginner with ArduPilot and you do not know nothing about Linux, you may desist on compile your modifications as you can not do it directly on Windows.

So, here is the solution to compile apm1/apm2 and Pixhawk in Windows without adding any strange thing: install "Bash on Ubuntu on Windows" and follow next tutorial.

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/

All right? Let´s go!

Notes: This tutorial is intended to be a "copy & paste" approach. Just follow text step by step and be patient with yourself ;). Using "Bash on Ubuntu on Windows" was discussed some time ago on "drone-discuss" forum, but I think that no exists a complete guide in the comunity (at least I have not been able to find it). Thanks to everyone that make Ardupilot possible!

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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:
127.0.0.1 "hostname"
         (where "hostname" is your PC name)

-Then, take root control over the bash:
sudo passwd root
su root

-Back to main directory:
cd

-Install git:
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:
./ardupilot/Tools/scripts/install-prereqs-ubuntu.sh

3689702701?profile=original

-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=4.9.3.2015q3-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:
git checkout ArduCopter-3.2.1
cd ArduCopter
make configure

-If everything is ok, compile the code:
cd ArduCopter
make apm1

-Or:
make apm2

-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

-Or:
make apm2


*******************************************************************************************

-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 vehicule folder, in my case (complete path):

cd
cd GitHub/ardupilot/ArduCopter

-In your vehicule folder, type "make" and press enter for see supported targets for compile.
 Just type "make" and your target, in my case:
make px4-v2

-If everything is ok, you will see a message like this:
 PX4 ArduCopter Firmware is in ArduCopter-v2.px4

3689702643?profile=original

*******************************************************************************************

-The new method of compilation "Waf" is also supported.

 Go to git ardupilot software:

cd

cd GitHub/ardupilot/

-Configure your board:

./waf configure --board px4-v2

3689702772?profile=original

-Compile for your target:

./waf copter

3689702717?profile=original

-And here you are! You have compiled your code!

Tips: if you want to unhide Ubuntu system folder on Windwos, open a command prompt as administrator,
navigate to Ubuntu system path (C:\Users\username\AppData\Local) and change the folder attributes. So:
cd C:\Users\username\AppData\Local
         (where "username" is your user name)
attrib -s -h lxss

You can make a direct access to "lxss" folder on your desktop for a quick navigation.

Regards from Spain,

Dario.

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • This is pretty awesome. I can even run SITL in this. I was wondering if there is a way to access the VCOM port created by ftdi. In that case we can run mavproxy to act as ground station. That would be great.

  • Thanks, ist functional

  • @Uwe Blumenhofer

    Although the project was removed from Launchpad the repository is still available and you can install gcc-4.9 using these instructions without any issue - at least, until the Ubuntu subsystem is updated to 16.xx.

  • OK gcc-none-eabi Version 5 not functional with ardupilot

  • new Info gcc4.9 has removed gcc 5 ist active?????

    https://launchpad.net/gcc-arm-embedded/+announcement/13824

    New PPA repository : GNU Arm Embedded Toolchain
  • Dario,

    https://github.com/ArduPilot/ardupilot_wiki

    Would be nice to get this instruction in our wiki, probably replacing older instructions. Thanks

    ArduPilot/ardupilot_wiki
    Repository for Ardupilot wiki issues and wiki-specific website infrastructure. - ArduPilot/ardupilot_wiki
  • Developer

    @Dario, yes, docs are in github here: https://github.com/ArduPilot/ardupilot_wiki

    thanks for the great tutorial!

    ArduPilot/ardupilot_wiki
    Repository for Ardupilot wiki issues and wiki-specific website infrastructure. - ArduPilot/ardupilot_wiki
  • Developer

    Hello everyone!

    @Tridge: I have already corrected the lack of "sudo" command. Sorry for the inconvenience. Normally I always go into Ubuntu as "root", so I usually forget to enter "sudo".

    What is the new system for upload docs to the wiki? GitHub? I have no problem in working on a page for this. Just guide me how to upload it to servers.

    @Nikita P: I have not had the problem of entering the public key ... I have made the installation several months ago and do not remember that problem. Thank you for including the correction! ;)

    Cheers,

    Dario.

  • Perfect!

  • I have got problem with adding add-apt-repository ppa:terry.guo/gcc-arm-embedded

    After sudo apt-get update i have got error msg W: GPG error: http://ppa.launchpad.net precise Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6D1D8367A3421AFB

    In order to solve it: I have got key file from http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x6D1D8367... , saved it to file key1; 

    added it to system via: sudo apt-key add key1

    And received succesfull message OK

    After that sudo apt-get update gave me no errors.

    Everything else was successful. I have build px4 firmware.

This reply was deleted.