Hi Dominic. Thanks in advance for your help.
“without knowing what’s inside gdb_init-manual it’s hard to tell what is going on in your case.”
OK. Lets forget about the example above. Lets look at my Eclipse Setup.
Here is my openocd config file for debugging.
OPENOCD Debug
for Philips LPC2138/2148 ARM7TDMI-S
Based on information from Dominic Rath - Thank you!
#daemon configuration
telnet_port 4444
gdb_port 3333
#interface
interface ft2232
ft2232_device_desc “Olimex OpenOCD JTAG A”
ft2232_layout olimex-jtag
ft2232_vid_pid 0x15BA 0x0003
jtag_speed 2
srst_push_pull
reset_config trst_and_srst trst_pulls_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 attach
daemon_startup reset
#target
#target arm7tdmi little reset_run 0 lpc2000
target arm7tdmi little run_and_halt 0 arm7tdmi-s_r4
run_and_halt_time 0 30
working_area 0 0x40000000 0x4000 nobackup
mthomas: LPC2138 @ 12MHz 0x7D000 from 500*1024 (not 512!)
loses 12K due to remapping of registers
flash bank lpc2000 0x0 0x7D000 0 0 lpc2000_v2 0 12000 calc_checksum
I am running the Zylin debugger plugin in Eclipse.
My "initialize’ commands are below. I am not running any ‘run’ commands.
target remote localhost:3333
monitor arm7_9 force_hw_bkpts enable
monitor soft_reset_halt
info reg pc
info breakpoints
Here is what I get in the Eclipse console for the arm-elf-gdb process:
target remote localhost:3333
uart0Getch () at uart.c:121
121 if (U0LSR & ULSR_RDR) // check if character is available
Current language: auto; currently c++
monitor arm7_9 force_hw_bkpts enable
monitor soft_reset_halt
info reg pc
pc 0x2224 8740
info breakpoints
No breakpoints or watchpoints.
The problem with this setup is that pc doesn’t get reset between runs, unless I restart openocd each time. And even then, the target runs before the debug process starts and pc doesn’t start at 0x0 in the debug process.
Am I doing something wrong ?
“The GDB remote protocol can’t ‘run’ a program, as running basically means create a new process and let that run. With the GDB remote protocol, you attach to the target (target remote localhost:3333), then ‘continue’ execution.”
OK, I changed the config file from daemon_startup reset
to daemon_startup attach
I then tested a number of command combinations and none seem to reset the pc. I want to debug some initialization routines, so I need the processor under control immediately. If I put continue into the command, the debug process locks up.
So… how do I get the processor to reset so I can debug init routines ? The only thing I have found to remotely work is soft_reset_halt, but it doesn’t always reset pc.
target remote localhost:3333
uart0Getch () at uart.c:124
124 return -1;
Current language: auto; currently c++
monitor arm7_9 force_hw_bkpts enable
monitor soft_reset_halt
info reg pc
pc 0x2260 8800
So how does one start the debugging process with the PC at the proper place ?
“Resetting is a bit difficult, as the GDB remote protocol doesn’t have a reset packet (there is one, but it’s obsoleted and for a different purpose), but you can use the ‘monitor’ facility to send the reset command to the OpenOCD.”
On my setup, that crashes the debugging session. I get a “broken pipe” error like this:
Execution is suspended because of error.
putpkt: write failed: Broken pipe.
Don’t know how to run. Try “help target”.
That was using the following command sequence:
target remote localhost:3333
__pabt () at crt0.S:69
69 __pabt: b . // program abort
Current language: auto; currently asm
monitor arm7_9 force_hw_bkpts enable
monitor reset halt
info reg pc
pc 0x40 64
Remote communication error: Connection reset by peer.
putpkt: write failed: Broken pipe.
Don’t know how to run. Try “help target”.
Or I get this:
target remote localhost:3333
0x00002240 in uart0Getch () at uart.c:121
121 if (U0LSR & ULSR_RDR) // check if character is available
Current language: auto; currently c++
monitor arm7_9 force_hw_bkpts enable
monitor reset halt
info reg pc
pc 0x2240 8768
Remote communication error: Connection reset by peer.
continue
putpkt: write failed: Broken pipe.
“Because GDB expects the target to be halted while you’re working on the GDB command line, you must not use “reset run”, only “reset halt”, “reset init”, “reset run_and_halt” or “reset run_and_init”. The versions without “run_and” only work with targets that can be debugged out of reset, i.e. not with the LPC2000 or the STR7x (among others).”
That is great to know.
So how do I start my debugging session with pc at the start of the code ?
Thanks