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
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 {
halt
}
$_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:
With this OpenOCD is able to connect to the NXP FRDM-KL46Z board :-).
Happy Halting 🙂
Wow, thanks! Solved my problem with Atmel’s SAM3U-EK 🙂
LikeLike
Hi Numius,
thanks for letting us know. Indeed, that OpenOCD error message can show up for any other device family too 🙂
LikeLike
I am using K82, I still get this error
LikeLike
I believe K82 is not supported by OpenOCD. As it does not support many other Kinetis devices (only a handful), I have moved away from OpenOCD :-(.
LikeLike
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”
LikeLike
I had similar problems of that kind with OpenOCD. I switched over to use the Segger J-Link for the ST-Link/V2: https://www.segger.com/products/debug-probes/j-link/models/other-j-links/st-link-on-board/
That way I never had problems. Maybe this can help you too?
LikeLike
Nice idea to stop a hart in its tracks. ! Should the “reset init” be in the gdb-detach event? I think there’s a typo.
LikeLiked by 1 person
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.
LikeLike