STM32WB55CG option bytes getting erased when debugging through STM32CubeIDE
Some strange behavior is happening when debugging our firmware through STM32CubeIDE, where it erases the option bytes upon flashing the firmware (0xFF @ 0x1FFF8000 onwards). The debugging session still launches ok and the firmware appears to be flashed correctly and working as intended.
This is especially annoying as it triggers the flash option bytes protection where it secures the memory and I have to manually restore it using the FUS safe boot mechanism. Our firmware is designed to go to shutdown mode each time which triggers this, so I can't do any work on it right now.
At first I thought it was a problem inside the firmware, but if I flash the ELF / srec artifact through the STM32CubeProgrammer directly, the problem goes away??
This never used to happen - took a break over the new year and I've come back to this problem.
Tried:
- Creating a dummy firmware with size larger than ours (thinking its a size problem) - dummy firmware works fine, no erasing of OBs.
- Dummy firmware is just a blinking LED, with a lot of padding (~280 KB), real firmware size around 200 KB
- Adjusting optimization settings
- Recreating the debug launch settings
- Adjusting linker script with various offsets
- The OPTKEY values required to unlock the flash aren't even in our firmware... checked with a binary dump. It's very unlikely our firmware is doing this
- Stopping on the very first instruction and inspecting memory - the OB's are erased even here!
Dummy firmware:
Real firmware:
Any ideas? Thanks
