Click here to learn
about this Sponsor:
Home  |  News  |  Articles  |  Polls  |  Forum

Keywords: Match:
Introducing YAFFS, the first NAND-specific flash file system
by Charles Manning (Sept. 20, 2002)

Overview

YAFFS stands for 'yet another flash file system' (see footnote 1). As far as I am aware, YAFFS is the only file system, under any operating system, that has been designed specifically for use with NAND flash. YAFFS is thus designed to work within the constraints of, and exploit the features of, NAND flash to maximize performance. YAFFS uses journaling, error correction, and verification techniques tuned to the way NAND typically fails to enhance robustness. The result is a file system that exploits low-cost NAND chips and is both fast and robust. YAFFS is highly portable and runs under Linux, uClinux, and Windows CE. YAFFS is an open source project.

Why NAND flash?

Embedded and mobile systems are increasingly using NAND flash for storage because it has various advantages over other storage technologies. As always though, life is a compromise and those advantages come with some limitations that need to be addressed to provide a robust flash file system.

Hard disks are not a viable storage option for many embedded and handheld systems because they are too big, too fragile and use too much power. For some years now, people have been using common-old NOR flash for file system storage. JFFS and JFFS2 do an excellent job of this for Linux. For storage applications NOR flash is not that great because it is not very dense (i.e. not much storage per chip), is costly and is slow to write. NAND flash, on the other hand, is low cost, dense, and writes fast; but it has other limitations. The most common consumer usage of NAND flash is in the form of SmartMedia cards, which are simply NAND chips bonded to a carrier card. Consumer use of SmartMedia is driving down NAND prices, while driving up densities.

The standard SmartMedia file system is FAT-based and is thus susceptable to corruption due to power failures, crashes, and other acts of demonic forces. This raises robustness concerns, particularly in embedded systems where a corrupted file system can kill the device (or do even worse collateral damage). What's really needed is a journaling file system that is able to work around the limitations of NAND and exploit it for best performance.

History

The lead-up to YAFFS started with an investigation into modifying the JFFS2 flash file system to work with NAND flash (see footnote 2) for some Aleph One customers. At first, it seemed reasonable that the best way to get a file system for NAND flash would be just 'tweaking' an existing flash file system. On deeper investigation, though, it became apparent that designing a new file system specifically for NAND might have some benefits.


Comparison of NOR and NAND Flash technologies


Designing an effective flash file system is a difficult task, and you need to jump through many hoops of fire to get a useful system. Although both are called 'Flash', NOR and NAND flash have very different properties. Thus, a flash file system that works with NOR incorporates various mechanisms that are not required for NAND, and NAND needs extra mechanisms not required for NOR.

For example, garbage collection performance is largely determined by the erasure time. NOR erases very slowly and thus an effective NOR garbage collection strategy is relatively complex and limits the design options. In comparison, NAND erases very quickly thus these limitations don't apply.

Another major difference is that NAND is shipped with marked bad blocks on the device, while NOR chips are shipped defect free. Thus, one expects to encounter some failures in NAND and should design accordingly.

On top of this, we also realized that typical NAND flash arrays would be far larger than typical NOR flash arrays (see footnote 3). This raised concerns as to how well JFFS2 would scale up, particularly with regard to RAM usage, mounting/scanning time, and garbage collection time.

This lead me to believe that it would be worth designing a file system specifically for NAND flash, exploiting the features of NAND to simplify the design, and catering to NAND specific limitations directly -- rather than trying to 'bend' NAND to work with an existing file system architecture, or vice versa.

The first conceptual design for YAFFS was drawn up in late December 2001. Once the customers bought in to the idea, things progressed rapidly. The first line of code was cut in January 2002. By May 2002 we had the first publicly available CVS code. We now have at least six different companies using or experimenting with YAFFS in embedded or handheld systems. YAFFS is already very stable and is rapidly becoming a very useful file system. We expect to see YAFFS-based products shipped before the end of the year.

Design approach

Rather than develop and debug code inside the Linux kernel, I took the approach of developing the file system 'guts' algorithms -- the most complex part -- in a user space program. To achieve this, the code is split into four sections:
  • yaffs_guts.c: The file system algorithms. This code is fully portable C.
  • yaffs_fs.c: Interface layer to the Linux VFS. Can be replaced with a test harness for user space developing of yaffs_guts.c
  • NAND interface: wrapper layer between yaffs_guts and the NAND memory access functions. eg. calls Linux mtd layer or RAM emulation layer.
  • Portability functions: wrapper functions for services such as memory allocation etc.
