4. Remote Debug via Remote System Explorer (RSE) and arm-none-eabi-gdb.exe in Eclipse

28 May 2012

Return to: Embedded Code Generation Home

1 Getting Started with the Remote System Explorer

The Remote System Explorer (RSE)  is a perspective and toolkit in Eclipse Workbench, that allows you to connect and work with a variety of remote systems. With the predefined plug-ins, You can look at remote file systems, transfer files between hosts, do remote search, execute commands and work with processes.

 

1.1 Create a connection to beagle board

    To create a connection to the remote target system:

1.      Switch to the Remote System Explorer perspective. From the workbench menu, click Window > Open Perspective > Remote System Explorer.

2.      In the Remote Systems view, New Connection is automatically expanded to show the various remote systems you can connect to through the Remote System Explorer.

3.      Define a new connection and choose SSH Only from the Select Remote System Type screen in the New Connection dialog.

4.      Enter the name or TCP/IP address of your beagleboard in the Host name field, for example, 10.2.1.2.

If you prefer to use a hostname, please edit the host file at Windows\System32\drivers\etc (in Windows 7) and assign the hostname with a IP address: For instance,

10.2.1.2  beagleboard

Save the host file and you can use 'beagleboard' at the Host name field.

5.      Enter a connection name. This name displays in your tree view and must be unique to the profile. For example, Beagleboard_via_IP

6.      (Optional) Enter a Description. The description appears in the Properties view after the connection is created.

7.      Click Finish to define your system.

Description: Machine generated alternative text: S New Connection
Remote SSH Only System Connection
Define connection information
Parent profile: engs-19674 —.
Host name: 10.2.1.2
Connection name: Beagleboard_via_IP
Description: Using the IP as the host name for remote SSH connection
Ri Verify host name
® L <Back Next> ] [ Finish ] [ Cancel ]

 

1.2 Connecting to the Beagleboard

In the 'Remote systems' window, right click the connection you just created and select 'connect'

