NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

Create a YAFFS Target Image

From Texas Instruments Wiki
Jump to: navigation, search

Introduction to YAFFS/YAFFS2[edit]

What is YAFFS[edit]

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.

Benefits of YAFFS[edit]

There are several reasons why YAFFS is useful in an embedded system. Some of the more common ones are

  1. YAFFS allows data to be written back to Flash for persistent storage
  2. YAFFS is optimized for NAND FLash memory which must be erased in block size segments
  3. YAFFS provides wear leveling for longer Flash memory life
  4. YAFFS file systems do not need to be copied from Flash to RAM to be used
  5. YAFFS uses less run-time RAM to hold its state, so YAFFS/YAFFS2 scales better than JFFS2 on large devices
  6. YAFFS garbage collection is simpler and faster, typically making for better performance under hard writing than JFFS2

Benefits of YAFFS2 vs. YAFFS[edit]

YAFFS2 supports all of the features of YAFFS and is backwards compatible with YAFFS but also has some additional features added.

  1. YAFFS2 support large block NAND devices
  2. YAFFS2 meets the "write once" requirement of modern NAND Flash
  3. YAFFS2 supports "shrink headers" to handle how to resize an existing file to a smaller size
  4. YAFFS2 uses a more abstract definition of NAND which allows it to be used with a wider variety of devices which may have different geometries as well as using auto-placement of OOB (Out of Band) data
  5. YAFFS2 supports "checkpointing" to bypass normal mount scanning to reduce boot time

Limitations of YAFFS/YAFFS2[edit]

While YAFFS/YAFFS2 can be of use in embedded systems there are some limitations that users should be aware of. The most common are

  1. YAFFS/YAFFS2 scans the entire file system during mount to check for valid data and recreate the file system tree. This can result in longer boot times, particularly for large flash devices
  2. YAFFS/YAFFS2 does not provide compression
  3. YAFFS/YAFFS2 is included in the TI kernel but may not be included in mainline kernels

Methods for Creating the File System Image[edit]

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.

Prerequisites[edit]

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/images/.

Making the File System Image[edit]

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.

Making a Tarball Image[edit]

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.

  • Create a working directory
   host$ mkdir -p /home/user/workdir
  • Copy the example ramdisk.gz file to the working directory
   host$ cd /home/user/workdir
   host$ cp <ramdisk path>/ramdisk.gz .
  • Gunzip and mount the ramdisk image to a temporary directory
   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.

  • Create the tarball image of the file system mounted at /home/user/workdir/ram
   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.

Conclusion[edit]

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.

Further reading[edit]

The Filesystem_in_NOR_or_NAND article has some more useful pointers as well.

E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Create a YAFFS Target Image here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Create a YAFFS Target Image here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article Create a YAFFS Target Image here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article Create a YAFFS Target Image here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article Create a YAFFS Target Image here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Create a YAFFS Target Image here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Create a YAFFS Target Image here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article Create a YAFFS Target Image here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article Create a YAFFS Target Image here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity