Dario Lindo Andres's Posts (1)

Sort by
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.

Read more…