Is it possible to debug with OpenOCD helloworld on Hammer?

Hi all,

I have a Hammer module from tincantools and have connected the flyswatter to it. And I have compiled a simple hello world program with

arm-linux-uclibc-gcc -g hello.c -o hello

====================

#include <stdio.h>

int main()

{

printf(“Hello world\n”);

return 0;

}

=====================

and have successfully copied it to the Hammer file system and it ran fine.

So what I want to do now is to be able to run gdb and debug helloworld with openocd.

I did the following:

On my LINUX box, I ran openocd via:

sudo openocd -f myhammer.cfg

where myhammer.cfg is:

====================

#daemon configuration

telnet_port 4444

gdb_port 3333

#interface

interface ft2232

ft2232_device_desc “Flyswatter”

ft2232_layout “flyswatter”

ft2232_vid_pid 0x0403 0x6010

jtag_speed 1

#use combined on interfaces or targets that can’t set TRST/SRST separately

reset_config trst_and_srst

#jtag scan chain

#format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)

jtag_device 4 0x1 0xf 0xe

#target configuration

daemon_startup reset

#target

target arm920t little run_and_init 0 arm920t

=============================

This actually allows me to telnet into openocd:

telnet localhost 4444

and I gave the command

arm7_9 sw_bkpts enable

to enable the breakpoints on the Hammer.

I then ran gdb on the linux box:

arm-linux-uclibc-gdb hello

and here’s what happens:

===============================

GNU gdb 6.6

Copyright (C) 2006 Free Software Foundation, Inc.

GDB is free software, covered by the GNU General Public License, and you are

welcome to change it and/or distribute copies of it under certain conditions.

Type “show copying” to see the conditions.

There is absolutely no warranty for GDB. Type “show warranty” for details.

This GDB was configured as “–host=i386-pc-linux-gnu --target=arm-linux-uclibc”.

(gdb) target remote localhost:3333

Remote debugging using localhost:3333

warning: Unable to find dynamic linker breakpoint function.

GDB will be unable to debug shared library initializers

and track explicitly loaded dynamic code.

0x30201804 in ?? ()

(gdb) list

1 #include <stdio.h>

2

3 int main()

4 {

5 printf(“Hello world\n”);

6 }

7

(gdb) b 5

Breakpoint 1 at 0x84f0: file hello.c, line 5.

(gdb) r

The program being debugged has been started already.

Start it from the beginning? (y or n) y

Starting program: /home/cytan/tmp/hello

Don’t know how to run. Try “help target”.

=============================

I’m sure I’m doing something stupid, can anyone help? Or perhaps

is it because gdb + openocd cannot debug directly compiled programs running under LINUX on the Hammer?

Thanks for any help or info.

cytan

Hi all,

I just did some research on OpenOCD and the Hammer, and have come to the conclusion (hopefully erroneous) that with embedded Linux running on the Hammer, OpenOCD is actually useless for debugging hello world. Is this right?

The solution is to compile gdbserver, run it on Hammer’s linux and debug hello world with the serial port using gbd’s remote debugging feature. Is this right?

cytan

Hi all,

I think I’ve found the solution: See

http://www.embeddedstar.com/weblog/2006 … lications/

which shows the key for debugging applications (I think) with OpenOCD is to halt the ARM processor with

asm(“bkpt 0”);

i.e.

=============

#include <stdio.h>

int main()

{

printf(“Halting processor …\n”);

asm(“bkpt 0”); //halt the processor

printf(“Hello world\n”);

return 0;

}

=================

Unfortunately, when I run it on the hammer, I get:


./hello.elf

Halting the target …

Illegal instruction


How do I halt the Hammer?

Thanks for any info.

cytan