cancel
Showing results for 
Search instead for 
Did you mean: 

STlink Debugging state not working

abbas
Associate II
Posted on December 09, 2016 at 19:31

Hello everyone,

I am using stm32f030k6...

When I am using ST-Link debugger and go into debug state, the Keil IDE goes to an assembly file 'startup_stm32f030x6.s  ' and get stuck there right at the line:

LDR     R0, =SystemInit

and I can't move futher using Step Over key (F10). when I do not use debugging and just download the code, the system is working as I expected but with this situation, I can't debug my code.

Is there anything wrong with me? Does anyone know how to get out of this trouble?

#st-link #stm32f030 #debugging
7 REPLIES 7
Posted on December 09, 2016 at 20:56

Do you have 'run to main()' unchecked?

Normally Keil brings up the debugger, and then attempts to get you to the first line in main() using a break-point. If code between the ResetHandler and there fails or loops, it will never get there.

Try pressing the Stop button to see where it is.

Review the clock start up code and loops called by SystemInit() in system_stm32xxxx.c

Consider using the SWV, and outputting progress data there, or via a USART

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ST Renegade
Senior
Posted on December 09, 2016 at 20:56

If you put a breakpoint into main and just press run, does the debugger jumps there? Btw. what is your optimization level? By default it's set to level 3 I think... For some reason you get stuck at the very beginning of code execution...

How did you create your project? You generated it from CubeMX and immediately jump to debug it or you've changed some IDE configurations etc.?

Have a nice day,

Renegade

Jaroslav BECKA
ST Employee
Posted on December 09, 2016 at 20:59

Hello

If you want to go directly to the main function after starting the debug session, check the option

''Run to main()''

in ''Options for Target'' (ALT +F7) -> Debug. Note that there is the ''SystemInit()'' function called before main (as you can see from the startup). You should be able to enter the function from startup by using Step key (F11).  0690X00000605SgQAI.png
abbas
Associate II
Posted on December 09, 2016 at 22:22

Thanks guys for your replies...

The Run to main() was checked

I put breakpoint on a line in main() and use F5 for running till that breakpoint but nothing happened. and the system remains at running state and whenever I push STOP button, the system was still at the same assembly line

The optimization level was the highest (o3). I changed it to lowest and nothing changed.

I used STM32Cube for making the project.

I also increase stack and heap sizes but they didn't help.

and unfortunately I should say, after rebuilding the project and restarting Keil over and over, at an unknown time the problem vanished. I had been seeing this problem before and always I didn't understand how the problem get resolved.

but thank you anyway

Posted on December 09, 2016 at 22:04

The question seems to indicate the OP wants it to get to main(), but it is not, it is stuck somewhere between and never gets there. With 'run to main()' checked, as it is by default, you'd have to press the stop button to regain control and see where it is actually stuck.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on December 09, 2016 at 22:27

Make sure the 'Update Target before Debugging' is checked in the Options/Utilities pane. And 'Load Application at Startup' is also checked in Options/Debug pane

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
gunter dussander
Associate
Posted on May 04, 2017 at 10:43

Hi everyone. I think i've solved this problem. The solution is go to st-link options -> debug tab -> download options -> Uncheck Download to flash. Now debugger works perfectly.