DEV Community

ronnie R
ronnie R

Posted on

From eMMC to NAND: Software Optimization Strategies for Embedded System Storage

In the embedded system development, as the core carrier of information interaction, the technical characteristics of the memory directly affect the system's performance and stability. However, when dealing with complex OS environments like Linux and Android, some struggle with understanding their storage mechanisms. Forlinx Embedded aims to overcome these hurdles by sharing storage knowledge to help build a comprehensive framework.

First, the media commonly used to store data in embedded scenarios can be divided into two categories:
Managed NAND: Mainly includes eMMC (embedded Multi - Media Card), TF cards, and SD cards, which have an internal storage management controller.

Raw NAND: Mainly based on NAND, without storage management functions, only containing simple IO logic control.
The figure above describes the relationship between NAND storage and eMMC storage. The NAND Controller refers to the CPU of the SoM, and NAND refers to the actual storage area. It can be seen that the difference between eMMC and NAND actually lies in whether the storage management control is inside the eMMC or in the CPU of the SoM. Storage management mainly includes the following functions: bad block management, ECC verification, wear leveling, data retention, address management and mapping, etc.
01 Related Concepts of Storage

Storage Types: SLC, MLC, TLC, and QLC. In embedded systems, SLC and MLC are commonly used for low - capacity storage, while TLC is generally used for high-capacity storage.
SLC (Single-Level Cell) It has high speed, long lifespan, and high price, with a theoretical erase-write cycle of about 100,000 times.
MLC (Multi-Level Cell) It has relatively high speed, relatively long lifespan, and relatively high price, with a theoretical erase-write cycle of 3000–5000 times.
TLC (Trinary-Level Cell) It has low speed, short lifespan, and the lowest price, with a theoretical erase-write cycle of 1000–3000 times.
QLC (Quad-Level Cell) It can have a larger capacity and lower cost, but its P/E lifespan is shorter.
pSLC (pseudo SLC) It is based on MLC FLASH, but only stores 1 bit of data in each cell instead of 2 bits. Since it only stores 1 bit per cell like SLC but is not a real SLC, it is called pSLC.
According to the above principle, if MLC is used as pSLC, the storage space will be halved, and the lifespan can usually be increased to about 30,000 times.
P/E (Program/Erase Count) Erase-write lifespan, one of the two indicators of durability.
TBW (Total Bytes Written) Total write volume, which is the value used by manufacturers to define the warranty period. That is, after the write volume exceeds this value, the manufacturer will no longer provide warranty services. It is also one of the two indicators of durability.
FW (Firmware) Since the internal controller of eMMC is a software-programmable controller, it requires firmware. The corresponding firmware has been flashed into the eMMC before it leaves the storage manufacturer.
WA (Write amplification) Write amplification. It indicates how many times the actual physical data written is compared to the written data volume, i.e., the data volume written to the flash memory ÷ the data volume written by the main controller = write amplification.
GC(Garbage Collection) Garbage collection. The storage writing of NAND media is carried out page by page and erased block by block.
02 Differences Between eMMC and NAND

(1) Comparison Between eMMC and NAND

NANDeMMCAddress MappingEach time the CPU is mounted and read into memory, it is stored in NAND before being unloaded.Internal firmware management, using internal reservationsWear leveling, bad block management and garbage collectionNAND and file system drivers running on the CPUInternal firmware management, firmware maintenance by storage manufacturerECC error correctionThe CPU software or hardware is responsible for the error correction logic, and the error correction capability depends on the SoC controller and driver configuration.Internal firmware management with hardware ECC error correctionWrite AmplificationDetermined by the CPU driver strategy.Determined by internal firmware, and some manufacturers provide interfaces to query write-amplification information.PartitionA unified area, and the partitioning is determined by the CPU.There are specific security partitions and boot partitions for storing different types of data.
(2) Related Features of eMMC

eMMC uses a separate hardware controller to manage storage, which is more reliable than NAND driver management under Linux.
The internal firmware integrates multiple functions, such as recording health information like service life and dynamically adjusting internal storage strategies according to different scenarios.
It has a standardized interface, with good compatibility among different manufacturers and capacities.
Generally, the storage lifespan of eMMC is shorter than that of NAND. Most NAND uses SLC or MLC, while most eMMC uses MLC or TLC. The unit lifespan of eMMC is lower than that of NAND. However, since the storage capacity of eMMC is generally large, it offsets the disadvantage of the low unit lifespan to a certain extent.
(3) Related Features of NAND

The driver of the system is mainly determined by the SoC manufacturer and the upstream logic of the system, which can not give full play to the advantages of different NAND storage media, or has the compatibility problem of the driver logic.
NAND is prone to bit flips, bad blocks, etc. Compared with the internal management of eMMC, CPU management requires a large amount of system overhead to maintain the stored content.
The interface standard uses the ONFI interface protocol, but there are differences in the configuration of the page, OOB area, and block size of NAND from different manufacturers. If the material is discontinued and needs to be replaced, there is a risk of image incompatibility.
The layout control of NAND is managed by the CPU, so the corresponding partition management and logic customization have great flexibility. Different management strategies can be formulated according to the actual application scenarios.
The unit storage lifespan of NAND is relatively long.
In summary, it is recommended to use eMMC with management functions for product storage selection.

Top comments (0)