Search by Tags
  • Computer on Module
    Colibri iMX6ULL
  • Carrier Board
    Apalis Evaluation Board
  • Computer on Module OS
    Linux
  • Development PC OS
    Linux

Debug Using Eclipse

 

Your progress

 

Attention: the Quickstart Guide for BSP 2.8, based on the Ångström distribution, is not being updated anymore. Depending on your SoM, you have different options:

Vybrid and Tegra: the information is provided as-is and still accurate, since newer Toradex BSPs are not ported to those SoMs. Just keep in mind that the Guides are not being maintained anymore, even if we find bugs or outdated instructions.

Apalis TK1 (all variants), Colibri iMX6ULL (all variants), Colibri iMX7S 256MB and Colibri iMX7D 512MB: these computer on modules are still regularly maintained in our BSPs and, to get started, you must check the software page Toradex BSP Layers and Reference Images for Yocto Project. Since Torizon is not supported, at the moment a Quickstart Guide is not available.

All other i.MX-based SoMs: you have two options to get started with embedded Linux: the first is to follow the Quickstart Guide for Torizon, which provides the greatest out-of-the-box experience, or if you choose to use Yocto, check the software page Toradex BSP Layers and Reference Images for Yocto Project.

Overview

This section of Module 2 will help you to configure the debug environment, in order to deploy the code to the target and debug it.

Information provided in this section was based on the Hello World application on Embedded Linux article from Toradex' knowledge-base.

In this module you will:

  • Use the Remote System Explorer perspective
  • Configure the IDE for debugging
  • Deploy and debug the hello world application

Prerequsites

  • Host computer running the regular 64-bit installation of Ubuntu 16.04 LTS, as stated in the module 1 cover page.
  • Eclipse Neon, as described in the previous lesson.

Step 1

In the top-right corner of the window:

  • Click the Open Perspective button



  • Open a new perspective

    Open a new perspective

Step 2

From the Open Perspective list:

-Select Remote System Explorer

Note: Should the Remote System Explorer not be installed yet, you may do so at Help - New Software... - --All Available Sites-- (from the with: drop-down menu) - and Device Development or Purpose Tools - System Explorer.



  • Select the Remote System Explorer perspective

    Select the Remote System Explorer perspective

Step 3

The IDE will open a different set of tabs, i.e. a new perspective, meant for accessing a remote device. We are interested in the Remote Systems tab to the left:

  • Click the Define a connection to remote system button



  • Remote System Explorer perspective

    Remote System Explorer perspective

Step 4

A window will open. From the list:

  • Select SSH Only



  • Create an SSH connection

    Create an SSH connection

Step 5

Fill the fields:

  • Host Name is the board IP
  • Connection Name is the connection label
  • Description might be left blank

Note: If your network allows, it might be practical to set the board IP as static. Please consult this article for more information.



  • Configure the SSH connection

    Configure the SSH connection

Step 6

The new connection will be listed in the Remote Systems tab. Right-click it and:

  • Select the Connect option



  • Connect to the recently created device

    Connect to the recently created device

Step 7

In the Enter Password pop-up window, you need to enter login details for the board connected:

  • User ID: root
  • Password (optional): (must be left blank)



  • Login request

    Login request

Step 8

You may be prompted to accept the host authentication. Click yes:



  • Accept the authentication

    Accept the authentication

Step 9

Use the Remote Systems tab to navigate the target filesystem:



  • Target filesystem

    Target filesystem

Here you can browse the target board contents using the SFTP protocol, as displayed in the picture above.

Step 10

Switch back to the C/C++ perspective using the button in the top-right corner. Right-click the project in the Project Explorer tab:

  • Select Debug as --> Debug Configurations...:



  • Configure the debug options

    Configure the debug options

Step 11

Maximize the C/C++ Remote Application options and select hello-world Debug. If there are no options to select, right-click the C/C++ Remote Application and select the new option. In the Main tab:

  • Give a name such as hello-world Debug to this debug option
  • Fill the C/C++ Application field with Debug/hello-world
  • Select Debug from the Build Configuration dropdown menu
  • Fill the Remote Absolute File Path for C/C++ Application field with the full path to where the application should be deployed on the target plus the binary name, e.g. /home/root/hello-world-debug
  • Last, create a new connection by clicking the New.. button



  • Main debug configuration tab

    Main debug configuration tab


  • Create a new connection

    Create a new connection

Step 12

From the dropdown menu in the Create a New Connection pop-up window:

  • Select SSH and click OK



  • SSH connection

    SSH connection

Step 13

