2024-09-25 02:26 AM - edited 2024-09-25 02:28 AM
I am debugging an application for an STMF103RCTX Using STM32CubeIDE and an STLINK v2 debugger.
This is my usual combination of tools and my usual hookup.
I find that I can start a debug session and step into main() and even step over anything befoer HAL_Init(); but as soon as I hit that the begugger connection fails.
I've made a short video showing this issue:
My hookup from the STLINK to the device is as follows:
STLINK ---> DEVICE
Pin 2 VCC ---> VCC
Pin 4 GND ---> GND
Pin 7 TMS/SWDIO ---> PA13/TMS/SWDIO (46)
Pin 9 TCLK/SWCLK ---> PA14/TCLK/SWCLK (50)
Pin 15 --> RESET ---> nRST (7)
Any ideas? (The app runs perfectly when not trying to debug it)
Solved! Go to Solution.
2024-09-25 03:37 AM
OK Found it!
Somehow I have set debug to "No Debug" - Must have been me, but I don't recall ever going there!
Changing ti back to Serial Wire debug fixes it.
2024-09-25 02:32 AM
Hello,
What memset is doing here? The destination? the size?
if you remove that line, do you have the same behavior?
2024-09-25 02:40 AM
@KMill wrote:I find that I can start a debug session and step into main() and even step over anything befoer HAL_Init(); but as soon as I hit that the begugger connection fails.
So what happens if you step into HAL_Init() ?
Where within HAL_Init() does it fail?
Does your HAL_Init() disable the SWD pins, perhaps ... ?
https://community.st.com/t5/stm32-mcus/how-to-solve-debugger-connection-issues/ta-p/49693
2024-09-25 02:58 AM
The memset is absolutely fine, destination and size are correct.
I only added it to gove me something to step-over beforr HAL init as as test.
I will try the things mentioned in the other post...
2024-09-25 03:02 AM
Start a new project with the bare minimum. Then see if you can debug and get past HAL_Init
2024-09-25 03:06 AM
@Andrew Neil Thanks for the suggestion.
If I step into HAL_Init() it stops at this line:
My IOC file has reserved the pins for debug:
2024-09-25 03:17 AM
@KMill wrote:If I step into HAL_Init() it stops at this line:
Look at the comment immediately above that line: you are disabling the JTAG and SWD - so obviously the debug connection will fail!
2024-09-25 03:21 AM
@Andrew Neil Aye, I see that! The question is why is it being disabled?
I am in a debug configuration, and the pins are reserved for debug!
I had a browse through the stm32f1xx_hal_msp.c but can't see any clues as to why that is there?
2024-09-25 03:35 AM
Are you overriding HAL_MspInit function? That function is usually defined as __weak
2024-09-25 03:37 AM
OK Found it!
Somehow I have set debug to "No Debug" - Must have been me, but I don't recall ever going there!
Changing ti back to Serial Wire debug fixes it.