Showing results for 
Search instead for 
Did you mean: 

STMCube IDE fails to erase memory


Hello everybody. 

I have a custom board with an STM MCU on it.  This is not the first custom board I use, and all the others are working as expected.
This custom board works for a replacement of an identical board which stopped working. This means that the code that I am using is 100% compatible with the hardware I have. 

When I try to flash the code using STMCube IDE (1.13.1 on Ubuntu 22.04) the building works, but then I receive some errors while downloading. 

error message from debugger back end:

error finishing flash operation failed to execute mi command: st

And then

error: failed to erase memory
encountered error when opening /opt/st/stm32cubeide_1.13.1/plugins/

And as a further useful indication

erasing memory corresponding to segment 0:

erasing internal memory sectors [0 9]

error: failed to erase memory


This happens both while running and debugging the code. I have tried to modify the debug configuration, especially switching the alternatives under "reset behaviour" menu.

Now, for what regards CubeProgrammer, I am able to perform most of the operations. I can erase the flash memory and download code using the produced elf file form CubeIDE. Using the device memory display, I can see that, after downloading, the content of the flash memory is what I expect (identical to the binary file). While this seems okay, the MCU behaves weirdly. It is able to make some led blinking, but it does not execute the program it is supposed to run. As you can imagine, since I cannot interact with the MCU using CubeIDE, i have no way to enter in debug mode and understand what the MCU is really doing. 

What do you suggest me to do/try? Right now, my only guess is that the MCU is somehow damaged, or that maybe there are some wrong components placed on the board which cause problems to the execution.