This modular design has provided a lot of flexibility for testing and development. A user space program and DDD is a far more rapid development environment that continually hanging the Linux kernel. Also, a RAM-based NAND emulation layer provides an excellent way to debug the file system in-kernel without special hardware.

A further spin-off has been that YAFFS is portable to other operating systems. For example, a port of YAFFS for Windows CE was readily achieved by writing a new wrapper layer to hook up to the WinCE file system manager and new NAND access layer. yaffs_guts.c remains 100% portable (see footnote 4). YAFFS is thus likely to be easily portable to other OSes too.

Results

Removing surplus constraints has lead to a simpler design that has improved performance and robustness as well, and also has reduced development time.

YAFFS reads and writes pretty fast. There is no significant hit due to garbage collection -- i.e., in most situations garbage collection overheads are not likely to impact usage.

It is difficult to give meaningful benchmarks given non-standard hardware. However here are some results achieved on a StrongARM-based board with 128MB of NAND flash: write speed is approximately 800KB/sec, and read speed is approximately 1.5MB/sec; in a weekend stress test I wrote, triple-verified, then deleted 25GB of file data without a single bit of file data being corrupted. Note that 25GB exceeds the design lifetime of most embedded or handheld devices.

Future

Although YAFFS already performs well, there is still a lot of room for improvement. Development is continuing to enhance performance and robustness as well as add support software such as utilities, bootloader support, and analysis tools.

I expect to see ports to other OSes too. Increasing the user base of YAFFS is an important way to get more eyes over the code and test it under a wider set of scenarios.

The YAFFS development community is growing well, with good involvement from people all over the world. YAFFS is realizing all the benefits open source projects hope for and will, we expect, continue to grow.



Want more info about YFFS?

The YAFFS project home page provides further investigation reports, YAFFS documentation, and instructions for access CVS and the YAFFS mail list.



Footnotes:
  1. The YAFFS name came from the first concept document proposing yet another flash file system. Some how that name just stuck.

  2. NAND support has since been added to JFFS2 by others. The YAFFS, JFFS2 and mtd communities cooperate to provide a rich flexible set of solutions to draw from. As is the nature of open source projects, JFFS2 code was used as a reference for some parts of the YAFFS development, particularly for figuring out the VFS interface. Google for further info on JFFS2 and mtd.

  3. A 32MB NOR array would be considered large. Single NAND chips of 256MB are already available. YAFFS is undergoing testing on NAND arrays of up to 512MB or larger.

  4. Some features were added to the guts to enhance WinCE usage. For example, the string comparison function was made configurable to be either strcmp or scricmp because Windows file names are case insensitive.


About the author: Charles Manning (aka The Embedded Janitor) lives near Christchurch, New Zealand, and has been developing and mopping up embedded systems for twenty years. His hobbies include fly tying and spinning wool.



Related stories:

(Click here for further information)


FUEL Database on MontaVista Linux
Whether building a mobile handset, a car navigation system, a package tracking device, or a home entertainment console, developers need capable software systems, including an operating system, development tools, and supporting libraries, to gain maximum benefit from their hardware platform and to meet aggressive time-to-market goals.

Breaking New Ground: The Evolution of Linux Clustering
With a platform comprising a complete Linux distribution, enhanced for clustering, and tailored for HPC, Penguin Computing�s Scyld Software provides the building blocks for organizations from enterprises to workgroups to deploy, manage, and maintain Linux clusters, regardless of their size.

Data Monitoring with NightStar LX
Unlike ordinary debuggers, NightStar LX doesn�t leave you stranded in the dark. It�s more than just a debugger, it�s a whole suite of integrated diagnostic tools designed for time-critical Linux applications to reduce test time, increase productivity and lower costs. You can debug, monitor, analyze and tune with minimal intrusion, so you see real execution behavior. And that�s positively illuminating.

Virtualizing Service Provider Networks with Vyatta
This paper highlights Vyatta's unique ability to virtualize networking functions using Vyatta's secure routing software in service provider environments.

High Availability Messaging Solution Using AXIGEN, Heartbeat and DRBD
This white paper discusses a high-availability messaging solution relying on the AXIGEN Mail Server, Heartbeat and DRBD. Solution architecture and implementation, as well as benefits of using AXIGEN for this setup are all presented in detail.

Understanding the Financial Benefits of Open Source
Will open source pay off? Open source is becoming standard within enterprises, often because of cost savings. Find out how much of a financial impact it can have on your organization. Get this methodology and calculator now, compliments of JBoss.

Embedded Hardware and OS Technology Empower PC-Based Platforms
The modern embedded computer is the jack of all trades appearing in many forms.

