EEPROM emulation: working principle
Hello everyone,
I'm currently working on an STM32L433 microcontroller and, considering cost and space-saving aspects, I opted to implement an EEPROM emulation library. While I've been going through the related documents, I've encountered a few uncertainties about its functionality.
Initially, I intended to store a 32-byte string and conducted some tests on an F4 Nucleo board using the STM-provided test code files. However, the method I observed for saving the string into memory seemed weird. It required dividing the string into 32 parts and storing them sequentially, leading to 32 memory erase operation. This approach appears highly inefficient. (I'd like to mention that I plan to perform this operation a maximum of 20 times a day. However, if my understanding is correct, I could simplify this process by utilizing 3 integer variables instead of 32, compressing the useful information.)
Upon examining the library's structure for "L4" MCU, similar to the case with the "F4" Nucleo board, it seems the library only supports storage for 32-bit variables. I'm unsure if this limitation stems from how the memory is constructed, or if I'm overlooking something crucial.
It's puzzling because, if this were the only method available to store information and code, flashing code into the memory would result in a high number of erase operation each time, which seems impractical.
My other doubt are regarding the AN4894 application note. In particular:
"The first set of pages is initially erased and used to store new data, with flash memory programming operations executed sequentially in increasing order of flash memory addresses. Once the first set of pages is full of data, it needs to be garbage-collected. The second set of pages collects only the valid data from the first set of pages, leaving the remaining area available for new data storage. Once the transfer of valid data to the second set of pages is completed, the first set of pages can be erased."
I'm confused about how this procedure reduces memory stress caused by erase operation. If I save my data in the first page and then move it to the second, it appears that I'll need to erase the memory twice as often. Additionally, I'm unclear about the meaning of "garbage-collected" – if I'm saving data into memory, it implies that I intend to retain it.
Apologies for these queries, but I'm striving to comprehend how this process functions without results.
