Tuesday, 17 October 2017

jtag - ST-Link connection suddenly stops responding


While I wanted to upload/debug a new HAL Eclipse System Workbench for STM32 project on my STM32F103 it showed the following message:


OpenOCD child process termination

Reason:
Wrong device detected

Details:

Wrong device detected

Open On-Chip Debugger 0.10.0-dev-00302-gc211ca5-dirty (2017-07-03-10:41)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
none separate
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 950 kHz
adapter_nsrst_delay: 100
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v27 API v2 SWIM v6 VID 0x0483 PID 0x3748

Info : vid/pid are not identical: 0x0483/0x374B 0x0483/0x3748
Info : using stlink api v2
Info : Target voltage: 3.236436
Error: init mode failed (unable to connect to the target)
in procedure 'init'
in procedure 'ocd_bouncer'

This happens regularly, what I normally do is startup up STLink utility, and select Target/connect. This shows sometimes an error:


Can not connect to target!
If you're trying to connect to an STMW1xx device, please select

Normal or HotPlug mode from Target->Settings menu.
If you're trying to connect a low frequency application, please select
a lower SWD Frequency mode from Target->Settings menu.

Since both do not apply, I remove the USB STLink stick (V2, cheap one) and USB for power to the STM and try again, mostly it works. I close the ST Link utility and continue with Eclipse. This takes normally a few minutes and is annoying, but at least I can continue.


However, now I keep getting the ST Link message and cannot get rid of it (also restarted my computer).


If I try ST-LINK/Firmware Update from the ST-Link utility (to check if I can get connection to the ST Link itself), and press Device Connect, I get:


ST-Link is not in the DFU mode.
Please restart it


I don't know how to 'restart' it, but removing the ST Link from the USB and reinserting does not help.


I also tried another ST-Link, but it has the same behavior.


Than I tried another STM32, that worked. However, as soon as I tried to upload the program via Eclipse, it works once, when retrying, I get the same problems as above and now I have both of my STM's not working anymore. The program is not special, and worked before.


How to restore the connection with Eclipse so I can upload programs for debugging again?


Update:



  • I tried to put BOOT0 to 1 (3V), I could get once connection with ST link, I erased it. I could even debug after uploading, but just once. Than the problems started as before.

  • Also, suddenly, the ST Link utility crashes when trying to connect.


  • When I put BOOT0 to 0 again, and keep pressing the reset button, select erase memory from the ST Link utility and release the reset button, I could erase it. This makes it possible again to upload a program via Eclipse. However, after the first initial breakpoint stepping further, I get continuous the following error:



    Error: JTAG failure: -4





Answer



It seems that in the HAL project the SYS / Debug was not set to Serial Wire (this is not default).


However, the first time it was possible to debug, but not afterwards anymore. The reason is that the JTAG/SWDIO is disabled during the application. When it is disabled, even a connection is hard to make.


What worked:



  • Set BOOT0 to 1

  • Keep Reset button pressed


  • Remove / Erase Chip

  • Restart debugging


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...