cancel
Showing results for 
Search instead for 
Did you mean: 

I have STM32G030J6 with 32kB Flash and I need emulate EEPROM. Is it possible?

Stastny.Petr
Associate III

I need permanently save configuration data (several bytes only) in STM32G030J6 in SO8N package. I tried to use EEPROM emulation SW but not working - very robust and complicated. Is there some easy way how to do this? There is no other EEPROM and no possible to connect.

14 REPLIES 14
Stastny.Petr
Associate III

I found a solution - I can use:

const uint32_t variable_X = 0xABCDDCBA;

But is it possible to say the compiler where should be this constant located? I do not need exact location, I only need to keep always the same the location in Flash when I make some pogram changes and recompile.

0693W00000NrhfZQAR.png 

> But is it possible to say the compiler where should be this constant located?

This is toolchain-dependent. If you use gcc-based toolchain, you should modify the linker script to include a custom section placed at a particular address, and then place the variable in question into that section.

I'm not sure whether there is some simple example out there, but this is a recurring question in this forum so you may want to search here.

JW

ne562
Associate II

For EEPROM emulation use array of structs, mapped to last FLASH page.

On power-on find last non-empty record (not equal to 0xFF), on every write increment record index, after last - erase whole page, and start from beginning.

According to my tests real number of page write cycles is 200000..400000 for STM32F030, so if record size is 20 bytes, you can get real 10..20 mln cycles - even better than many external EEPROMs...

Peter BENSCH
ST Employee
The suggestion of @ne562 is a good idea, but the guaranteed write cycle endurance of the STM32G030 is 1000 cycles - guaranteed over the entire temperature range! Of course higher numbers can be achieved in restricted temperature ranges and especially at lower temperatures, but this is not part of the respective data sheet.
Regards
/Peter
In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

I agree, at extreme temperatures (over 80..100deg.C) number of cycles can be significantly lower (leakage current increases exponentially).

I tested at 22deg and 60deg - no detectable difference, in my applications MCU rarely heats over 40deg...