SparkFun Forums 

Where electronics enthusiasts find answers.

Open source ARM Debugger
By mgiaco82
#79282
I have a problem with OpenOCD and GDB. Debugging works fine if I erase at least the first sector of the lpc2148 – I use telnet for that (flash_erase_sector 0 0 0). So if I start a debugging session in Eclipse everything works fine. But if I stop the session and try to restart a new one I get this error.
Code: Select all
Open On-Chip Debugger 0.3.0-in-development (2009-08-19-10:19) svn:2596
$URL: svn://svn.berlios.de/openocd/trunk/src/openocd.c $
For bug reports, read http://svn.berlios.de/svnroot/repos/openocd/trunk/BUGS
30 kHz
jtag_nsrst_delay: 200
jtag_ntrst_delay: 200
Info : device: 4 "2232C"
Info : deviceID: 67358712
Info : SerialNumber: 32OZPDQCA
Info : Description: Amontec JTAGkey A
Info : clock speed 30 kHz
Info : JTAG tap: lpc2148.cpu tap/device found: 0x4f1f0f0f (mfg: 0x787, part: 0xf1f0, ver: 0x4)
Info : JTAG Tap/device matched
target state: halted
target halted in ARM state due to breakpoint, current mode: Supervisor
cpsr: 0x60000093 pc: 0x40000070
30 kHz
Info : JTAG tap: lpc2148.cpu tap/device found: 0x4f1f0f0f (mfg: 0x787, part: 0xf1f0, ver: 0x4)
Info : JTAG Tap/device matched
Warn : srst pulls trst - can not reset into halted mode. Issuing halt after reset.
target state: halted
target halted in Thumb state due to debug-request, current mode: Supervisor
cpsr: 0xa00000f3 pc: 0x7fffd2c2
requesting target halt and executing a soft reset
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0xa00000d3 pc: 0x00000000
1500 kHz
Info : accepting 'gdb' connection from 0
Warn : acknowledgment received, but no packet pending
background polling: on
TAP: lpc2148.cpu (enabled)
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0xa00000d3 pc: 0x00000000
requesting target halt and executing a soft reset
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0xa00000d3 pc: 0x00000000
30 kHz
Info : JTAG tap: lpc2148.cpu tap/device found: 0x4f1f0f0f (mfg: 0x787, part: 0xf1f0, ver: 0x4)
Info : JTAG Tap/device matched
Warn : srst pulls trst - can not reset into halted mode. Issuing halt after reset.
target state: halted
target halted in Thumb state due to debug-request, current mode: Supervisor
cpsr: 0xa00000f3 pc: 0x7fffd2c0
requesting target halt and executing a soft reset
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0xa00000d3 pc: 0x00000000
1500 kHz
0xe01fc040: 00000001 
flash 'lpc2000' found at 0x00000000
Warn : Verification will fail since checksum in image (0xe1a00000) to be written to flash is different from calculated vector checksum (0xa1b11eac).
Warn : To remove this warning modify build tools on developer PC to inject correct LPC vector checksum.
Info : dropped 'gdb' connection - error -400
Info : accepting 'gdb' connection from 0
Warn : acknowledgment received, but no packet pending
background polling: on
TAP: lpc2148.cpu (enabled)
target state: halted
target halted in ARM state due to debug-request, current mode: System
cpsr: 0x8000001f pc: 0x00000320
requesting target halt and executing a soft reset
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0x800000d3 pc: 0x00000000
30 kHz
Info : JTAG tap: lpc2148.cpu tap/device found: 0x4f1f0f0f (mfg: 0x787, part: 0xf1f0, ver: 0x4)
Info : JTAG Tap/device matched
Warn : srst pulls trst - can not reset into halted mode. Issuing halt after reset.
target state: halted
target halted in ARM state due to debug-request, current mode: System
cpsr: 0x8000001f pc: 0x00000310
requesting target halt and executing a soft reset
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0x800000d3 pc: 0x00000000
1500 kHz
0xe01fc040: 00000001 
flash 'lpc2000' found at 0x00000000
Error: timed out while waiting for target halted
Warn : target not halted
Error: Target not halted
Error: error writing to flash at address 0x00000000 at offset 0x00000000 (-304)
Warn : target not halted
Info : can't add breakpoint while target is running (BPID: 13)
Warn : target not halted
Warn : target not halted
Eclipse Dialog:
Code: Select all
Execution is suspended because of error.
  Warning:
  Cannot insert hardware breakpoint 1.
  Could not insert hardware breakpoints:
  You may have requested too many hardware breakpoints/watchpoints.
As recently as I erase at least the first sector of the on chip flash via telnet it works fine again. Sometimes I must halt the target before the erase command works.

I use the latest Version of OpenOCD with FTDI-Lib and the latest Eclipse and Zylin tools.

These are my gdb init commands:
Code: Select all
target remote localhost:3333
monitor poll
monitor reset init
monitor sleep 500
monitor mww 0xE01FC040 0x0001
monitor mdw 0xE01FC040
# needed for gdb 6.8 and higher
set mem inaccessible-by-default off
monitor flash probe 0
load
break main
continue
I do not know what´s wrong.

