cancel
Showing results for 
Search instead for 
Did you mean: 

How to solve debugger connection issues

Sara BEN HADJ YAHYA
ST Employee

How to solve debugger connection issues?

1. Introduction

The debugger is a tool that permit the programmer to monitor and track its code. It is very useful to execute the code step by step and see how it responds, it also helps to indicate the source of an error in case of malfunction.
The debugger requires some specific pins to communicate with the MCU, if those pins are used for other purpose, the user won’t be able to assure this communication and track the code would not be achieved.
This article describes the ways to prevent or fix debugger connection issues

2. Pre-requisite

STM32CubeMX
STM32CubeProgrammer
STM32CubeIDE

3. Steps

3.1. Preventing debug issues using CubeMX

The easiest and only way to prevent connection issues using CubeMX is to make sure that your debug pins are Free, Reserved for Debug or Used by the Debug.
Generally, SWD is mapped on PA13 (SWDIO) and PA14 (SWCLK). This is the default state after reset.
Taking the example of Serial Wire Debugging for a NUCLEO-U575ZI-Q

FreeReserved for DebugUsed by the Debug
1481.png1482.png1483.png

Note:

It is always recommended to activate the debug interface in MX, this will protect the IO pins from being used by another IP.

1484.png

Note:

In CubeMX interface, the Debug section can be found under System Core > SYS IP for the legacy products.

3.2. Solving debug connection issues

In case, one of the debug pins have been set accidently to any other signal than SWDIO and SWCLK. Then you generated the code and loaded it in the MCU.

1485.png

 During Debug, the message “Target is not responding, retrying...” will keep showing up in the IDE console and eventually the connection will be lost.

1486.png

In this case, the only way to take back the control of the board is by connecting it under reset using the NRST pin.
Debug pins must be overwritten by the debugger to achieve the communication, this can be done using STM32CubeProgrammer or the IDE (CubeIDE, MDK-ARM or EWARM).

3.2.1. STM32CubeProgrammer

Step1: Connect the board

Reset and Connection modes can be selected in the ST-LINK configuration Panel.

1488.png1490.png
 

Step2: Mass erase the MCU

Once connected, Mass erase the Chip

1492.png

The Mass Erase function erases the full memory, A message “Mass erase successfully achieved” will be displayed in case of success.

1494.png

After doing these steps, the board will be able to communicate with the debugger.

3.2.2. STM32CubeIDE

Step1: Debug interface check in MX

Return to CubeMX and activate the Debug.

1496.png

Step2: Debug configuration in CubeIDE

After code re-generation, open debug configuration

1498.png

And change the Reset behavior type to “Connect Under Reset”

1499.png

Click on Apply, then debug the board.

4. Links

For more details, please check AN4989 , section 4,
  • EWARM section 4.2.2
  • MDK-ARM  section 4.2.3

STM32CubeMX install link
STM32CubeProgrammer install link
STM32CubeIDE install link

 
 
Comments
MahadiHasan32
Associate II

 

I have tried with stmcubeprogrammer step one but getting this error below. My Board is Stm32WLxx.

 

15:43:24 : UR connection mode is defined with the HWrst reset mode
15:43:24 : ST-LINK SN : 13002900130000544141514E
15:43:24 : ST-LINK FW : V2J42S7
15:43:24 : Board : --
15:43:24 : Voltage : 3.25V
15:43:24 : Error: No STM32 target found! If your product embeds Debug Authentication, please perform a discovery using Debug Authentication

Uwe Bonnes
Principal II

Check  that jumpers on the board are in default position.

MahadiHasan32
Associate II

IMG_20240503_151619.jpg

IMG_20240503_151548.jpg

  •  I'm working with these modules, I'm quite sure these are ST clone, even the pinout is not marked.   

Uwe Bonnes
Principal II

As you are using a STLink Clone, did you check your precedures against a know working setup? It seem at the moment both debugger and target board are unknown. First check your procedures  with both end know working, e.g. a ST Nucleo Board and check your procedures are working.When working, attach the clone to the Nucleo, disabling the on board STLink and check again. When still  working, connect to yout target board.

Andrew Neil
Evangelist III

@MahadiHasan32 Yes, those units are definitely clones - they are not ST products (the ST logo is fake).

Beware that the pinouts on those things are not consistent:

https://community.st.com/t5/stm32-mcus-products/debug-problem-with-clone-st-linkv2/m-p/661306/highlight/true#M240845

 

chandruR
Associate II

Im also facing same issue, but im using Nucleo-H7A3ZI-Q Development Board, can you please help me to resolve the issue

 

Re: STM32H7A3ZIT6 - Code not automatically startin... - STMicroelectronics Community

Version history
Last update:
‎2022-04-04 01:07 AM
Updated by: