cancel
Showing results for 
Search instead for 
Did you mean: 

Does STM32G031 offer word/double-word based Data EEPROM access

JYao.2
Associate

I am trying to migrate our current design from L031 to G031 for the additional 32K firmware space with the same pin layout. One of the requirements is to store integer counters in the flash memory, and the counters get updated roughly 50K times over the device life. We used to be able to do it easily with L031 "data EEPROM". But it seems that with G031 the flash memory requires page-erase before any rewrite update.

Since the G031 flash has a 10K write limit, if each counter update requires a page erase, the limit will be reached very quickly. I am wondering if there is an equivalent "Data EEPROM" capability in G031 ? We found a X-CUBE-EEPROM emulator expansion but it seems at low level it still requires the same page erase operation.

5 REPLIES 5
gbm
Lead II

The basic principle of "EEPROM emulation" is the reduction of number page erases. You may use ST package or develop your own - basically it stores new values of the data to be modified in different locations of Flash and it erases Flash page when it overflows, so the number of erases is no_of_updates * Flash_page_size / mod_record_size. With mod record of 8 bytes and page size of 2 KiB you get one erase per 256 updates. If you assign more than one page for update records, the erase rate drops accordingly (with 4 pages - one erase per 1024 updates, which yields one million updates for a single item).

MM..1
Chief II

0693W00000WJYUzQAP.pngmod_record size need be based on ECC more info en.STM32G0-Memory-Flash-FLASH.pdf

S.Ma
Principal

Emulating an eeprom with flash has limits that you should consider before jumping.

What if power down during sector erase?

JYao.2
Associate

Thank you all for the very helpful comments. It helped me realize that it is not possible to perform "bit-wise 1->0 flip" for the counter application, since the ECC value of each double-word gets changed as soon as the double-word value is updated. So I am limited to 256 count per 2k-page. With the 10,000 flash write limit the total 2,560,000 count capacity can roughly cover the needs of our applications. We still need to find a way to address the false "counter reset" issue, if a power down occurred right after an erase, and before the counter value gets increased and re-written back to the flash.

MM..1
Chief II

Simply use two sectors and on last write to first sectore, write counter twice. On last pos and too erase and first in next sector... Possible you lost counter between start and stop erase only