2025-07-16 11:42 AM - edited 2025-07-16 2:13 PM
I am developing software on the Nucleo-L433RC-P board but have a strange situation when debugging.
The first time I debug, the software does not run and I get the following error...
Break at address "0x1fff2ce8" with no debug information available, or outside of program code.
Break at address "0x1fff2cd6" with no debug information available, or outside of program code.
As shown in the screenshot below...
However, the second time I debug it works correctly.
Why does it not work correctly on the first debug, but then works correctly on the second debug ?
I have tried two different boards (one of which is brand new and never been used) but the behaviour is the same, so it must be a software issue.
2025-08-14 7:45 PM
second attempt. Here's how:
Software System Reset ensures the MCU starts correctly in user flash, avoiding the debugger halting in system memory (like 0x1fff2ce8).
BOOT0 LOW guarantees the MCU boots from your code in flash, not the bootloader.
Updated ST-Link firmware fixes known bugs that cause unreliable initial debugging behavior.
<ul>
<li>Set the <strong>Reset Mode</strong> in Debug Configurations to <strong>Software System Reset</strong>.</li>
<li>Ensure <strong>BOOT0</strong> is pulled <strong>LOW</strong> to boot from flash memory.</li>
<li>Update <strong>ST-Link firmware</strong> via STM32CubeIDE to ensure stable debugging.</li>
</ul>
2025-08-14 7:51 PM
Lines 11–15 likely have no impact and using malloc/free can risk heap corruption or stack overflow from unexpected interrupts.
Check that _Min_Heap_Size and _Min_Stack_Size are set correctly, and verify stack usage using stack painting methods.
2025-08-28 6:52 AM
Thanks michaeljyti, the point at which the program fails when stepping though the code was a red herring.
As my code developed. the program failed at a different points in the program.
The stack size is the default setting, I have not changed this...
_Min_Heap_Size = 0x200; /* required amount of heap */
_Min_Stack_Size = 0x400; /* required amount of stack */
I have never used stack painting so will need to look further into this.
If the stack size was incorrect, then wouldn't it fail every time ?
The flashing fails the first time but works the next time, it alternatively fails and works.
So why would an incorrect stack size cause this ?
2025-09-07 9:37 AM
This is driving me crazy, espeically as I am trying to get a custom bootloader to work too.
I checked the stack and its well within the limits....
Below is the code snipet to check the stack...
static uint32_t stack_used;
static uint32_t stack_free;
static uint32_t stack_used_max;
static uint32_t stack_free_max;
int main(void)
{
HAL_Init();
SystemClock_Config();
Stack_Paint();
...
...
...
}
void Stack_Paint(void) {
uint32_t *p = &_stack_end;
while (p < &_estack) {
*p++ = 0xA5A5A5A5; // fill with pattern
}
}
uint32_t Stack_GetUsage(void) {
extern uint32_t _stack_end;
extern uint32_t _estack;
uint32_t *p = &_stack_end;
while (p < &_estack && *p == 0xA5A5A5A5) {
p++;
}
stack_used = (&_estack - p) * sizeof(uint32_t); // bytes used
if (stack_used > stack_used_max)
{
stack_used_max = stack_used;
}
}
uint32_t Stack_GetFree(void) {
extern uint32_t _stack_end;
extern uint32_t _estack;
uint32_t *p = &_stack_end;
while (p < &_estack && *p == 0xA5A5A5A5) {
p++;
}
stack_free = (p - &_stack_end) * sizeof(uint32_t); // free space in bytes
if (stack_free > stack_free_max)
{
stack_free_max = stack_used;
}
}
Stack_GetUsage and Stack_GetFree is called in a 100ms task and the program is left to run for several minutes.
I've written a custom bootloader and a simple application that flashes an LED, I can successfully flash the application using the bootloader.
However, when I try to flash the application for this project, although it flashes successfully it does not run the application. I don't know whether the application has the same issue, where it does not work the first time its flashed but does work the second time its flash. However, I cant test this because the application is used to call the bootloader, so when it does not work the flash then its not possible to go back to the bootloader.