cancel
Showing results for 
Search instead for 
Did you mean: 

Flash erase and write is not consistent in STM32G030K8.

OInam
Associate II

Hello,

I am using STM32G030K8 for my application. So, due to bug in my code, out of bound flash memory address was tried for write and hardfault occured. But after resolving bug and resetting MCU, I observed that flash erase and write is not consistent. I tried mass erase of flash using cubeMX programmer and reflash the program, but to no avail. How to resolve this issue?

Thanks & Regards,

Omkar

3 REPLIES 3
Andreas Bolsch
Lead II

What does "flash erase and write is not consistent." actually mean? And what was your out of bound address? You should check *ALL* option bytes, WRP, PCROP, SECR. In particular OPTR has some undocumented (this does not necessarily mean non-functional!) bits.

OInam
Associate II

Hello Andreas,

What does "flash erase and write is not consistent." actually mean?

-- As in flash erase sometimes works successfully and sometimes gives error and same result with flash write.

And what was your out of bound address?

-- My out of bound address was 0x2800A280. So, I was trying to store new OTA flash image at address 0x08008800 and because of bug in the code, address leaped to 0x2800A280.

You should check *ALL* option bytes

-- How to check all option bytes ?

Thanks & Regards,

Omkar

Andreas Bolsch
Lead II
  • 0x2800A280: This area is unoccupied (or at leasr undocumented), so write attempts to this area should have no serious impact. But aborting a programming operation unexpectedly by a hard fault could lead to permanent damage, depending on programming mode, clock etc. The RM contains a warning and says it's guaranteed not to happen, but ...

  • If the very same operation (i.e. with all parameters exactly the same) sometimes works and sometimes doesn't, I'd suppose a hardware defect, not necessarily related to the flash programming.

  • Checking option bytes: Inspect the flash registers starting at 0x40022000 and check the values according to description in reference manual, in particular to the factory defaults as indicated in section 3.4.1. I'd recommend to use RM0444 (for G0x1) rather than RM0454 (for G0x0) , as the G030 and G031 actually are the same die, and bits marked reserved on the G030 could in fact interfere with proper operation if modified accidentally.