YAFFS/YAFFS2 (Yet Another Flash File System) is a file system designed for use on NAND flash devices such as those commonly found in embedded systems. Unlike some other file systems which may be stored on the Flash device and then copied to RAM during boot (i.e. ramdisk) YAFFS/YAFFS2 actually resides on the Flash device and allows the user to read/write data to Flash. This is particularly useful in embedded devices that wish to save some persistent data between reboots. For more information on YAFFS/YAFFS2 please see the YAFFS wikipedia page as well as the YAFFS home page.
YAFFS/YAFFS2 is mainly designed for use with NAND Flash. While YAFFS/YAFFS2 can be used with NOR Flash devices it does not fit very well (because YAFFS does not use erase suspend). Generally if you are using a small flash device (less that 64MB) JFFS2 may be the better file system to use.
There are several reasons why YAFFS is useful in an embedded system. Some of the more common ones are
YAFFS2 supports all of the features of YAFFS and is backwards compatible with YAFFS but also has some additional features added.
While YAFFS/YAFFS2 can be of use in embedded systems there are some limitations that users should be aware of. The most common are
While there do exist utilities for creating a YAFFS/YAFFS2 file system image file they do not appear to be fully cooked and are not covered in this document. If you have used these utilities please feel free to add your input.
The method covered in this document for creating a YAFFS/YAFFS2 file system image is to create a tarball archive of the file system and use Linux to write that image to the file system partition. This requires the use of an intermediate file system (i.e. ramdisk, NFS, or hard drive file system) with the target version (ARM) of MTD Utilities installed in order to use the MTD subsystem to write the contents of the tarball archive to the Flash device.
To create a YAFFS/YAFFS2 image in this example you will need a target (ARM) root file system which you want to create a tarball image of (i.e. the content of a ramdisk or NFS share). For this example we will be using the sample ramdisk file system provided with the DVSDK software. For newer versions of the DVSDK (DVSDK 1.30 and greater) the sample ramdisk file system can be found at <DVSDK install dir>/<PSP directory>/bin. In older versions of the DVSDK (DVSDK 1.20 and earlier) the sample ramdisk file system can be found in the MontaVista installation directory at <MV install dir>/montavista/pro/devkit/arm/v5t_le/var/www/vhosts/mytiwiki.com/subdomains/wiki/httpdocs/images//.
As already mentioned it is possible to create a YAFFS/YAFFS2 file system image using the mkyaffsimage utility. However, it this document we will only cover creating a tarball image of a file system. The section below details how to create the tarball image.
This section will detail how to create a tarball file system image on a Linux development host. For this example I will be using the sample ramdisk.gz file shipped with the DVSDK. For information on locating the ramdisk.gz file please see the Prerequisites section.
host$ mkdir -p /home/user/workdir
host$ cd /home/user/workdir host$ cp <ramdisk path>/ramdisk.gz .
host$ mkdir ram host$ gunzip ramdisk.gz host$ mount ramdisk ram -o loop
NOTE: At this point you can add any additional files or applications you wish to the file system image at /home/user/workdir/ram before creating the tarball file system image.
host$ cd ram host$ tar czf ../rootfs.tar.gz *
The tarball rootfs.tar.gz located at /home/user/workdir is now ready to be used to populate the YAFFS/YAFFS2 file system.
By following this example you should now have created a file system image that you can use to populate the YAFFS/YAFFS2 file system. For more information on how to write this image to NAND plase see the Put YAFFS Image to Flash Page.
The Filesystem_in_NOR_or_NAND article has some more useful pointers as well.