In the Edit Connection pop-up window, fill the fields:

  • Connection name can be left as default (Remote Host)
  • Host is the target IP
  • User is root

Select "Password based authentication" instead of "Public key based authentication".



  • SSH connection configuration

    SSH connection configuration

Step 14

Switch to the Debugger tab. Replace the GDB Debugger field with "arm-angstrom-linux-gnueabi-gdb", such as illustrated in the figure below:

arm-angstrom-linux-gnueabi-gdb



  • Using GDB from the SDK

    Using GDB from the SDK

Click the Close button.

Step 15

Right-click the project in the Project Explorer tab:

  • Select Run as --> Run Configurations...:



  • Configure the run options

    Configure the run options

Step 16

Maximize the C/C++ Remote Application options and select hello-world Release. If there are no options to select, right-click the C/C++ Remote Application and select the new option. In the Main tab:

  • Give a name such as hello-world Release to this debug option
  • Fill the C/C++ Application field with Release/hello-world
  • Select Release from the Build Configuration dropdown menu
  • Fill the Remote Absolute File Path for C/C++ Application field with the full path to where the application should be deployed on the target plus the binary name, e.g. /home/root/hello-world-release
  • Last, select the previously configured option Remote Host from the Connection dropdown menu.



  • Main debug configuration tab

    Main debug configuration tab

Click the close button.

Step 17

Edit the source-code to add a loop, therefore you can debug it in the next steps:

#include <stdio.h>
#include <stdlib.h>
 
int main(void) {
	int mul = 1, i;
 
	puts("Hello World!"); /* prints Hello World! */
 
	for(i = 0; i < 5; i++){
		mul = 2*mul;
		printf("Loop %d - mul=%d", i, mul);
	}
 
	return EXIT_SUCCESS;
}

Step 18

Back to the C/C++ perspective, you will find two buttons in the top-left corner of the window. Both of them are used to build the application. The buttons are highlighted in the picture below:



  • Build buttons

    Build buttons

  • Click the arrow between them
  • Select the Debug option
  • Click the Build All button or just press Ctrl+B

Step 19

There are two buttons to debug or run the application. They are highlighted in the picture below:



  • Debug and Run buttons

    Debug and Run buttons

  • Click the arrow to the right of the Debug button.
  • Select the previously configured hello-world Debug option, as presented in the picture above.
  • If nothing happens, just click the debug button.

Warning: Sometimes, mostly after restarting Eclipse, the debug may fail for the first time you try to run it. Just try again and it might work.

Step 20

A pop-up window will tell you that the perspective will be switched to the debug perspective.

  • Click yes to acknowledge.

Note: You can always switch perspectives through the buttons in the top-right corner.



  • Warn about perspective switch to the debug mode

    Warn about perspective switch to the debug mode

Step 21

The debug perspective provides information and useful features in many different places:

  • There are buttons in a play/pause fashion in the top of the window. They are responsible for controlling the flow of the code, along with the breakpoints.
  • The Debug tab displays the application status - running or suspended and in which line of the source-code it is, for instance. You can easily verify and run the disassembled code, instruction by instruction, by clicking the Instruction Stepping Mode.
  • In the Console tab, everything printed to the stdout, such as when using functions like printf, will be displayed.
  • The Variables tab displays the application variables and their current status.
  • The Breakpoints tab lists all the breakpoints added and allows for quickly enabling/disabling them.

The picture below presents the debug perspective when it is started. The program will be halted in the first line of the main function. Take some time to get used to this perspective:



  • The debug perspective

    The debug perspective

Step 22

Add a breakpoint to the line 20:

  • Either right-click the number of the line you want to introduce the breakpoint and select Toggle Breakpoint from the options menu;
  • Or click anywhere in the desired line and press Crtl+Shift+B.



  • Adding a breakpoint by right-clicking the line number

    Adding a breakpoint by right-clicking the line number



  • Breakpoint added - the areas of interest are highlighted

    Breakpoint added - the areas of interest are highlighted

Step 23

Run the program:

  • Either click the Resume (play) button
  • Or press the F8 key

Step 24

Run step-by-step:

  • Either click the Step into button
  • Or press the F5 key

Keep pressing F5 while looking at the Variables tab. The values of i and mul will change as the for loop is executed. The last line to be executed is the return EXIT_SUCCESS;. By then, the Variables tab should look like this:



  • Variables updated as the code is executed

    Variables updated as the code is executed

FAQ

This lesson covers the basics of Eclipse IDE debugging, therefore this FAQ section is meant as an information complement.

Where can I find more information about the Eclipse IDE
Debugging behavior is erroneous