“ Mastering storage means mastering embedded systems!”

It is well understood by all engineers engaged in embedded development that storage plays a very important role in technology and products.
Common storage types include RAM, Flash, and ROM.
RAM is primarily used to store runtime programs and data, which needs no further explanation.
01
—
Flash & ROM
Flash and ROM are used to permanently store programs and data, but there are significant differences in their operation.
Generally speaking, Flash has a faster read speed and is commonly used to store firmware and permanent data.Flash must be read and written in pages/blocks, and frequent large-scale read/write operations can affect its lifespan (typically around 100k cycles), which can impact the normal operation of the controller. Once the Flash on the controller exceeds its lifespan, the controller product will fail and cannot continue to be used.
Of course, the Flash mentioned here refers to the internal Flash of the controller. Some products also configure external Flash through FSMC to supplement the internal Flash or to serve as a backup area for OTA.
ROM especially EEPROM is generally used to store specific data content, such as system operational state data. EEPROM typically operates on a byte basis but has a lower read/write speed.
So what are the usage scenarios and timing for EEPROM? Why is it necessary to use EEPROM?
First, EEPROM is very cost-effective, and its drivers are mature; it can be used with a software or hardware IIC bus.
Second, in actual product use, when the system experiences an unexpected power loss, saving data to Flash requires erasing before writing. From the moment of power loss to complete power off, it is impossible to know for sure whether the erase and write actions have been completed. In contrast, EEPROM only requires a single write action, making it simpler and faster.
Third, even if the data write fails, EEPROM can revert to the last written data. The page erase mechanism of Flash, if not managed with a good writing strategy, can potentially corrupt the most recent data.
Fourth, when a product fails and parts need to be replaced, if the data is stored in EEPROM, and the controller chip is replaced, the product’s usage data can still be recovered.
The author previously worked on a product that had both external Flash and EEPROM. The external Flash used an SPI bus to store upgrade packages during OTA; EEPROM was used to save system operational data, such as boot counts, total runtime, system version number, and device consumable lifespan, etc.
Please stay tuned.
