Homepage Wiki Forum Buy

Eclipse

From GNUBLIN

Contents

Very easy to handle is the use of the IDE Eclipse [1] for development. This is how to install a cross development platform on your PC.

Download and Setup

Download and installation

1. Download Eclipse. The current version is Juno. Use the Eclipse IDE for C/C++ developers. It contains the cdt tools.

After downloading, you have a tar.gz file in the download folder. We unpack this archive with the following command in the home directory:

user@dev-pc ~/Downloads $ tar -vxzf eclipse-cpp-juno-SR2-linux-gtk.tar.gz -C ~/

To start the program via the console by comfortable calling eclipse, you have the change the file .bashrc in your home directory. We call the file with the editor nano:

user@dev-pc ~ $ nano .bashrc

and add a new line:

export PATH=$PATH:~/eclipse

Now you can start Eclips with:

user@dev-pc ~ $ eclipse

2. Download the GNUBLIN toolchain (described here C/C++ Development Environment installation). The PATH variable doesn't have to be set, because we do this in Eclipse directly.

Create a Project

3.Create a new project with "File/New -> C Project -> Create a new C-Project". Bildschirmfoto-C-C++ - Eclipse .png

Assign a name (e.g. HelloGNUBLIN) and choose the cross compile project in the list.

Cross Compile Project.png

After "Next" you specify the command prefix "arm-linux-gnueabi-" as tool. The tool command path is "/opt/eldk-5.0/armv5te/sysroots/i686-oesdk-linux/usr/bin/armv5te-linux-gnueabi".

Eclipse command prefix and path.png

Below the menuentry 'Project/Properties' you start the characteristic-dialog and choose C/C++ Build/Settings. Over there you ensure, that the active configuration is set to "Release". If you want to debug the program on the Gnublin, than choose "Debug".


4. Now the first GNUBLIN project is ready. In the project browser click with the right mouse button -> New -> Sourcefile -> C-Sourcefile creates an empty C-File. Enter your "Hello World" program in the C-file. Click the menu option "Project/Build Project" in order to compile it.

5. Now an executable file,'HelloGNUBLIN' should be created in the directory $HOME/workspace/HelloGnublin/Release. If you have already an internet connection (described in Pseudo Network with USB) then you are able to copy the compiled application via scp to GNUBLIN:


scp HelloGnublin root@10.11.12.1:/home/root

After that don't forget to make the file executable!

chmod +x HelloGnublin
./HelloGnublin

Now you have an working IDE for the Gnublin development.

Use the Gnublin API

It is very easy to use the Gnublin API with Eclipse. First of all we need the two files gnublin.h and gnublin.cpp. You get them here.

Open your C++-Project.

Important! You have to use a C++ project to use the API, because the API is written in C++!

After you've opened your Project, right click on it in the project explorer and select "Import":

Eclipse import.jpg

Now select "File System" in "General":

Eclipse Import Filesystem.png

Navigate to the folder, where you've stored the gnublin.cpp and gnublin.h files an select them. It should look like this:

Eclipse Import Filesystem2.png

Now you can include the gnublin.h file in your project an use the API functions:

#include "gnublin.h"

Example Program

As a little example we use our LED-blink program, which let the red LED blink on the Gnublin. The LED is connected to GPIO Pin 3.

Sourcecode:

  1. #include "gnublin.h"
  2.  
  3.  
  4. int main()
  5. {
  6.    gnublin_gpio gpio;
  7.  
  8.    gpio.pinMode(3,OUTPUT);
  9.  
  10.    while(1){
  11.      gpio.digitalWrite(3,HIGH);
  12.      sleep(2);
  13.      gpio.digitalWrite(3,LOW);
  14.      sleep(2);
  15.    }
  16. }

The program can be build with a simple click on the little hammer in the left upper corner:

Eclipse build LED-blink.jpg

When there are no errors in the "problems" section at the bottom your program was successfully created.


Debugging a C-program on the Gnublin

First you need a gdbserver on the gnublin. Therefore you must install it with (internet connection required)

apt-get install gdbserver

The program you want to debug must be compiled as a debug-version! Under the menu item 'Project/Properties' you choose the C/C++ Build/Settings. There you ensure, that the "Debug" Option is checked correctly. Then you click the "Project / Clean" and "Project / Build" items again to compile the program. Afterwards transfer the compiled program to the Gnublin. Now you may start the program on the Gnublin with the following command:

gdbserver 10.0.0.1:2345 HelloGnublin

The gdbserver now awaits a connection from Eclipse and then starts the program.

Now you have to create a debug-configuration in Eclipse in order to connect to the debugserver at the Gnublin. You only have to set up the configuration once, you can reuse it anytime.

With the menu item 'Run / Debug Configuration' you start the configuration dialog. There you mark the entry 'C/C++ Remote Application' and create a new remote-debug-configuration with the 'New-Button'. Now pick a name and choose a project with clicking the 'Search Project' Button. Then click on the radio button 'Disable Auto build' and Link 'Select Ohter' choose the entry 'GDB (DSF) Manual Remote Debugger Launcher'. Now click on the 'Debugger' tab and insert 'GDB Debugger: arm-linux-gnueabi-gdb' into the Debugger options field. At 'Connection' insert the IP (10.0.0.1) of the Gnublin and the port (2345) 'Apply' and you are ready. Now start the debugger, the program should stop at the first breakpoint.

In other languages