cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G030 corrupting program on last minute write

Hendrik1
Associate II

I have a STM32G030K8 processor that needs to write some stuff to memory as soon as it detects that it will be losing power - always a bad time but I have to do this.

Most of the time it seems to be doing this just fine but once in a while the processor gets corrupted.

Here is the problem though, I have write protected the code space and the only pages not write protected are two pages at the end of memory where I want to write the data to. During stable operation I erase these pages, so that at last minute I just have to write the data.

The problem is that the actual program gets corrupted in the write protected pages.

Does write protection only affect external writing or also internal writing? In other words, is it a possibility that the write instructions leave the entire memory vulnerable for corruption even though I am not altering the write protection on the pages with program code in?

14 REPLIES 14

This is then disconcerting, but at this point the only thing I can say is, that you have to make sure all erasing/programming finishes until VDD drops below the brownout level (2.1V).

JW

This all is very simple checked with scoped minimum two signals : 3V3 on MCU and power loss detector or some input power. Optimal is place into code after flash store gpio toggle and on thirdth channel scope this pin...

Show this image and will see

Yes, but there are numerous external factors that will affect the exact timing of the store (within a few ms).

Keep in mind my original question though - I am not so much concerned by the integrity of the stored data (recoverable by the user) as I am by the fact that code stored in write protected pages are being corrupted (cannot be recovered by user). My original question was, how is it possible for code in these pages to get corrupted if I never clear the WP flags on the protected pages. - does that mean that the code protection only protects from write operations from the outside world...

As i write first risk is erase part, when you start erase and power is lost same moment, is batery and other backup capable do safe erase complete? When no erased can be any part of chip on power hazard isnt guaranted nothink.

Too on write time on power lost is second risk , power lost can have bursts and other noise equal same no guarancy.

> My original question was, how is it possible for code in these pages to get corrupted if I never clear the WP flags on the protected pages.

Please note that this is a primarily user-driven forum with casual ST presence. You may want to ask this - as I've said, disconcerting - question ST directly, through FAE or the web support form.

JW