cancel
Showing results for 
Search instead for 
Did you mean: 

Did I break my STM32G0 when I tried to write data to flash memory?

Rafael P. Monteiro
Associate

Hello, I'm using STM32G070 in my project.

My code programs data in some regions of the flash. Use the CubeG0 example to write my code.

In the first part of recording and reading, the problem is serious when some more data from my STM32G070 stopped working.

It states this because when changing the STM32G070 of the card, the error no longer occurs: Reason: No device found at the destination.

Is there any way to recover these STM32G070 or are you really losing?

1) I set my starting address as follows:

#define DATABASE_START_ADDR  (FLASH_BASE + (FLASH_SIZE - 5120))

2) So I wrote a 52-byte structure. If I read this data it works perfectly.

3) Then I write more a structure with 23 bytes <= After that my device stops working. If I change the board's micro, it will work again;

I'm doing HAL_FLASH_Unlock and HAL_FLASH_Lock. But I'm not sure if I was doing the debugging performed on HAL_FLASH_Lock ()

2 REPLIES 2
Uwe Bonnes
Principal III

If there is possible dangerous nonsense in flash, use some programmer like STM32CubeProgrammer, connect under reset and erase the flash. If you fear that dangerous option bits where set, erase options or check and set all bits individual.

I think the information I discovered for the community is very valuable. I worked with ST-LINK V2 (Aliexpress), but I have one purchased from Mouser. So I tried this second ST-LINK V2 (from Mouser) and it worked.

I deleted the flash memory using the STM32CubeProgrammer and my microcontroller was recovered.

Thank you!