Solution for OpenOCD “Cannot communicate… target not haltet”

Related to my earlier article about using OpenOCD, I want to share something I have learned (again) with OpenOCD v0.10.0:

I was running often into the following error:

Warn : Cannot communicate... target not halted.
Error: auto_probe failed
Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
Error: attempted 'gdb' connection rejected
OpenOCD cannot communicate

OpenOCD cannot communicate

I had to reflash/connect to the board with either P&E or Segger to be able to connect to the board with OpenOCD again.

Karibe is here to the rescue about anything on OpenOCD. The solution to the  “Cannot communicate… target not halted.” problem is to add this to the OpenOCD configuration (.cfg) file:

$_TARGETNAME configure -event gdb-attach {
 $_TARGETNAME configure -event gdb-attach {
   reset init

For OpenOCD v0.10.0 and NXP Kinetis L debugging I have added this to the scripts/target\klx.cfg file:

klx.cfg File

klx.cfg File

With this OpenOCD is able to connect to the NXP FRDM-KL46Z board :-).

Happy Halting 🙂

8 thoughts on “Solution for OpenOCD “Cannot communicate… target not haltet”

  1. I am using STM32F030K6x with ST-Link/V2, am still getting this error, it doesnt recognize the device connected “Cannot identify target as STM32 family”


    • Hi Paul,
      yes, it should be gdb-detach in that screenshot (it had been fixed afterwards), thanks for noticing. The important thing for the connection was the gdb-attach event handler.


What do you think?

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.