Compiling Bela projects in Eclipse » History » Version 33
Giulio Moro, 2016-02-12 11:24 PM
1 | 30 | Giulio Moro | h1. Compiling Bela projects in Eclipse |
---|---|---|---|
2 | 1 | Andrew McPherson | |
3 | 30 | Giulio Moro | This document contains information on how to compile the Bela 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 | 1 | Andrew McPherson | |
9 | 1 | Andrew McPherson | h3. On Linux |
10 | 30 | Giulio Moro | |
11 | 30 | Giulio Moro | Requires: |
12 | 1 | Andrew McPherson | * Working Linux system, either running natively or on a virtual machine |
13 | 3 | Andrew McPherson | * Mercurial version control system (http://mercurial.selenic.com). Available as a package in most Linux distributions. |
14 | 1 | Andrew McPherson | * arm-gcc hardfp compiler toolchain (i.e. @arm-linux-gnueabihf-gcc@ and similar. On Ubuntu, these can be installed from packages: |
15 | 1 | Andrew McPherson | <pre> |
16 | 23 | Giulio Moro | sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf |
17 | 2 | Andrew McPherson | </pre> |
18 | 1 | Andrew McPherson | * Eclipse IDE (http://www.eclipse.org), including the C/C++ development tools |
19 | 22 | 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: |
20 | 22 | Giulio Moro | <pre> |
21 | 22 | Giulio Moro | cd ~ |
22 | 22 | Giulio Moro | ssh root@192.168.7.2 "cd /usr/; tar -zcvf ~/xenomai.tar.gz xenomai" |
23 | 26 | Giulio Moro | rsync -avz --remove-source-files root@192.168.7.2:xenomai.tar.gz . |
24 | 22 | Giulio Moro | cd /usr/arm-linux-gnueabihf/include/ |
25 | 22 | Giulio Moro | sudo tar -xvf ~/xenomai.tar.gz |
26 | 22 | Giulio Moro | rm ~/xenomai.tar.gz |
27 | 22 | Giulio Moro | </pre> |
28 | 22 | Giulio Moro | |
29 | 28 | Giulio Moro | * Make sure that the following line is in your Eclipse project's includes |
30 | 22 | Giulio Moro | <pre>/usr/arm-linux-gnueabihf/include/xenomai/include</pre> |
31 | 22 | Giulio Moro | and the following line is in your Eclipse project's libraries search path |
32 | 22 | Giulio Moro | <pre>/usr/arm-linux-gnueabihf/include/xenomai/lib</pre> |
33 | 12 | Giulio Moro | |
34 | 12 | Giulio Moro | h3. On a 64bit MacOS X |
35 | 12 | Giulio Moro | |
36 | 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 |
37 | 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: |
38 | 12 | Giulio Moro | <pre> |
39 | 31 | Giulio Moro | cd ~ &&\ |
40 | 33 | Giulio Moro | ssh root@192.168.7.2 "cd /usr/; tar -zcvf ~/xenomai.tar.gz xenomai/include xenomai/lib include/ne10" &&\ |
41 | 31 | Giulio Moro | rsync -avz --remove-source-files root@192.168.7.2:xenomai.tar.gz . &&\ |
42 | 31 | Giulio Moro | cd /usr/local/linaro/arm-linux-gnueabihf/include &&\ |
43 | 1 | Andrew McPherson | sudo tar -xvf ~/xenomai.tar.gz &&\ |
44 | 33 | Giulio Moro | sudo mv include/ne10 ./ &&\ |
45 | 33 | Giulio Moro | sudo rm -rf ./include &&\ |
46 | 1 | Andrew McPherson | rm ~/xenomai.tar.gz |
47 | 1 | Andrew McPherson | </pre> |
48 | 1 | Andrew McPherson | |
49 | 33 | Giulio Moro | * Make sure that the following lines are in your Eclipse project's includes |
50 | 33 | Giulio Moro | <pre>/usr/local/linaro/arm-linux-gnueabihf/include/xenomai/include |
51 | 33 | Giulio Moro | /usr/local/linaro/arm-linux-gnueabihf/include/ne10/</pre> |
52 | 14 | Giulio Moro | and the following line is in your Eclipse project's libraries search path |
53 | 1 | Andrew McPherson | <pre>/usr/local/linaro/arm-linux-gnueabihf/include/xenomai/lib/</pre> |
54 | 1 | Andrew McPherson | |
55 | 13 | Giulio Moro | h3. Other operating systems |
56 | 18 | Giulio Moro | |
57 | 1 | Andrew McPherson | You have several options: |
58 | 18 | Giulio Moro | # find your own way and share it here |
59 | 19 | Giulio Moro | # use the Ubuntu VirtualBox image provided [ask for link]. |
60 | 30 | Giulio Moro | # compile on the board: [[ Compiling Bela projects on the board]] |
61 | 1 | Andrew McPherson | |
62 | 3 | Andrew McPherson | h2. Getting started |
63 | 1 | Andrew McPherson | |
64 | 30 | Giulio Moro | # Make sure you own a copy of the Bela files, if you do not already: |
65 | 1 | Andrew McPherson | <pre> |
66 | 30 | Giulio Moro | hg clone https://code.soundsoftware.ac.uk/hg/BeagleRT |
67 | 3 | Andrew McPherson | </pre> |
68 | 4 | Andrew McPherson | # Launch Eclipse and select a workspace (creating one if necessary). |
69 | 1 | Andrew McPherson | # In the Eclipse menu bar, choose _File -> Import..._. Within the dialog box that appears, choose _General -> Existing Projects into Workspace_. Click _Next_. |
70 | 30 | Giulio Moro | # Click the button _Select root directory_ and choose the path to the Bela repository you just cloned. |
71 | 30 | Giulio Moro | # Make sure the @Bela@ project is selected, and under Options, untick _Copy projects into workspace_. Click _Finish_ to complete the project import. |
72 | 1 | Andrew McPherson | |
73 | 30 | Giulio Moro | h2. Compiling the Bela project |
74 | 1 | Andrew McPherson | |
75 | 30 | Giulio Moro | # In Eclipse, right-click on the @Bela@ 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_.) |
76 | 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) |
77 | 6 | Andrew McPherson | # If any errors arise, check that you have all the dependencies installed, both header files and libraries. |
78 | 6 | Andrew McPherson | |
79 | 30 | Giulio Moro | h2. Copying Bela projects to the BeagleBone Black |
80 | 17 | Giulio Moro | |
81 | 30 | 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. |
82 | 7 | Andrew McPherson | If the project is not copied automatically: |
83 | 30 | Giulio Moro | # open a terminal window and @cd@ to the directory where the binary was compiled. For example, if you installed Bela in your home directory: @cd ~/BeagleRT/Release@ |
84 | 30 | Giulio Moro | # Copy the Bela executable to the BeagleBone Black using @scp@ (entering your BeagleBone Black password when prompted; you may need to create the @Bela@ directory first): |
85 | 7 | Andrew McPherson | <pre> |
86 | 30 | Giulio Moro | scp BeagleRT root@192.168.7.2:~/BeagleRT/ |
87 | 9 | Andrew McPherson | </pre> |
88 | 9 | Andrew McPherson | |
89 | 30 | Giulio Moro | h2. Selecting different Bela examples within the Eclipse project |
90 | 9 | Andrew McPherson | |
91 | 9 | Andrew McPherson | The Eclipse project contains several examples within the @projects@ directory. Follow these steps to choose which one to compile: |
92 | 9 | Andrew McPherson | |
93 | 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. |
94 | 9 | Andrew McPherson | # Right-click on the folder which is currently enabled (solid black). Choose _Resource Configurations -> Exclude from Build..._ |
95 | 9 | Andrew McPherson | # Click _Select All_ to disable the code in this folder. Click _OK_. |
96 | 9 | Andrew McPherson | # Now right-click on the folder which you want to enable. Choose _Resource Configurations -> Exclude from Build..._ |
97 | 10 | Andrew McPherson | # Click _Deselect All_ to enable the code in this folder. Click _OK_. |
98 | 10 | Andrew McPherson | |
99 | 30 | Giulio Moro | h2. Creating a new executable within the Bela project |
100 | 10 | Andrew McPherson | |
101 | 10 | Andrew McPherson | Duplicate one of the existing project folders using the following steps: |
102 | 10 | Andrew McPherson | |
103 | 10 | Andrew McPherson | # Right-click the project folder you want to duplicate and select _Copy_. |
104 | 10 | Andrew McPherson | # Right-click on the @projects@ folder and select _Paste_. It will ask you to type in a new name. |
105 | 1 | Andrew McPherson | # Follow the steps above (_Resource Configurations_) to enable compiling this new project rather than any of the others. |