Compiling Bela projects in Eclipse » History » Version 18

Giulio Moro, 2015-07-17 11:27 PM

1 11 Giulio Moro
h1.  Compiling BeagleRT projects in Eclipse
2 1 Andrew McPherson
3 1 Andrew McPherson
This document contains information on how to compile the BeagleRT software and upload it onto the BeagleBone Black.
4 1 Andrew McPherson
5 1 Andrew McPherson
h2. Required tools
6 1 Andrew McPherson
7 3 Andrew McPherson
This document assumes you have the following tools installed:
8 3 Andrew McPherson
9 12 Giulio Moro
h3. On Linux
10 1 Andrew McPherson
* Working Linux system, either running natively or on a virtual machine
11 3 Andrew McPherson
* Mercurial version control system (http://mercurial.selenic.com). Available as a package in most Linux distributions.
12 1 Andrew McPherson
* arm-gcc hardfp compiler toolchain (i.e. @arm-linux-gnueabihf-gcc@ and similar. On Ubuntu, these can be installed from packages:
13 1 Andrew McPherson
<pre>
14 1 Andrew McPherson
sudo apt-get install gcc-arm-linux-gnueabihf
15 1 Andrew McPherson
sudo apt-get install g++-arm-linux-gnueabihf
16 2 Andrew McPherson
</pre>
17 1 Andrew McPherson
* Eclipse IDE (http://www.eclipse.org), including the C/C++ development tools
18 12 Giulio Moro
* Xenomai libraries compiled for ARM hardfp _(details to come)_ ( you can probably do something similar to what described below for MacOS, make sure you use the appropriate paths, which might differ from the ones below)
19 12 Giulio Moro
20 12 Giulio Moro
h3. On a 64bit MacOS X
21 12 Giulio Moro
22 18 Giulio Moro
* You can get the arm cross-compiler toolchain from here http://www.welzels.de/blog/projekte/arm-cross-toolchain/, which will place the binaries into your /usr/local/linaro/arm-linux-gnueabihf/bin/ folder
23 18 Giulio Moro
* xenomai libraries and include files are already on the BBB's SD card. You can copy them over to your machine as follows:
24 12 Giulio Moro
<pre>
25 12 Giulio Moro
cd ~
26 12 Giulio Moro
ssh root@192.168.7.2 "cd /usr/; tar -zcvf ~/xenomai.tar.gz xenomai"
27 12 Giulio Moro
rsync -avz --remove-source-files bbb:xenomai.tar.gz .
28 12 Giulio Moro
cd  /usr/local/linaro/arm-linux-gnueabihf/include/
29 12 Giulio Moro
sudo tar -xvf ~/xenomai.tar.gz
30 1 Andrew McPherson
sudo rm xenomai.tar.gz
31 1 Andrew McPherson
</pre>
32 1 Andrew McPherson
33 18 Giulio Moro
* Make sure that the following line is in your Eclipse project's includes
34 13 Giulio Moro
<pre>/usr/arm-linux-gnueabihf/include/xenomai/include</pre>
35 14 Giulio Moro
and the following line is in your Eclipse project's libraries search path
36 1 Andrew McPherson
<pre>/usr/local/linaro/arm-linux-gnueabihf/include/xenomai/lib/</pre>
37 1 Andrew McPherson
38 13 Giulio Moro
h3. Other operating systems
39 13 Giulio Moro
40 18 Giulio Moro
You have several options:
41 18 Giulio Moro
# find your own way and share it here
42 18 Giulio Moro
# use the Ubuntu VirtualBox image provided [ask for link].
43 18 Giulio Moro
# compile on the board: [[ Compiling BeagleRT on the board]]
44 3 Andrew McPherson
45 3 Andrew McPherson
h2. Getting started
46 3 Andrew McPherson
47 17 Giulio Moro
# Make sure you own a copy of the BeagleRT files, if you do not already:
48 3 Andrew McPherson
<pre>
49 3 Andrew McPherson
hg clone https://code.soundsoftware.ac.uk/hg/beaglert
50 3 Andrew McPherson
</pre>
51 3 Andrew McPherson
# Launch Eclipse and select a workspace (creating one if necessary).
52 4 Andrew McPherson
# In the Eclipse menu bar, choose _File -> Import..._. Within the dialog box that appears, choose _General -> Existing Projects into Workspace_. Click _Next_.
53 4 Andrew McPherson
# Click the button _Select root directory_ and choose the path to the BeagleRT repository you just cloned.
54 1 Andrew McPherson
# Make sure the @BeagleRT@ project is selected, and under Options, untick _Copy projects into workspace_. Click _Finish_ to complete the project import.
55 6 Andrew McPherson
56 6 Andrew McPherson
h2. Compiling the BeagleRT project
57 6 Andrew McPherson
58 6 Andrew McPherson
# In Eclipse, right-click on the @BeagleRT@ project folder in the left-hand column, and choose _Build Project_. (If you don't see the list of projects, make sure the C/C++ Perspective is active in Eclipse, and choose _Window -> Show View -> Project Explorer_.)
59 6 Andrew McPherson
# The project should compile without errors, and the results should be visible in the Console tab (typically in the bottom pane of the window)
60 6 Andrew McPherson
# If any errors arise, check that you have all the dependencies installed, both header files and libraries.
61 6 Andrew McPherson
62 6 Andrew McPherson
h2. Copying BeagleRT projects to the BeagleBone Black
63 1 Andrew McPherson
64 17 Giulio Moro
Once the project has compiled, Eclipse should automatically copy it over to the Beaglebone in the ~/beaglert folder, prompting you twice for the password in case you did not set up the ssh keys.
65 17 Giulio Moro
If the project is not copied automatically:
66 17 Giulio Moro
# open a terminal window and @cd@ to the directory where the binary was compiled. For example, if you installed BeagleRT in your home directory: @cd ~/BeagleRT/Release@
67 7 Andrew McPherson
# Copy the BeagleRT executable to the BeagleBone Black using @scp@ (entering your BeagleBone Black password when prompted; you may need to create the @beaglert@ directory first):
68 7 Andrew McPherson
<pre>
69 7 Andrew McPherson
scp BeagleRT root@192.168.7.2:~/beaglert/
70 6 Andrew McPherson
</pre>
71 9 Andrew McPherson
72 9 Andrew McPherson
h2. Selecting different BeagleRT examples within the Eclipse project
73 9 Andrew McPherson
74 9 Andrew McPherson
The Eclipse project contains several examples within the @projects@ directory. Follow these steps to choose which one to compile:
75 9 Andrew McPherson
76 9 Andrew McPherson
# Only one of the folders within @projects@ should be enabled at a time. This one will be in solid black text; the remainder will be grey.
77 9 Andrew McPherson
# Right-click on the folder which is currently enabled (solid black). Choose _Resource Configurations -> Exclude from Build..._
78 9 Andrew McPherson
# Click _Select All_ to disable the code in this folder. Click _OK_.
79 9 Andrew McPherson
# Now right-click on the folder which you want to enable. Choose _Resource Configurations -> Exclude from Build..._
80 9 Andrew McPherson
# Click _Deselect All_ to enable the code in this folder. Click _OK_.
81 10 Andrew McPherson
82 10 Andrew McPherson
h2. Creating a new executable within the BeagleRT project
83 10 Andrew McPherson
84 10 Andrew McPherson
Duplicate one of the existing project folders using the following steps:
85 10 Andrew McPherson
86 10 Andrew McPherson
# Right-click the project folder you want to duplicate and select _Copy_.
87 10 Andrew McPherson
# Right-click on the @projects@ folder and select _Paste_. It will ask you to type in a new name.
88 10 Andrew McPherson
# Follow the steps above (_Resource Configurations_) to enable compiling this new project rather than any of the others.