Skip to main content
NASI
Associate III
September 1, 2021
Question

Debug issue

  • September 1, 2021
  • 4 replies
  • 5561 views

Hello,

I have an issue debug issue in my custom board. The debug session works for a while and then stop to working and suddenly after many tries it works again.

When the debug session doesn't work, I get:

STMicroelectronics ST-LINK GDB server. Version 5.9.1

Copyright (c) 2021, STMicroelectronics. All rights reserved.

Starting server with the following options:

    Persistent Mode      : Disabled

    LogFile Name        : C:\Users\***\Debug\st-link_gdbserver_log.txt

    Logging Level       : 31

    Listen Port Number     : 61234

    Status Refresh Delay    : 15s

    Verbose Mode        : Enabled

    SWD Debug         : Enabled

COM frequency = 4000 kHz

Target connection mode: Attach

Reading ROM table for AP 0 @0xe00fffd0

Hardware watchpoint supported by the target 

ST-LINK Firmware version : V2J38M27

Device ID: 0x418

PC: 0x78f9e0

ST-LINK device status: RUN_MODE

ST-LINK detects target voltage = 3.26 V

ST-LINK device status: RUN_MODE

ST-LINK device initialization OK

Waiting for debugger connection...

Waiting for connection on port 61234...

Waiting for connection on port 61235...

Accepted connection on port 61234...

Debugger connected

Try halt...

ST-LINK device status: HALT_MODE

Enter STM32_HardwareReset() function 

STM32_HardwareReset(), failure reset target.

ST-LINK device status: RESET_MODE

 ------ Switching to STM32CubeProgrammer ----- 

   -------------------------------------------------------------------

            STM32CubeProgrammer v2.8.0          

   -------------------------------------------------------------------

Log output file:  C:\Users\***\AppData\Local\Temp\STM32CubeProgrammer_a14944.log

ST-LINK SN : 0668FF343537424257252146

ST-LINK FW : V2J38M27

Board    : NUCLEO-F302R8

Voltage   : 3.25V

Error: ST-LINK error (DEV_TARGET_CMD_ERR)

Encountered Error when opening C:\ST\STM32CubeIDE_1.4.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.0.0.202105311346\tools\bin\STM32_Programmer_CLI.exe

 ------ Switching context ----- 

Error in STM32CubeProgrammer

Debugger connection lost.

Shutting down...

Stopping port 61235

Received stop for port 61235, not accepting new connections.

I use ST-LINK device and pins SWCLK, SWDIO and NRST are connected to the custom board MCU STM32F105VC. (of course 3.3v and GND).

The debug configuration is attached.

Thank you.

This topic has been closed for replies.

4 replies

MM..1
Chief III
September 1, 2021

Two possible mistakes , your code enter STOP or lower mode and you dont setup session to this.

Or you dont setup sonnecion under reset ...

NASI
NASIAuthor
Associate III
September 1, 2021

Thank you for your reply,

The debug sometimes (when it works) ends in Error_Hanlder function.

void Error_Handler(void)

{

 /* USER CODE BEGIN Error_Handler_Debug */

 /* User can add his own implementation to report the HAL error return state */

 __disable_irq();

 while (1)

 {

 }

 /* USER CODE END Error_Handler_Debug */

}

Tesla DeLorean
Guru
September 1, 2021

Perhaps migrate to the form of this that identifies the file and line it is called from, or pulls the return address so you can pin it down via symbols and .MAP or .ELF file.​

P​erhaps don't disable interrupts here, and double check NRST is properly connected.

C​heck clock startup code for failure cases.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
MM..1
Chief III
September 1, 2021

When your hardware fail, then ofcourse debuger crash too. For hw debug use scope ...

NASI
NASIAuthor
Associate III
September 1, 2021

Thank you,

I will check for the hardware if something is wrong.

But would you please tell me, the reason I can't change the LSI to LSE in clock configuration (as I mentioned, I use two external crystal 8MHz/32KHz, HSE and LSE). A picture is attached.

NASI
NASIAuthor
Associate III
September 2, 2021

RTC have to be enabled.

NASI
NASIAuthor
Associate III
September 2, 2021

I can verify that the 8MHz crystal is working on board when debug session is ok.

But I am still facing issue with debug.

NASI
NASIAuthor
Associate III
September 3, 2021

Could be that the MCU goes to deep sleep mode? Because I can program the MCU and suddenly it stopped. Doesn't ST-LINK bring the MCU out off sleep mode?

MM..1
Chief III
September 3, 2021

I write this in first reply. And basic is when you plan use debug you cant use SWD pins in code usw.