EEPROM Emul advantages in STM32WL
Hi All,
I have implemented EEPROM Emul Middleware in STM32WL project (https://www.st.com/resource/en/application_note/an4894-eeprom-emulation-techniques-and-software-for-stm32-microcontrollers-stmicroelectronics.pdf) in lieu of writing directly in FLASH the NVM Lorawan Context Structure.
LorawanEndNode example store the NVM Lorawan Context Structure in FLASH, directly as follow( function OnStoreContextRequest in lora_app.c):
if (FLASH_IF_Erase(LORAWAN_NVM_BASE_ADDRESS, FLASH_PAGE_SIZE) == FLASH_IF_OK)
{
FLASH_IF_Write(LORAWAN_NVM_BASE_ADDRESS, (const void *)nvm, nvm_size);
}I changed this function to my own function using EEPROM Emul
//store nvm in eeprom
writeNVMContext_EEPROMemul ((const void *)nvm, nvm_size);And something similar to restore the context.
It is working properly as desired:
- I store the NVM lorawan context every Uplink/Downlink message. This works for my OTAA session is always ok after poweron/off or hard resets.
- Save lifetime of FLASH in this case of use:
- EEPROM Emul: Every Uplink/Downlink only changes 24 bytes.
- FLASH directly: Every Uplink/Downlink erase and write 1484 bytes in 1 page.
My calculations are that EEPROM Emul write cycles are 10.000, and i have configured EEPROM emul for 2 & 2 EEPROM Pages:
1484 bytes first write.
24 bytes every Uplink/Downlink
...
...
4096 bytes(2 pages) 1484 + 108x24 bytes.
Every 108 Downlink/Uplink 2 pages are erased.
Next 108 Downlink/Uplink Next 2 pages are erased.
We have 4 pages of EEPROM Emul.
If every page have 10000 write cycle life.
EEPROM Emul lifetime in this case is: 216 x10000= 2.160.000 downlink/uplink messages
Do you think that it is correct?
Thanks very much