X-CUBE-EEPROM- Help calculating the required size of flash memory
Hi
I am am trying to use the X-CUBE-EEPROM package in my application.
I found this very helpful post which I am using as a guide to setup the code.
https://community.st.com/t5/stm32-mcus/porting-and-using-x-cube-eeprom-with-any-stm32/ta-p/570539
I think I need to define the flash address where the emulated eeprom starts.
In order to do that, I need to know the size of the emulated eeprom.
Formula
Application note an4894 gives a formula to calculate the required size of flash memory, but I want to make sure I am using it properly. Also note, I am using a STM32G070CB, which has a flash memory endurance of 1K cycles. This is less than the standard 10K of most other STM32 MCUs.
Here is the formula:

Here is my calculation, I would appreciate if anyone can confirm I am doing it correctly!
I want to store a max of 50, 32 bit variables.
The page size of the STM32G0 series is 2KB.
The flash memory endurance is 1K cycles.
Variable elements per page = 500 = 2000 byte page size / 4 bytes for each variable
Number of EEPROM variables = 50
Number of cycles = 10000 (more on this later)
Flash memory endurance = 1000
Number of guard pages = 0
Page size = 2000 (2KB page size)
I get a result of 40KB from the formula.
That seems very high to store 200 bytes of data, so I don't know if i'm doing somthing wrong.
If I am doing things correct, I guess it is so high becuase I am trying to get 10K cycle endurance with 1K cycle endurance flash.
If I modify my requirements to only be 1K cycles, I get a result of 4KB.
4KB seems much more reasonable, however another issue arrises if I want to set 1K cycles in eeprom_emul_conf.h.
Software
In X-CUBE-EEPROM, eeprom_emul_conf.h, the cycle define is this:
#define CYCLES_NUMBER 1U /*!< Number of 10Kcycles requested, minimum 1 for 10Kcycles (default),
for instance 10 to reach 100Kcycles. This factor will increase
pages number */
Since CYCLES_NUMBER is in increments of 10K cycles, it doesn't seem possble to allow 1K cycles like I want to reduce the flash needed. I don't think I can put 0.1 for CYCLES_NUMBER right?
If I just set CYCLES_NUMBER to 1, will the eeprom use 4KB or 40KB, becuase I can't see anywhere in the code where the flash endurance of the MCU is defined?
Perhaps I am missing somthing?
Any help is greatly appreciated!
