Skip to main content
Alpha Mr
Associate II
January 5, 2019
Solved

Truestudio don't stop at breakpoint

  • January 5, 2019
  • 2 replies
  • 1560 views

I am trying to debug the program using ST link on the board STM32F0308-DISCO. But after adding a breakpoint the Truestudio don't stop at the break point

This topic has been closed for replies.
Best answer by S.Ma

Easy peasy: Change in the project settings the compiler optimisations. It's there regardless of the toolchain. Set that to none or minimal and you'll be able to put breakpoints in the unoptized machine code. When optimized, most of the assembly machine instructions have been factorized so much that breakpoints can't be placed where you wished for.

And if you need to keep the optimizations on?

  • Add an asm("nop/n");
  • Make some global variables volatile and put a conditional if(myvolatilevar) asm("nop/n"); will enable you to even activate code post compile using the debugger because the compiler won't optimize as much.

volatile uint8_t always_zero = 0;
 
(...)
your code
if(always_zero)
 { asm("nop/n"); } // this code will be executed only if you stop the code, change the variable to non zero... in debug mode only. can be used for many fun things....

2 replies

S.Ma
S.MaAnswer
Principal
January 5, 2019

Easy peasy: Change in the project settings the compiler optimisations. It's there regardless of the toolchain. Set that to none or minimal and you'll be able to put breakpoints in the unoptized machine code. When optimized, most of the assembly machine instructions have been factorized so much that breakpoints can't be placed where you wished for.

And if you need to keep the optimizations on?

  • Add an asm("nop/n");
  • Make some global variables volatile and put a conditional if(myvolatilevar) asm("nop/n"); will enable you to even activate code post compile using the debugger because the compiler won't optimize as much.

volatile uint8_t always_zero = 0;
 
(...)
your code
if(always_zero)
 { asm("nop/n"); } // this code will be executed only if you stop the code, change the variable to non zero... in debug mode only. can be used for many fun things....

Alpha Mr
Alpha MrAuthor
Associate II
January 7, 2019

This worked for me! Thanks.

Tesla DeLorean
Guru
January 5, 2019

Or the code simply doesn't get there?

__asm("BKPT #0\n"); 

Perhaps add telemetry via a USART so you can establish flow and function.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
kurta999
Senior
January 9, 2019

In TrueStudio I'm unable to step to next line when using software breakpoints? Is that OK?