cancel
Showing results for 
Search instead for 
Did you mean: 

Debug losing connection with Stm32WB55 target

GYV
Associate II

Code is written using stm32CubeMX. Connecting with stmlink V3 Minie. 
Executing step by step, it appears that debug fails (lose connection) when executing debug_init. In fact debug_init creates the problem when programming pa13.
When removing the initialization of PA13 and PA14 in debug init, things seems to work but I have no idea of potential side effect. 
An recommendation?

1 ACCEPTED SOLUTION

Accepted Solutions

@GYV wrote:

What is the appropriate way to initialise this macro?


You need to do it somewhere in the C source code

#define CFG_DEBUGGER_SUPPORTED 1
A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

View solution in original post

10 REPLIES 10
TDK
Super User

Please include the IOC that generates the problematic code.

If you feel a post has answered your question, please click "Accept as Solution".
Andrew Neil
Super User

Welcome to the forum.

Please see How to write your question to maximize your chances to find a solution for best results.

In particular, please give details of your setup.

 


@GYV wrote:

debug fails (lose connection) when executing debug_init. In fact debug_init creates the problem when programming pa13.


Please show that code. See: How to insert source code

 

PA13 & PA14 carry the SWD signals (ie, the signals the debugger uses to communicate) - so messing with them will break the debugger connection!

AndrewNeil_0-1770136701144.png

https://www.st.com/resource/en/datasheet/stm32wb55rg.pdf#page=65

via: https://www.st.com/en/microcontrollers-microprocessors/stm32wb55rg.html#documentation

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Please find the app_entry.c generated by CubeMX. Init_debug function start at line 189. On line 208 there is a list of pins to update, Problem occurs when executing HAL_GPIO_Init. 

GYV
Associate II

Sorry my english fails me here. What "IOC" stands for, or what additional info do you need?
Thanks

TDK
Super User

Set CFG_DEBUGGER_SUPPORTED = 1 to enable debug support. If this is 0, debug support is disabled and the pins are reconfigured to analog, as you can see in the code.

IOC is the file type of an STM32CubeMX project.

If you feel a post has answered your question, please click "Accept as Solution".
GYV
Associate II

Hello, after your message I look the code one more time and I think you are correct.

My IOC file (see attched) does not contain reference to CFG_DEBUGGER_SUPPORTED .
I tried adding CFG_DEBUGGER_SUPPORTED=1 as the last line of the IOC file (using notepad). I re-open CubeMX and generate the code. Closed CubeMX and reopen IOC file with notepad and noticed that the line i added (i.e. CFG_DEBUGGER_SUPPORTED=1) did not exist anymore. 
Looking at the generated code (specifically a #if (CFG_DEBUGGER_SUPPORTED ==1)) is grayed out confirming that the macro is not initialized. 

What is the appropriate way to initialise this macro?
Thanks


@GYV wrote:

What is the appropriate way to initialise this macro?


You need to do it somewhere in the C source code

#define CFG_DEBUGGER_SUPPORTED 1
A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

I added one statement to avoid compiler warning: 
#undef CFG_DEBUGGER_SUPPORTED

#define CFG_DEBUGGER_SUPPORTED 1


@GYV wrote:

I added one statement to avoid compiler warning


Presumably, that warning was telling you that it was already defined?

Then it would also have told you where that original definition was - so you could have edited the original definition ...

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.