# Error: Target not halted

**URL:** <https://community.sparkfun.com/t/error-target-not-halted/12291>\
**Category:** MicroMod\
**Tags:** arm-lpc\
**Created:** [August 21, 2009, 8:24am UTC](https://community.sparkfun.com/t/error-target-not-halted/12291 "2009-08-21T08:24:08Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgiaco82](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@mgiaco82](https://community.sparkfun.com/u/mgiaco82)\
**Post date:** [August 21, 2009, 8:24am UTC](https://community.sparkfun.com/t/error-target-not-halted/12291/1 "2009-08-21T08:24:08Z")

</div>

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.

```auto
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:

```auto
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:

```auto
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

---

<div class="post-metadata">

**Author:** ![mgiaco82](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@mgiaco82](https://community.sparkfun.com/u/mgiaco82)\
**Post date:** [August 21, 2009, 8:35am UTC](https://community.sparkfun.com/t/error-target-not-halted/12291/2 "2009-08-21T08:35:22Z")

</div>

So now it works but i need to erase every time i start a session but why?

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Freddie\_Chopin](https://avatars.discourse-cdn.com/v4/letter/f/5e9695/32.png) [@Freddie\_Chopin](https://community.sparkfun.com/u/Freddie_Chopin)\
**Post date:** [August 21, 2009, 11:12am UTC](https://community.sparkfun.com/t/error-target-not-halted/12291/3 "2009-08-21T11:12:23Z")

</div>

Try this:

target remote localhost:3333

monitor reset halt

load

4/3!!

---

<div class="post-metadata">

**Author:** ![mgiaco82](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@mgiaco82](https://community.sparkfun.com/u/mgiaco82)\
**Post date:** [August 25, 2009, 8:23am UTC](https://community.sparkfun.com/t/error-target-not-halted/12291/4 "2009-08-25T08:23:23Z")

</div>

Hello Freddie,

```auto
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.

---

<div class="post-metadata">

**Author:** ![Freddie\_Chopin](https://avatars.discourse-cdn.com/v4/letter/f/5e9695/32.png) [@Freddie\_Chopin](https://community.sparkfun.com/u/Freddie_Chopin)\
**Post date:** [August 25, 2009, 11:02am UTC](https://community.sparkfun.com/t/error-target-not-halted/12291/5 "2009-08-25T11:02:36Z")

</div>

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!!

---

<div class="post-metadata">

**Author:** ![ntfreak](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@ntfreak](https://community.sparkfun.com/u/ntfreak)\
**Post date:** [August 25, 2009, 7:13pm UTC](https://community.sparkfun.com/t/error-target-not-halted/12291/6 "2009-08-25T19:13:27Z")

</div>

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](http://openocd.berlios.de/doc/html/GDB-and-OpenOCD.html#GDB-and-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

---

<div class="post-metadata">

**Author:** ![mgiaco82](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@mgiaco82](https://community.sparkfun.com/u/mgiaco82)\
**Post date:** [August 26, 2009, 8:48am UTC](https://community.sparkfun.com/t/error-target-not-halted/12291/7 "2009-08-26T08:48:17Z")

</div>

Hello Freddie,

Okay so i try your commands and i get these errors.

```auto
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

---

<div class="post-metadata">

**Author:** ![Freddie\_Chopin](https://avatars.discourse-cdn.com/v4/letter/f/5e9695/32.png) [@Freddie\_Chopin](https://community.sparkfun.com/u/Freddie_Chopin)\
**Post date:** [August 26, 2009, 3:17pm UTC](https://community.sparkfun.com/t/error-target-not-halted/12291/8 "2009-08-26T15:17:38Z")

</div>

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!!

---

<div class="post-metadata">

**Author:** ![Rakesh](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@Rakesh](https://community.sparkfun.com/u/Rakesh)\
**Post date:** [August 27, 2009, 7:19pm UTC](https://community.sparkfun.com/t/error-target-not-halted/12291/9 "2009-08-27T19:19:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anantmalewar](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@anantmalewar](https://community.sparkfun.com/u/anantmalewar)\
**Post date:** [October 17, 2011, 4:43pm UTC](https://community.sparkfun.com/t/error-target-not-halted/12291/10 "2011-10-17T16:43:28Z")

</div>

Hello Rakesh,

Can you please let me know if you resolved this issue? I am facing similar problem with openOCD and LPC2148.

Thanks!

Anant

---

<div class="post-metadata">

**Author:** ![Smiley](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@Smiley](https://community.sparkfun.com/u/Smiley)\
**Post date:** [December 22, 2011, 3:32pm UTC](https://community.sparkfun.com/t/error-target-not-halted/12291/11 "2011-12-22T15:32:43Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![Smiley](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@Smiley](https://community.sparkfun.com/u/Smiley)\
**Post date:** [December 25, 2011, 7:17am UTC](https://community.sparkfun.com/t/error-target-not-halted/12291/12 "2011-12-25T07:17:15Z")

</div>

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…!! 😃 😃 😃
