Difference between revisions of "Eclipse"

From ArmadeusWiki
Jump to: navigation, search
m (Forewords)
(Debug helloworld on the target)
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
How-To install Eclipse IDE and GDB debugger
+
How-to install Eclipse IDE and GDB debugger
  
 
==Forewords==
 
==Forewords==
Eclipse IDE has been choosen as standard IDE for the Armadeus software development process.<br>
+
Eclipse IDE can be used as standard IDE for the Armadeus software development process.
Specific pluggins will be added to ease writing kernel drivers and user applications. <br>
+
Despite one or two drawbacks (Java slowliness for example), Eclipse provides several advantages like the support of different languages, the good integration of GDB ...
+
  
==Eclipse installation==
+
Specific plugins will (might) be added (some day ;-)) to ease writing kernel drivers and user applications.
Go to the Eclipse download page
+
* http://www.eclipse.org/downloads/
+
and select '''Eclipse IDE for C/C++ Developers''' (Linux version)
+
  
Install Eclipse to the Home directory:
+
Despite one or two drawbacks (Java slowliness and memory usage for example), Eclipse provides several advantages like the support of different languages, the good integration of GDB ...
$cd $HOME
+
  
Assuming that the downloaded package is located on your desktop
+
==Eclipse installation==
$tar -xvzf Desktop/eclipse-cpp-europa-winter-linux-gtk.tar.gz
+
* If you don't need latest versions, you can get the one packaged with your distribution, for example on Debian/Ubuntu:
 +
<pre class="host">
 +
$ sudo apt-get install eclipse eclipse-cdt eclipse-egit eclipse-subclipse eclipse-cdt-launch-remote
 +
</pre>
  
