Changes

Jump to: navigation, search

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

1,867 bytes added, 13:45, 20 January 2021
Example: embedded Linux system equipped with a raw NAND flash memory and UBIFS file system
=== Example: embedded Linux system equipped with a raw NAND flash memory and UBIFS file system ===
TBDOn embedded Linux system, raw NAND are commonly managed by MTD/UBI subsystems and, on top of them, UBIFS to manage files These subsystems are explained in more details in [[Memory Tecnology Device (MTD)]] article, here we'll focus on health monitoring There's two main indicator of NAND device health:* current ECC corrected errors* block erase counterWe'll focus on the latter because it's easy to extract and give a good lifetime expectation of the device UBI put [http://www.linux-mtd.infradead.org/doc/ubi.html#L_ubi_headers its header] on top of each NAND physical erase block ('''PEB''') and here, among the other fields, user can find the erase counter ('''EC'''). Comparing the sum of the EC of all PEB with the nominal expected maximum erase count, user can estimate the usage of the whole NAND device. To read EC directly from PEB at runtime, user can rely on <code>ubidumpec</code> tool: this is not yet merged in [http://git.infradead.org/mtd-utils.git mtd-utils] package but is provided as [http://lists.infradead.org/pipermail/linux-mtd/2015-May/059381.html RFC on linux-mtd mailing list] (it's also provided by default on most of DAVE Linux Embedded development kit) UBI partition expected remaining life in percentage can be calculated with a simple formula:<syntaxhighlight lang="text">RL = (MaxEC - sum(EC)) / MaxEC) * 100</syntaxhighlight>Where <code>MaxEC</code> is the maximum erase count supported by raw NAND. E.g. in case of a "standard" SLC NAND, which usually have 100k maximum erase count, this can be implemented as simple bash pipe between <code>ubidumpec</code> and <code>awk</code><syntaxhighlight lang="bash">ubidumpec /dev/ubi0 | awk -v MAXEC=100000 '{ s+=$1; n=n+1} END {print s, n*MAXEC, (((n*MAXEC)-s)/(n*MAXEC))*100 }'</syntaxhighlight>This command prints:* number of blocks (in this <code>/dev/ubi0</code> partition)*
743
edits

Navigation menu