Skip to main content

Remote debugging for ARM target board

Remote debugging for ARM target board

With GDB one can both trace and modify code and data flow, and otherwise analyze the behavior of code, without explicitly changing any of it.

Rather than run a full-blown instance of GDB on the target platform, you can use GDBserver, a program that lets you run GDB on a different machine than the one on which your program is running. The advantage of using GDBserver is that it needs just a fraction of the target resources that GDB consumes, because it implements only the low-level functionality of the debugger -- namely setting breakpoints and accessing the target processor registers and read/write application memory. GDBserver takes control of the application being debugged, and then waits for instructions from a remote instance of GDB running on a development workstation.

Remote target needs to have debugging stub (gdbserver),
The gdbserver is also referred to as the 'stub' and must be cross-compiled for
that target.
You also have to use a version of gdb on the host that was built
with the correct target in mind.  Executing your gdb with the -v flag will give
you information on how it was built.
before you begin, you need a communication interface between the PC running GDB
and the target platform: either a serial link or, preferably, an Ethernet network
connection. You also need a cross-target toolchain: a GNU C compiler (together with
a C run-time library and binary utilities, a.k.a. binutils) that runs on the
development workstation and generates executables for the target processor. You will
build two sets of binaries from the GDB source code:
cross-target -- where the host is the development workstation and the target is the
target processor
native -- where both host and target are the target processor
First download the GDB source code compressed archive, and unpack it
The GDB source package uses the GNU build system, where generating binaries is
usually just a few commands away (./configure ; make ; make install)

Configure gdbserver for ARM target board


To remote debug need a gdb built for the correct target. To do this, download the latest gdb release (6.8)

    $ tar –xvzf .gz 
    $ cd gdb-6.8 
    $ ./configure --host=i386 --target=arm-linux --build=i686 
    $ make
    $ make install 

Cross target GDB ie arm-linux-gdb will be available in /home/bhagwat/arm-tools/bin/arm-linux-gdb/bin


Then, to build 'the stub' aka gdbserver for the arm-linux platform

    $ cd gdb-6.8/gdb/gdbserver 
    $ export CC=arm-linux-gcc   // if required
    $ export LD=arm-linux-ld    // if required 
    $ ./configure --build=i686 --host=arm-linux --target=arm-linux
    $ make

Copy gdbserver on target platform

gdbserver requires library, copy this from standard path to target boards /lib path.

Start with Remote Debugging

Start with simple hello.c example program

$ vi hello.c 
int main ( void)
   printf ( ”Hello , World ! \ n” ) ;
   return 0;

To build this program, you must use a cross compiler that is configured to generate binaries for the ARM Linux target (arm-linux-gcc).

Compile using arm-linux-gcc

$ arm-linux-gcc -g -Wall -o hello hello.c

Copy the program to board.

Telnet into the target and start gdbserver:

 $ gdbserver :4000 hello

The port number (4000) is arbitrary. Be sure to include the full path to your executable.

On the host, cd to the hello.c program directory and type:

 $ /home/bhagwat/arm-tools/bin/arm-linux-gdb/bin/arm-linux-gdb hello
 $ target remote ds:4000
 $ break main
 $ continue

Where "ds" is the name or IP address of your target board.

If you want to have some comfort, use ddd:

 $ ddd --gdb --debugger /home/bhagwat/arm-tools/bin/arm-linux-gdb/bin/arm-linux-gdb hello

Keep me updating.

Happy remote debugging.


Nihilist Hayvan said…
That was helpful. Thank you. But I guess one should set host as i686 not i386 whilst compiling gdb

Bhagwat said…
Thanks Nihilist; I did not see much difference with i386 and i686 option it works well in both cases.
./configure --host=i686 --target=arm-linux --build=i686
Redjupiter said…
I tried the above but I get the following:

(gdb) target remote
Remote debugging using
[New Thread 1195]
Malformed packet(b) (missing colon): re:0;
Packet: 'T050b:00000000;0d:c03ecebe;0f:b0070040;thread:4ab;core:0;'

Any idea? been struggling with this for a bit.


Popular posts from this blog

dasara marathi message dasara greetings in marathi

Dasara Marathi Greetings-SMS-marathi-Messages-vijaya dasami
marathi greeting cards for vijaya dasami
Happy Vijaya Dashami ! Celebrate the victory of the forces of good over Evil
Dasara is celebrated in Nepal by the name of Dashain. Vijayadashami (Hindi and Marathi: विजयादशमी, Kannada:ವಿಜಯದಶಮಿ)

Marathi Wishes for Dasara..
Apanas ani aplya kutumbiyans Vijayadashami nimmitt hardik shubhechha!

dassera greetings, marathi world, greetings, dassera, marathi greeting MARATHIGREETING.COMSpecial Marathi Greetings from ...Dasera, nljk. New Born, ckGkph pkgwy. Marathi Birthday, okMarathi Diwali ...

मराठी शुभेच्छापत्रे greeting marathi greetings...New Marathi Greeting Cards. Send this Marathi Dipawali Greeting Dasara Greeting Card to your friends · Click to Send this Greeting card to your friends for ...

मराठी शुभेच्छापत्रे - Greetings Cards, Marathi ...
Send free Marathi Greetings, electronic Greetings, m…

Xilinx's Interview Questions

Xilinx is the world's one of largest supplier of programmable logic devices. It has started R & D department in Hyderabad, India. It has broad scope for embedded system programming in device driver in linux.

Before the interview you have to feel the Xilinx form with information containing all academic details, current/previous employer, contacts of employer( to check out info about you), current ctc, expected ctc and expected date of joining, etc.

I appeared two back to back technical interviews.

The first interview was taken by a young man look like just crossed 30's.

He asked me to tell me about myself.

Then he asked my experience.

He checked my expertise in resume.

He asked questions about RTOS, and Linux Device Drivers.
What is RTOS ? Define it.
How a linux device driver works?
How a character driver works?

He looked at my project summaries and started to ask in depth questions about each project.

After that he asked me to write to delete nth node from starting in Singly Linked Li…

Rajasthan Board 10th Results | | RBSE

Raj Board of Secondary Education, Rajasthan Results at rajeduboard.nic.inBoard of Secondary Education, Rajasthan Ajmer declared result of secondary examination today at 4PM official site is

check Secondary Examination- 2008 Result
(To be announced on July 1st, 2008 at 4:00 PM)

Declared result
Praveshika Examination-2008 Result
(Announced on June 25, 2008 at 4:00 PM)

The history of the Board of Secondary Education Rajasthan (BSER) is a remarkable panorama of progressive record of the futurological vision for developing a dynamic system of various sub-systems of examinations and highlights of the academic excellence of the last four decades. The BSER took rapid strides for promotion and development of Secondary Education in Rajasthan, spread over 3,42,239 sq. km. and in more than 6000 schools located in 32 districts involving 8.5 lakhs students for Secondary and Senior Secondary Examination in the year 2000.

At present the Board is conducting …