thanks mgiaco
By mgiaco82
#79283
So now it works but i need to erase every time i start a session but why?
Code: Select all
target remote localhost:3333

monitor poll
monitor halt
monitor sleep 500
monitor flash_erase_sector 0 0 0

monitor soft_reset_halt

monitor reset init
monitor sleep 500

monitor mww 0xE01FC040 0x0001
monitor mdw 0xE01FC040

# needed for gdb 6.8 and higher
set mem inaccessible-by-default off

monitor flash probe 0

load
break main
continue
By Freddie Chopin
#79287
Try this:

target remote localhost:3333
monitor reset halt
load

4\/3!!
By mgiaco82
#79526
Hello Freddie,
Code: Select all
target remote localhost:3333
loop () at main/startup/ex11_start.S:210
210	loop:   b   loop
Current language:  auto; currently asm
monitor reset halt 
monitor reset init
monitor sleep 500
monitor mww 0xE01FC040 0x0001
monitor mdw 0xE01FC040
set mem inaccessible-by-default off
load
Error erasing flash with vFlashErase packet
Breakpoint 1 at 0x190: file main/src/main.c, line 54.
break main
Note: automatically using hardware breakpoints for read-only addresses.
continue
Warning:
Cannot insert hardware breakpoint 1.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.

No it doesn´t work.
By Freddie Chopin
#79535
I've proposed this set:

target remote localhost:3333
monitor reset halt
load

You entered:

target remote localhost:3333
monitor reset halt
monitor reset init
monitor sleep 500
monitor mww 0xE01FC040 0x0001
monitor mdw 0xE01FC040
set mem inaccessible-by-default off
load
break main
continue

You see any difference?

4\/3!!
User avatar
By ntfreak
#79581
To enable flash programming via load in gdb you need to make sure valid flash banks are configured:
flash bank lpc2000 0x0 0x7d000 0 0 0 lpc2000_v2 14765 calc_checksum
and also a working area to speed things up - look at the default lpc2148 cfg for an example.

What will happen when gdb connects openocd will send the memory map to gdb. Then when you use the gdb load cmd it will erase the flash for you and then write the new flash.

The following cmds are not required, they will be done automatically:
set mem inaccessible-by-default off
monitor flash probe 0
http://openocd.berlios.de/doc/html/GDB- ... nd-OpenOCD may provide more info.

If you are still getting trouble then attach a full openocd debug log -d3.

I do not use lpc's, so these guidelines are general.

Cheers
Spen
By mgiaco82
#79616
Hello Freddie,

Okay so i try your commands and i get these errors.
Code: Select all
target remote localhost:3333
0x0000033c in main () at main/src/main.c:226
226			if (timer_cnt0 > counter) {
monitor reset halt 
load
Error erasing flash with vFlashErase packet
@ntfreak

thx i will have a look at that.

thx
mgiaco
By Freddie Chopin
#79632
What's the output of OpenOCD when you issue those commands?

You can also try this method:
To find out what's wrong start OpenOCD as usuall and open Command Prompt (cmd) and type:

telnet localhost 4444

this will connect you to OpenOCD via telnet.

Now you can try commands like:
reset halt
poll

and post the output (of telnet and of OpenOCD in the other command prompt) here.

You can also try to flash the chip via telnet with flash write_image ... (the details in the User's Guide of OpenOCD)

4\/3!!
By Rakesh
#79763
Even I am facing a similar problem with wriggler. The microcontroller is not halted after reset. The telnet output is :

> version
Open On-Chip Debugger 0.2.0 (2009-07-18-09:50) Release
> reset halt
JTAG tap: lpc2148.cpu tap/device found: 0x4f1f0f0f (mfg: 0x787, part: 0xf1f0, ver: 0x4)
JTAG Tap/device matched
srst pulls trst - can not reset into halted mode. Issuing halt after reset.
timed out while waiting for target halted
Runtime error, file "embedded:startup.tcl", line 222:
expected return code but got 'TARGET: lpc2148.cpu - Not halted'
in procedure 'ocd_process_reset'
called at file "embedded:startup.tcl", line 204
called at file "embedded:startup.tcl", line 205
called at file "embedded:startup.tcl", line 221
Runtime error, file "command.c", line 469:

> soft_reset_halt
requesting target halt and executing a soft reset
Failed to halt CPU after 1 sec
>


I can program the chip using H-JTAG, so apparently the jtag hardware is OK. I have checked the nrst - Pin 15 - of jtag header does go low.

Anything else I can try ?

Thanks

Rakesh
By anantmalewar
#134719
Hello Rakesh,
Can you please let me know if you resolved this issue? I am facing similar problem with openOCD and LPC2148.

Thanks!
Anant
By Smiley
#137295
Hello,
I am getting the same error of Target not halted. Also d monitor command error pops up and if I remove all the monitor commands,I still get d msg "Error: Launching main.elf file"...
Anyone please tell me the solution of at least one of these problems.....
By Smiley
#137399
Hello,
I followed the steps written above exactly and my problem is solved...!! I can now run the program on my kit...

Thank u Sparkfun..!! :D :D :D