2021-09-01 12:42 AM
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.
2021-09-01 01:25 AM
Two possible mistakes , your code enter STOP or lower mode and you dont setup session to this.
Or you dont setup sonnecion under reset ...
2021-09-01 01:30 AM
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 */
}
2021-09-01 01:43 AM
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.
Perhaps don't disable interrupts here, and double check NRST is properly connected.
Check clock startup code for failure cases.
2021-09-01 02:04 AM
2021-09-01 02:09 AM
If the HSE doesn't start it will trap. Should be a couple of points you can identify quickly with breakpoints in SystemClock_Config()
2021-09-01 02:28 AM
When your hardware fail, then ofcourse debuger crash too. For hw debug use scope ...
2021-09-01 06:26 AM
2021-09-02 12:41 AM
I can verify that the 8MHz crystal is working on board when debug session is ok.
But I am still facing issue with debug.
2021-09-02 03:59 AM
RTC have to be enabled.