Data Management for Real-Time Distributed Systems
This paper provides an overview of the network-centric computing model, data distribution services, and distributed data management. It then describes how the SkyBoard integration and synchronization service, coupled with an implementation of the OMG�s Data Distribution Service (DDS) standard, can be used to create an efficient data distribution, storage, and retrieval system.

7 Advantages of D2D Backup
For decades, tape has been the backup medium of choice. But, now, disk-to-disk (D2D) backup is gaining in favor. Learn why you should make the move in this whitepaper.

 


Got a HOT tip?   please tell us!
Free weekly newsletter
Enter your email...
Click here for a profile of each sponsor:
PLATINUM SPONSORS
GOLD SPONSORS
(Become a sponsor)
(Become a sponsor)

ADVERTISEMENT
(Advertise here)

Check out the latest Linux powered...

Mobile phones!

MIDs, UMPCs
& tablets

Mobile devices

Other cool
gadgets



Resource Library

• Unix, Linux Uptime and Reliability Increase: Patch Management Woes Plague Windows Yankee Group survey finds IBM AIX Unix is highest in ...
• Scalable, Fault-Tolerant NAS for Oracle - The Next Generation For several years NAS has been evolving as a storage ...
• Managing Software Intellectual Property in an Open Source World This whitepaper draws on the experiences of the Black Duck ...
• Open Source Security Myths Dispelled Is it risky to trust mission-critical infrastructure to open source ...
• Bringing IT Operations Management to Open Source & Beyond Download this IDC analyst report to learn how open source ...


BREAKING NEWS

• PC/104 module runs Linux on "two Watt" SoC
• Development kit adds "personality" to ARM9 SoC
• Audio system taps Linux, 802.11n
• Can automotive survive without open source?
• Media-savvy NAS offers DLNA support
• DPF design runs Linux
• Subversion software appliance runs Linux
• 1.5-pound mini-laptop boots Linux fast
• UC Extension offers embedded Linux courses
• Itanium cruising at full steam, claims backers
• Palm unveils Linux "Pre" smartphone
• WiFi digital camera runs Linux
• Skype aims VoIP client at MIDs
• Touchscreen Net radio design runs Linux
• DPF design runs Linux on ARM11


Most popular stories -- past 90 days:
• Linux boots in 2.97 seconds
• Tiniest Linux system, yet?
• Linux powers "cloud" gaming console
• Report: T-Mobile sells out first 1.5 million G1s
• Open set-top box ships
• E17 adapted to Linux devices, demo'd on Treo650
• Android debuts
• First ALP Linux smartphone?
• Cortex-A8 gaming handheld runs Linux
• Ubuntu announces ARM port


DesktopLinux headlines:
• "I'm Linux" contest open for video entries
• Debian permits binary blobs
• Bluefish top Linux HTML editor
• Times damns Ubuntu with faint praise
• Skype ships beta for MIDs
• Vietnam mandates open source for gov't servers, desktops
• A peek at Phoenix HyperSpace
• Linux desktop gains kid-friendly browser
• OpenSUSE Community Manager discusses 11.1 release
• "...and I'm Linux" video contest approaches


Also visit our sister site:


Sign up for LinuxDevices.com's...

news feed

Home  |  News  |  Articles  |  Polls  |  Forum  |  About  |  Contact
 

Ziff Davis Enterprise Home | Contact Us | Advertise | Link to Us | Reprints | Magazine Subscriptions | Newsletters
Tech RSS Feeds | White Papers | ROI Calculators | Tech Podcasts | Tech Video | VARs | Channel News

Baseline | Careers | Channel Insider | CIO Insight | DesktopLinux | DeviceForge | DevSource | eSeminars |
eWEEK | Enterprise Network Security | LinuxDevices | Linux Watch | Microsoft Watch | Mid-market | Networking | PDF Zone |
Publish | Security IT Hub | Strategic Partner | Web Buyer's Guide | Windows for Devices

Developer Shed | Dev Shed | ASP Free | Dev Articles | Dev Hardware | SEO Chat | Tutorialized | Scripts |
Code Walkers | Web Hosters | Dev Mechanic | Dev Archives | igrep

Use of this site is governed by our Terms of Service and Privacy Policy. Except where otherwise specified, the contents of this site are copyright © 1999-2008 Ziff Davis Enterprise Holdings Inc. All Rights Reserved. Reproduction in whole or in part in any form or medium without express written permission of Ziff Davis Enterprise is prohibited. Linux is a registered trademark of Linus Torvalds. All other marks are the property of their respective owners.