Changes

Jump to: navigation, search

MISC-TN-017: Persistent storage and read-write file systems

2,159 bytes added, 17:15, 17 January 2022
Example: embedded Linux system equipped with SanDisk SDINBDG4-8G-XI1 eMMC and ext4 file system
Some of the following examples refer to embedded Linux systems making use of NOR flashes or raw NAND flashes. Such systems are commonly managed by [http://www.linux-mtd.infradead.org/doc/general.html MTD]/[http://www.linux-mtd.infradead.org/doc/ubi.html UBI] subsystems and, on top of them, [http://www.linux-mtd.infradead.org/doc/ubifs.html UBIFS] to manage files.
Therefore, before diving into these examples, we suggest to take taking a look at our [[Memory Tecnology Device (MTD)]] article where these subsystems are explained in more detail.
== Embedded Linux systems with eMMC or SD cards ==
Another typical use case refers to eMMC's and SD cards. As explained [http://www.linux-mtd.infradead.org/doc/ubifs.html#L_raw_vs_ftl here], these components are FTL devices, where FTL stands for ''Flash Translation Layer''. This layer ''emulates a block device on top of flash hardware''. Therefore, these storage devices are used in tandem with file systems such as [https://en.wikipedia.org/wiki/Ext4 ext4] and [https://en.wikipedia.org/wiki/File_Allocation_Table#FAT32 FAT32]. Besides a raw NAND flash memory, eMMC's and SD cards integrate a microcontroller implementing the FTL and other important tasks as detailed in the rest of the document. All things considered, eMMC's and SD cards appear therefore to the host as managed-NAND block devices.
The sections related to eMMC-based use cases are the result of a joint effort between [https://www.westerndigital.com/ Western Digital] (which purchased [https://en.wikipedia.org/wiki/SanDisk SanDisk] in 2016), Lauterbach Italy, and DAVE Embedded Systems.
 
 
[[File:Lauterbach-logo.png|center|thumb|308x308px]]
 
[[File:WesterDigital-logo.png|center|thumb|180x180px]]
 
 
Parts of such sections are retrieved from the White Paper ''TRACE32 log method for analysing accesses to an eMMC device'' by Lauterbach, which is available for download [https://www.lauterbach.com/publications/trace32_log_method_for_analysing_accesses_to_an_emmc_device.pdf here].
=Wear-out=
The main indicator of ''how much data has been written'' for NAND devices is ''how many blocks has been erased'', assuming that a block has been erased only if:
* has already being been written (even if not completely)
* needs to be written again (this is not completely true, because UBI has a background tasks that erases dirty LEB while the system is idle).
Assuming that <code>TEC</code> is the ''sum of PEB Erase Counter'' and <code>DAYS</code> is the number of days the test has been run, the ''estimated amount of written data per year'' can be computed as:
</syntaxhighlight>
== Example: embedded Linux system equipped with SanDisk SDINBDG4-8G-XI1 eMMC and <code>ext4 </code> file system ==As stated previously, eMMC's and SD cards are block device. As such, they are operated in tandem with file systems that have been developed for hard disks and solid -state drives. [https://en.wikipedia.org/wiki/Ext4 <code>ext4</code>] is one of them and one of the most popular in the Linux world. On the one hand, eMMC's and SD cards are easier to use by the systems integrators because they hide most of the complexity regarding the management of the underlying NAND memory. On the other hand, their architecture could make it difficult to retrieve data regarding the actual usage of the memory at low level. There are several techniques, however, to address this issue when working with an embedded Linux platform:* Logging the accesses with the Linux kernel's Function Tracer (ftrace)* Logging the accesses with development/debugging tools such as Lauterbach TRACE32 and PowerDebug* Exploiting the storage device's built-in advanced functionsfunctionalities
In the following sections, these approaches are illustrated in more detail.
 
===Logging the accesses===
The idea is to log all the accesses triggered by the host and isolate the write operations. Two methods are compared. The first one makes use of a hardware-based trace tool while the other exploits a software tracer, namely the Linux kernel's Function Tracer (<code>ftrace</code>).
 
As is known, the specific architecture of a managed-NAND device can be extremely sensitive to certain read and write access sequences performed by the host processor under the direction of the application software, especially if these are frequently iterated.
 
A classic software-based recording method (log) of these accesses requires the implementation of additional code that captures information and saves it securely. The information can be saved on another permanent storage device, for example, an external USB drive. This software method is intrusive and in addition to the overhead of monitoring the eMMC access, additional overhead is added in order to save the data.
 
Besides a software-based approach, this example shows also a different method of capturing and saving such information through the use of a hardware-based trace tool. This can be done with minimal intrusion on the software and, in some cases, almost zero. This tool captures the program and data trace transmitted by the cores of a system-on-chip (SoC) through a dedicated trace port and records it to its own dedicated memory. To do that, advanced hardware functionalities of modern SoC's are exploited.
 
====Arm CoreSight™====
 
==== Lauterbach TRACE32 development tools ====
 
==== TRACE32-based eMMC access log solution ====
 
==== Implementation example for Linux OS ====
 
==== Comparison with the software method ftrace ====
 
==== Conclusion ====
 
==== References ====
 
==== Appendix 1: source code example ====
 
==== Appendix 2: time details ====
 
==== Appendix 3: TRACE32 tools configuration for Arm Cortex-A/R architectures ====
 
===Device's built-in advanced functionalities===
TBD
 
=Power failures=
4,650
edits

Navigation menu