file systems in real-time embedded applications
DESCRIPTION
File Systems in Real-Time Embedded Applications. Choosing the Right Storage Media. March 7th Eric Julien. Introduction. Storage media provides a nonvolatile backing device for one or multiple partitions. Different media, different attributes: Removability, Latency, - PowerPoint PPT PresentationTRANSCRIPT
File Systems in Real-Time Embedded Applications
March 7thEric Julien
Choosing the Right Storage Media
1
IntroductionStorage media provides a nonvolatile backing device for one or multiple partitions.
Different media, different attributes:• Removability,• Latency,• Sequential write/read throughput,• Random write/read throughput,• Cost, density,• Reliability, wear, etc.
2
Latency in embedded systems
Latency plays an often neglected role in FS performances on embedded systems.
Limited memory availability in embedded system prevent writes or reads using large buffers.
Global throughput becomes more affected by latency and less by I/O speed.
3
Latency: SD Card example
4
Bus speed Read length Rd time (WC) Throughput Improvement
25 MHz 512 B 1541 µs 324.5 KB/s 0 %
50 MHz 512 B 1520 µs 328.9 KB/s 1.4 %
25 MHz 1024 B 1582 µS 632.1 KB/s 94.8 %
SanDisk 2GB MicroSD Card, SD 4 bit mode•Access time: 1.5 ms (worst case).•I/O time, 512B @ 25MHz: 40.96 µs.•Total read time: 1541 µs (I/O 2.7% of total).
Storage Media Types
• RAM (volatile)• Hard Disk Drive, Solid State Drive • Unmanaged Flash Memory
• NOR Flash Memory• NAND Flash Memory
• Managed Flash Memory• Secure Digital (SD)/MultiMediaCard• CompactFlash
• USB Mass Storage Device
5
RAM
Volatile storage technology, unless battery-backed that has almost ideal performance characteristics.
•Very low latency, esp. static RAM,•Fast write and read throughput.
6
Hard Disk Drive
Stores data on rotating discs called platters coated with a magnetic material. Integrate a controller providing a sector based interface.•Head movement imply seek time (latency):
• Slower random access time.• Vulnerability to file system fragmentation.• Average latency around 12ms (mobile drives).• More RPM = less latency = more noise.
7
Hard Disk Drive• Huge capacity up to a few TB.
• Very low cost per bit.
• Good sequential throughput– Typical modern 7200 RPM drive can sustain “disk-to-
buffer” rates up to 130 MB/s (outer tracks).
• Reliability• Controller provides ECC, bad sector management.• Mechanical parts can cause data loss (eg. head
crash): less suitable for mobile embedded systems.
8
Unmanaged Flash MemoryFlash memory technology stores bits of information by modulating the charge on the floating-gate of field effect transistors.
The presence of a charge on the floating gate affects the threshold required to activate the transistor, allowing its state to be read.
9
Unmanaged Flash Memory Types
10
Bit line
Word line
Sourceline
Word line
Bit line
Source lineNOR
NAND
• Byte/word-addressable.• More metal contacts: bigger cell size.
• Page-addressable.• Less metal contacts: smaller cell size.
NOR Flash
11
• Cells must be erased prior to programming.• Byte/Word-addressable.
• Suitable for eXecute In Place (XIP).
• Cells are almost independent:• Byte/Word program possible.• Reads and programs don’t disturb neighboring cells.
• NORs generally don’t require ECC.
• Erases do affect multiple cells (page, sector, block).
NOR Flash
12
• Single-byte/word random reads are fast and low-latency. No moving mechanical parts.• Very good random and sequential read throughput.
• Slow programming and erase operations.• Poor sequential and random write throughput.
• High cost per bit, medium density (bigger cells).• Requires wear levelling: cell life 10 000 to 100 000
P/E cycles.• No bad blocks.
NOR Flash: interface
13
Two types of interfaces:• Parallel memory-mapped, using standard external bus
interface.• Best throughput/latency, XIP support, but uses more pins.
• Serially-interfaced devices (often SPI and variants).
Common Flash memory Interface (CFI) standard.• Provides info on queried device including:
• Size, block configuration, voltage, command set, etc.
• Eliminate need for descriptor tables.• Allows new devices to be used without SW updates.
NAND Flash• Cells must be erased prior to programming• Page addressable.
• Not suitable for XIP (unless special controller).
• Cells aren’t independent:• Smallest programmable unit: page.• Smallest erasable unit: block (many pages).• Reads and programs cause disturbance to other
cells in a block.• Data reliability affected; use of ECC mandatory.
14
NAND Flash• Page random reads are fast and low-latency.
• Very good random and sequential read throughput.
• Fast programming and erase operation.– Good sequential and random write throughput.
• Low cost per bit, high density (smaller cells).• Requires wear leveling:
– Average cell life SLC: 100 000 to 1 000 000 P/E cycles.– Average cell life MLC: 10 000 to 100 000 P/E cycles.
• Bad blocks must be dealt with (incl. factory).
15
NAND Flash: interface• Most common interface: parallel on IO bus.
• Less pins than parallel NOR.
• Some serial devices (often integrate ECC).• Multiple plane, multiple die devices.• Open NAND Flash Interface (ONFI) standard.
• Standard pinout for multiple packages.• Standard command set.• Parameter page for querying device parameters.• Timing requirements, etc.
16
Unmanaged Flash Comparison
17
Type NOR NAND
Addressable Unit Byte/Word Page (512B, 2kB, 4kB)
Sequential Write Very Slow Fast
Single Byte Write Slow Slow
Sequential Read Fast Very fast
Single Byte Read Fast Slow
eXecute In Place (XIP) Yes No
Density Low High
Cost per Bit High Low
Bad Blocks No Yes
Avg. cell life (P/E c.) 10 000-100 000 SLC: 100 000-1 000 000MLC: 10 000-100 000
Error Correction Codes Not required SLC: 1-8 bit/512 bytesMLC: 8+ bits/512 bytes
Managed Flash MemoryNOR and NAND Flash memories, due to their erase before write nature, need to be handled differently than traditional devices.The algorithms involved are often complex and/or costly.Managed flash memory devices provide a simpler interface, taking care of logical block abstraction, wear leveling, EDC data protection, bad block management, etc.
18
Secure Digital/MultiMediaCardSecure Digital (SD) and MultiMediaCard are removable devices that contain a storage device (often NAND) along with a controller.•Provides a standardized physical interface, socket and command set.•Basic variants of SD and MMC have identical pinouts and almost identical command set.•SD has a SPI compatible mode (MMC: opt.).
19
Secure Digital/MultiMediaCard
20
Card Type MMC MMCplus SD microSD eMMC
Form Factor Standard Standard Standard Micro IC
Pins 7 13 9 8 -
Removable Yes Yes Yes Yes No
1-bit bus mode Yes Yes Yes Yes Yes
4-bit bus mode No Opt. Opt. Opt. Opt.
8-bit bus mode No Opt. No No Opt.
SPI mode Opt. Opt. Yes Yes Opt.
Max bus rate 20 Mb/s 416 Mb/s 832 Mb/s 832 Mb/s 1600 Mb/s
Secure Digital
21
• Maximum capacity is 2GB for SD cards, 32 GB for SDHC cards and 2TB for SDXC cards.• SDA has recommended exFAT as FS for SDXC cards.
• Speed class: minimum sustained sequential read/write speed in MB/s with a card in a fragmented state (class 10: non-fragmented).• Random read/write performance not controlled.
• Ultra High Speed (UHS): bus modes increasing max bus bandwidth (DDR, clk rate, 1.8V).
e•MMCManaged flash memory in a non-removable package, compatible with MMCplus, convenient for integrated embedded system storage.
• Higher throughput bus modes,• TRIM (background erase),• Secure erase (purge),• Sanitize (purge unmapped),• Reliable writes,• Boot areas…
22
Secure Digital/MultiMediaCardPerformance of SD/MMC cards are highly dependent on embedded controller and storage device used.
• Sequential read/write throughput is usually good, but may be limited by max bus rate.
• Random read performance is usually middling, depending on controller latency.
• Random write performance is usually poor to mediocre, depending on controller.
23
USB Mass Storage Class DevicesUSB standard has a device class specifying a protocol for controlling a logical block addressed storage device through USB.Most common types:
• External HDD: similar performance to internal HDDs, but may be limited in throughput by bus.
• Flash memory (USB Flash drives): similar performance to SD/MMC cards, dependent on embedded controller and storage device.
24
Storage Media Comparison
25
Type Hard Disk NOR NAND SD/MMC
Addressable Unit Logical block Byte/Word Page Logical block
Sequential Write Very Good Very Slow Good Avg-Good
Random Write Good Slow Good Average
Sequential Read Outstanding Good Very Good Good
Random Read Poor Good Good Average-Good
Capacity High Low Average Average
Cost per Bit Very Low High Low Low
Reliability Fair Good Good Good
Expected life 5-15 yrs 10k-100k P/E (SLC)
100k-1M P/E (SLC)10k-100k P/E (MLC) Device dependent
USB HDD: similar to Hard Disk, USB Flash Drive: similar to SD/MMC