==Eclipse start and configuration for the target==
+
* Otherwise, go to the [http://www.eclipse.org/downloads/ Eclipse download page] and select '''Eclipse IDE for C/C++ Developers''' (Linux version) or '''Eclipse IDE for Java Developers''' (if you intend to do Android development).
  $eclipse/eclipse &
+
* Install Eclipse to your HOME directory:
 +
<pre class="host">
 +
$ cd $HOME
 +
</pre>
 +
Assuming that the downloaded package is located on your desktop:
 +
<pre class="host">
 +
$ tar -xvzf Desktop/eclipse-cpp-europa-winter-linux-gtk.tar.gz
 +
</pre>
 +
 
 +
==Eclipse starting and configuration for the target (C/C++ developpers)==
 +
<pre class="host">
 +
  $ eclipse/eclipse &
 +
</pre>
  
 
1. Select your workspace (where your projects will be saved) <br>
 
1. Select your workspace (where your projects will be saved) <br>
Line 24: Line 33:
 
3. Create a new C Project with the name "helloworld" ->File ->New -> C project <br>
 
3. Create a new C Project with the name "helloworld" ->File ->New -> C project <br>
 
4. Enter the project name here "helloworld" and click '''finish''' <br>
 
4. Enter the project name here "helloworld" and click '''finish''' <br>
5. Now the ARM compiler has to be chosen to build the code for the target. Right click on the project "helloworld" in the project explorer and select '''properties''' <br>
+
5. Now the ARM© cross-compiler has to be choosen to build the code for the target. Right click on the project "helloworld" in the project explorer and select '''properties''' <br>
6. In the '''C/C++ Build''' entry, select '''Settings''' then '''GCC C Compiler''' then insert the path of the ARM compiler in the field '''Command'''
+
6. In the '''C/C++ Build''' entry, select '''Settings''' then '''GCC C Compiler''' then insert the path of the ARM compiler in the field '''Command'''; for example:
  /home/nicolas/armadeus/buildroot/build_arm/staging_dir/bin/arm-linux-gcc  
+
  /home/nicolas/armadeus/buildroot/output/host/usr/bin/arm-linux-gnueabihf-gcc  
 
7. GCC options can be modified in the '''All options''' field  <br>
 
7. GCC options can be modified in the '''All options''' field  <br>
8. Now the ARM linker has to be chosen as well. '''GCC C Linker''' then insert the path of the ARM linker in the field '''Command'''
+
8. Now the ARM© cross-linker has to be chosen as well. '''GCC C Linker''' then insert the path of the ARM linker in the field '''Command'''; for example:
  /home/nicolas/armadeus/buildroot/build_arm/staging_dir/bin/arm-linux-gcc
+
  /home/nicolas/armadeus/buildroot/output/host/usr/bin/arm-linux-gnueabihf-gcc
9. And finally the ARM assembler.'''GCC Assembler''' then insert the path of the ARM assembler in the field '''Command'''
+
9. And finally the ARM© cross-assembler. '''GCC Assembler''' then insert the path of the ARM assembler in the field '''Command'''; for example:
  /home/nicolas/armadeus/buildroot/build_arm/staging_dir/bin/arm-linux-as
+
  /home/nicolas/armadeus/buildroot/output/host/usr/bin/arm-linux-gnueabihf-as
10. The path for the include files has to be specified as well. Eclipse has, per default, the include path of the host. In the '''C/C++ General''', select '''Paths and Symbols''' then '''GNU C''' in languages and add
+
10. The path for the include files has to be specified as well. Eclipse has, by default, the include path of the host. In the '''C/C++ General''', select '''Paths and Symbols''' then '''GNU C''' in languages and add (for example):
  /home/nicolas/armadeus/buildroot/toolchain_build_arm/uClibc-0.9.29/include
+
  /home/nicolas/armadeus/buildroot/output/staging/usr/include/
 
This will add the standard include files for the small helloworld example below. Depending on the application additional paths can be specified.
 
This will add the standard include files for the small helloworld example below. Depending on the application additional paths can be specified.
  
 
==helloworld build==
 
==helloworld build==
Once the project correctly configured, we will add a new C File to it.<br>
+
Once the project is correctly configured, we will add a new C File to it.
1. add a source file to the project by right clicking on the "helloworld" project and selecting New -> Source File <br>
+
# Add a source file to the project by right clicking on the "helloworld" project and selecting New -> Source File
2. Enter the name '''main.c''' and click '''finish''' <br>
+
# Enter the name '''main.c''' and click '''finish'''
3. Write the code. See [[HelloWorld | hello world]] example <br>
+
# Write the code. See the [[HelloWorld | hello world example page]]
4. Then build it by selecting "helloworld" in the Project Explorer and then Project-> Build Project<br>
+
# Then build it by selecting "helloworld" in the Project Explorer and then Project-> Build Project
5. Take a look a the '''problems''' tab on the bottom of the Eclipse window to verify that the build was successfully done. <br>
+
# Take a look at the '''problems''' tab on the bottom of the Eclipse window to verify that the build was successfully done.
  
 
==Debug helloworld on the target==
 
==Debug helloworld on the target==
Once the project successfully compiled and linked:
+
Once the project has successfully compiled and linked:
1. In the Eclipse IDE, right click on "helloworld" in the Project Navigator, then Debug As -> Open Debug Dialog <br>
+
# In the Eclipse IDE, right click on "helloworld" in the Project Navigator, then Debug As -> Open Debug Dialog
2. Select '''C/C++ Local Application''' and create a '''new launch configuration''' (first icon in the top menu) <br>
+
# Select '''C/C++ Local Application''' and create a '''new launch configuration''' (first icon in the top left menu)
3. This new configuration will be automatically named "helloworld Debug". Select the '''Debugger''' tab <br>
+
# This new configuration will be automatically named "helloworld Debug". Select the '''Debugger''' tab
4. Select '''gdbserver Debugger''' in the "debugger" drop down list <br>
+
# Select '''gdbserver Debugger''' in the "debugger" drop down list
5. Now indicates where GDB is located (debugger option and GDB Debugger input):
+
# Now indicates where GDB is located (Debugger option -> Main -> GDB Debugger); for example: <pre>/home/nicolas/armadeus/buildroot/output/host/usr/bin/arm-linux-gnueabihf-gdb</pre>
/home/nicolas/armadeus/buildroot/build_arm/staging_dir/bin/arm-linux-gdb
+
# Once done, the link between the GDB server (on the target) and the GDB client (on the host) has to be configured. In "Debugger Options", select the "Connection" tab then "TCP" for the type if you want to use the ethernet link
6. Once done, the link between the GDB server (on the target) and the GDB client (on the host) has to be configured. In "Debugger Options", select the "Connection" tab then "TCP" for the type if you want to use the ethernet link <br>
+
# Indicates the target IP address for the gdb host server and then the port number: here 2345<br>
7. Indicates the target IP address for the gdb host server and then the port number: here 2345<br>
+
# Close and save the Debug configuration
8. Close and save the Debug configuration <br>
+
# Transfer the "helloworld binary" on the target by means of TFTP, SCP or whatever you want ( ''tftp -g -r [PATH]/helloworld HOST_IP_ADDRESS'' )
9. Transfer the "helloworld binary" on the target by means of TFTP, SCP or what you want ( tftp -g -r [PATH]/helloworld HOST_IP_ADDRESS ) <br>
+
# On your APF, start the program with GDB: <pre class="apf"># gdbserver HOST_IP_ADDRESS:2345 helloworld </pre>
10. Start the program with GDB:  
+
# GDB will launch your program and starts listen on port 2345 for a GDB client.
$gdbserver HOST_IP_ADDRESS:2345 helloworld
+
# in Eclipse start the debug session Run-> Debug
11. GDB will launch your program and starts listen on port 2345 for a GDB target. <br>
+
12. in Eclipse start the debug session Run-> Debug
+
 
+
  
 +
==Links==
 +
* [[GDB | GDB/GDBserver command line usage]]
 +
* [[HelloWorld | "Manual" compilation of a C program]]
  
 
[[Category:Toolchain]]
 
[[Category:Toolchain]]
 +
[[Category:IDE]]

Latest revision as of 17:29, 12 July 2017

How-to install Eclipse IDE and GDB debugger

Forewords

Eclipse IDE can be used as standard IDE for the Armadeus software development process.

Specific plugins will (might) be added (some day ;-)) to ease writing kernel drivers and user applications.