Description: Machine generated alternative text: Local
t’ % Local Files
Q Local Shells
beagleboard
Beagleboard_via_IP
% Sftp Files
Ssh Shells ‘
Ssh Terminals
r Properties iNsLRe
Property Valu
Connection stat No s
Default User ID dan
Descriotion Usin
III
X
New
Go Into
Go To
Open in New Window
Show in Table
Monitor
Refresh
Rename...
Delete...
Copy...
Move...
Export...
Import...
6s Move Up
Move Down
[ Connect ]
Clear Passwords
Remote Systems  Team
II%
@1 main3.c
mt main(void
(
mt a;
a=1;
a=a+2;
Drintf( “hello
F5
F2
Delete
‘‘‘
Connect all sut
Properties
Alt+Enter

 

If it is the first time you connect to the target system, you will be asked for user name and password.

Description: Machine generated alternative text: 3 Enter Password
System type:
Host name:
User ID:
Password (optional):
SSH Only
10.2.1.2
ubuntu
Save user ID
Sve password
[ OK EJ [ Cancel J

 

The connection will be successful unless you have got some error window.

 

1.3 Using the Terminal

 Once the connection succeed, right click 'Ssh Terminals' under the connection and select 'Launch Terminal'

Description: Machine generated alternative text: lRemoteSystemsJajfl [
1Y Local
Local Files
Local Shells
beagleboard
Beagleboard_viaJP
% Sftp Files
£ Ssh Shells
Ssh Terminalsi
Refresh
Disconnect
Clear Password
Launch Terminal
Properties
‘‘‘

 

And  a 'Terminal' window appears in the Elecipse.

Description: Machine generated alternative text: ¿H Remote System DetaijTasks ) Terminals
s,» Beagleboard_viaJP ____________________________________
Last login: Fri Jan 27 21:39:45 2012 from 10.2.1.1
ubuntuomap:’4 pwd
/home/ubuntu
ubuntuJomap : ‘4
‘‘‘

 

1.4 SFTP Files to transfer files between local host computer and remote target system

 

You can copy/rename/delete files at the remote target system by browsing the 'Sftp Files' tree under the connection.   You can transfer files from 'local' to remote system easily.

Description: Machine generated alternative text: Remote Sys Nt Team E Outline] o
I47Local a
Local Files
+ My Home
3 Drives
! Local Shells
beagleboard
% Sftp Files
3 My Home
>  Desktop
ITh Documents
L Downloads
1’ helloworldremote
j helloworld2.elf
ITh Music
‘ Ò myTestModel_rtt
D Pictures
L! Public
Sourcery
TpmnItnc
4 III

 

 

1.5 Switch among various Eclipse perspective

 

Switch perspective: Window -> Open Perspective -> Other… and select the 'Remote System Explorer' in the 'Open Perspective' window. 

 

Description: Machine generated alternative text: J Open Perspective [ 1
C/C++ (default)
CVS Repository Exploring
Debug
Git Repository Exploring
Java
!Java Browsing
7Java Type Hierarchy
Planning
4Plug-in Development
Remote System Explorer
q Resource
3Team Synchronizing
OK [ Cancel J

If you have opened a 'Remote System Explorer' and other perspectives, you can easily switch them by clicking the up-right corner.

 

Description: Machine generated alternative text: Debug [ Remote S... I i C/C++

 

And the RSE perspective would look like this:

 

Description: Machine generated alternative text: 3 Remote System Explorer - RemoteSystemsTempFiles/BEAGLEBOARD/home/ubuntu/helloworldremote/main3.c - Eclipse
File Edit Source Refactor Navigate Search Project Run Window Help
-
Q beagleboard
% Sftp Files
3 My Home
Desktop
Documents
Downloads
c helloworldremote
,J4 helloworld2.elf
J main3.c
Music
printf(”hello world!\n”);
printf(” compiled by Sourcery in Eclipse (Win7)\n”);
return 0;
Pictures
Public
myTestModel_rtt
Sourcery J
u Templates
u Videos
a.out
41 factorial
4 III
Properties  Remote Scratchpa 
_____ III
4. O% í4» E!h’
M Remote Sys iS tTeamE Outline ° 
ç-  #include “stdio.h”
a
Ç ê Debug jRemoteS...]C/C÷÷
mt main(void)
{
mt a;
a=1;
a=a+2;
° n
a
Remote System DetailjTasks $‘ TerminairZJ
beagleboard _____
ubuntu€Jomap:»$ pwd
/home/ubuntu
ubuntu@omap:»4 cd helloworldremote/
ubuntu€lomap:.-/helloworldremote$ ls
helloworid . elf
ubuntu€lomap:.-/helloworldremote$ ./helloworld.elf
hello world!
compiled by Sourcery in Eclipse (Win7)
ubuntu@omap : «ijhelloworldremote$
4
‘‘‘
Writable
Smart Insert 11: 10

 

 

 

2. Remote debugging with gdbserver and Eclipse in Windows

2.1 Generate the executable file.

Switch to the C/C++ perspective (Window -> Open Perspective -> Other… and select 'C/C++') and build the local project  by Ctrl+B to generate the ARM executable file. Once the build process completes, you will find a file <projectname>.elf at the project's Debug subfolder.  In my case, the <projectname> is helloworld.

 

2.2 Copy the executable file to target system

Switch to the 'RSE perspective' and copy the local executable file <projectfolder>\Debug\<projectname>.elf to the remote target system $HOME/hellowworldremote/<projectname>.elf.

 

Description: Machine generated alternative text: M Remote Sys Nt Tearn E Outline  J1 Terminals  fl
_jbeagIeboardiN
LocaI Last login: Fri ]an 27 22:29:34 2012 from 10.2.1.1
!beagIeboard ubuntu@omap:r..$ pwd
% Sftp Files /home/ubuntu
MyHome ubuntuomap:r..$ cd helloworldremote/
D Deskto ubuntu@oniap:r-/helloworldremote$ ls
p helloworld2.elf
D Documents ubuntuomap:r/helloworldremote$ chmod 777 helloworld2el+
D Downloads ubuntu@omap : ‘‘/helloworldremote$
lE helloworldremote
helloworld2.elf
Music
myTestModel_rtt
Pictures
Public
Sourcery
Templates
Ill 4

Note, In order to distinguish this remote file from the local file explicitly, I change the remote file name to helloworld2.elf.

  

2.3. Run the programme remotely

We need to set up an remote application configuration to run the program at the target system.

Click 'Run-> Run Configurations',  a  'Run Configurations' window opens. Right click 'C/C++ Remote Application' in the left panel,  select 'New' and set the options in the 'Main' tab as follows:

Name: helloworld Remote Run-Debug

Connection: beagleboard

Project: helloworld

C/C++ Application: Debug/helloworld.elf

Remote Absolute File Path for C/C++ Application: /home/ubuntu/helloworldremote/helloworld2.elf

Check the box of 'Skip download to target path'.

 

Here, the selection of 'Connection' is the point. The connection 'beagleboard' is the one setup in the previous step. You can click the 'Browse' button of the 'Remote Absolute File Path for C/C++ Application' to view and select the remote file.

Description: Machine generated alternative text: S Run Configurations
Create, manage, and run configurations
IxF]
_______________ Name: helloworid Remote Run-Debug
type filter text
C/C++ Application Main5rguments]  Common
C/C++ Remote Application Connection beagleboard ej New... J L Properties...
helloworld Remote Run Local I
Project: ________________
• Eclipse Application Lr,leboard k I _______________ _______________
helloworli Beagleboard_viaJP I E Browse...
Java Applet ___________________________________________________
rn Java Application Build configuration: [Debug e
Ju JUnit
L1 Select configuration using C/C++ Application
[ jg JUnit Plug-in Test
[ b Launch Group C/C++ Application: , _______________ _______________
* OSGi Framework Debug/helloworld.elf [Search Project.. [[ Browse... j
Remote Absolute File Path for C/C++ Application:
/home/ubuntu/helloworldremote/helloworld2.elf I [ Browse... j
Commands to execute before application
J Skip download to target path.
Filter matched 10 of 10 items [ Apply I [ Kevert j
Ii Run Close J

 

 

Then click 'Run' button.

The 'Console' window will look like this

Description: Machine generated alternative text: iProbIems  Tasks1 Q Console  Properties M Remote Systems 0
<terminated> helloworid Remote Run [C/Ct .‘- Remote Applicationj E:\Beagle\Eclipseworkspace\helloworld\Det
___ . __
;; Ec
/home/ubuntu/helloworldremote/helloworld2.elf;exit
ubuntu@omap:’.’$ echo $PWD’>’
/home/ubuntu>
ubuntu@omap :
ubuntu@omap :«$ /home/ubuntu/helloworldremote/helloworld2. elf;exit
hello world!
compiled by Sourcery in Eclipse (Win7)
logout
L’ __________

This verified the programme helloworld2.elf runs correctly in the remote system.

 

 

2.4. Debug the programme remotely

 

Click 'Run-> Debug Configurations',  a  'Debug  Configurations' window opens. You should be able to see the configuration  'helloworld Remote Run-Debug' which we just created in the left panel.

 

Select this configuration and go to 'Debugger' tab. Set the 'GDB debugger' to your Sourcery debugger by browsing to your ARM debugger. In my host system, it is

C:\CodeSourcery\bin\arm-none-eabi-gdb.exe

Description: Machine generated alternative text: Name: helloworld Remote Run-Debug
Main fr» Arguments P Debugger jSource flCommon
Stop on startup at main
Debugger Options
Main Shared Libraries j Gdbserver Settings
GDB debugger C:\CodeSourcery\bin\arm-none-eabi-gdb.exe Browse...
GDB command file: .gdbinit [ Browse.,.
(Warning: Some commands in this file may interfere with the startup operation of the debugger, for
example “run”.)
D Non-stop mode (Note: Requires non-stop GDB)
D Enable Reverse Debugging at startup (Note: Requires Reverse GDB)
D Force thread list update on suspend
D Automatically debug forked processes (Note: Requires Multi Process GDB)
a
Using 6DB (DSF) Automatic Remote Debugging Launcher - Select other... [ Apply Revert 1

 

Verify that the 'Gdbserver name' and port number in the 'Gdbserver Settings' tab are set. The port number can be any valid port number.

 

Description: Machine generated alternative text: Name: helloworid Remote Run-Debug
Main (x): Arguments * Debugger .3 Source  CommonJ
Stop on startup at: main
Debugger Options
MaiJJSared Libraries 1 Gdbserver Settings
Gdbserver name: gdbserver
Port number 123451
Using 6DB (DSF) Automatic Remote Debugging Launcher - Select other...

 

Screen clipping taken: 28/05/2012 14:23

 

 

 And click 'Debug' button at the 'Debug Configuration' window, Eclipse will switch to the 'Debug' perspective and start the debugging.

Since we set 'Stop on startup at main' in the Debug configuration, the programme stop at the beginning of main.c. Click 'F6' to run one step, we can see the output only the 'Hello world' appears at the console and the programe pause at next  printf() statement.

 

We can set breakpoints, etc to debug the programme.

Description: Machine generated alternative text: Remote Shell
.1 ndh
[ê Debug] Î Remote S...  C/C++
°. BreakpointsfUURegistersJtModules1 o fl
‘‘‘
____ .rH ____ ___ -
=_noutlinqfDisassemjjjj’b Console • xI  
helloworld Remote Run-Debug [C/C++ Remote Application] Remote Shell
gdbserver :2345 /home/ubuntu/helloworldremote/helloworld2.elf;exit
ubuntuomap:’4 echo $PWD’>’
/home/ubuntu>
ubuntuomap : ‘4
ubuntuomap:’4 gdbserver :2345 /home/ubuntu/helloworldremote/helloworh
Process /home/ubuntu/helloworldremote/helloworld2.elf created; pid = l
Listening on port 2345
Remote debugging from host 10.2.1.1
hello world!
4 ___ _____
lolo   ‘ = n
File Edit Source Refactor Nay gate Search Pr ct Run Window Help _______
riuI 4 *“O”% 4JDc
PDebug $1\  S? D DU S o ° »Variables 
A  helloworld Remote Run-Debug [C/C++ Remote Application] A
# helloworld.elf [cores: 0] Name
P Thread [1] 1939 [core: 0] (Suspended : Step) E
E mamo at mamn3.c:6 0x8414 4
Type Value
j main3.c
#include “stdio.h”
mt mairi(void)
printf(”hello world!\n”);
a prantf( compiled by Sourcery in Eclipse (Win7)\n ),
return 0;
fr
¿ Tasks [ Problems O Executables li Memory ì”
Monitors
+fl

 

 

The Eclipse will automatically call the gdbserver at the  beagleboard

 

dgbserver :2345 /home/ubuntu/helloworldremote/helloworld2.elf

 

 

 

Created with Microsoft OneNote 2010
One place for all your notes and information