Despite one or two drawbacks (Java slowliness and memory usage for example), Eclipse provides several advantages like the support of different languages, the good integration of GDB ...

Eclipse installation

  • If you don't need latest versions, you can get the one packaged with your distribution, for example on Debian/Ubuntu:
$ sudo apt-get install eclipse eclipse-cdt eclipse-egit eclipse-subclipse eclipse-cdt-launch-remote
  • Otherwise, go to the Eclipse download page and select Eclipse IDE for C/C++ Developers (Linux version) or Eclipse IDE for Java Developers (if you intend to do Android development).
  • Install Eclipse to your HOME directory:
 $ cd $HOME

Assuming that the downloaded package is located on your desktop:

 $ tar -xvzf Desktop/eclipse-cpp-europa-winter-linux-gtk.tar.gz

Eclipse starting and configuration for the target (C/C++ developpers)

 $ eclipse/eclipse &

1. Select your workspace (where your projects will be saved)
2. Go to the workbench by clicking on "Workbench"
3. Create a new C Project with the name "helloworld" ->File ->New -> C project
4. Enter the project name here "helloworld" and click finish
5. Now the ARM© cross-compiler has to be choosen to build the code for the target. Right click on the project "helloworld" in the project explorer and select properties
6. In the C/C++ Build entry, select Settings then GCC C Compiler then insert the path of the ARM compiler in the field Command; for example:

/home/nicolas/armadeus/buildroot/output/host/usr/bin/arm-linux-gnueabihf-gcc 

7. GCC options can be modified in the All options field
8. Now the ARM© cross-linker has to be chosen as well. GCC C Linker then insert the path of the ARM linker in the field Command; for example:

/home/nicolas/armadeus/buildroot/output/host/usr/bin/arm-linux-gnueabihf-gcc

9. And finally the ARM© cross-assembler. GCC Assembler then insert the path of the ARM assembler in the field Command; for example:

/home/nicolas/armadeus/buildroot/output/host/usr/bin/arm-linux-gnueabihf-as

10. The path for the include files has to be specified as well. Eclipse has, by default, the include path of the host. In the C/C++ General, select Paths and Symbols then GNU C in languages and add (for example):

/home/nicolas/armadeus/buildroot/output/staging/usr/include/

This will add the standard include files for the small helloworld example below. Depending on the application additional paths can be specified.

helloworld build

Once the project is correctly configured, we will add a new C File to it.

  1. Add a source file to the project by right clicking on the "helloworld" project and selecting New -> Source File
  2. Enter the name main.c and click finish
  3. Write the code. See the hello world example page
  4. Then build it by selecting "helloworld" in the Project Explorer and then Project-> Build Project
  5. Take a look at the problems tab on the bottom of the Eclipse window to verify that the build was successfully done.

Debug helloworld on the target

Once the project has successfully compiled and linked:

  1. In the Eclipse IDE, right click on "helloworld" in the Project Navigator, then Debug As -> Open Debug Dialog
  2. Select C/C++ Local Application and create a new launch configuration (first icon in the top left menu)
  3. This new configuration will be automatically named "helloworld Debug". Select the Debugger tab
  4. Select gdbserver Debugger in the "debugger" drop down list
  5. Now indicates where GDB is located (Debugger option -> Main -> GDB Debugger); for example:
    /home/nicolas/armadeus/buildroot/output/host/usr/bin/arm-linux-gnueabihf-gdb
  6. Once done, the link between the GDB server (on the target) and the GDB client (on the host) has to be configured. In "Debugger Options", select the "Connection" tab then "TCP" for the type if you want to use the ethernet link
  7. Indicates the target IP address for the gdb host server and then the port number: here 2345
  8. Close and save the Debug configuration
  9. Transfer the "helloworld binary" on the target by means of TFTP, SCP or whatever you want ( tftp -g -r [PATH]/helloworld HOST_IP_ADDRESS )
  10. On your APF, start the program with GDB:
    # gdbserver HOST_IP_ADDRESS:2345 helloworld 
  11. GDB will launch your program and starts listen on port 2345 for a GDB client.
  12. in Eclipse start the debug session Run-> Debug

Links