world leader in high performance signal processing
Trace: » yaffs

Yet Another Flash File System (YAFFS)

Since JFFS has some series short comings when working with large devices (such as NAND), the Yet Another Flash File System (YAFFS) project was started. While it can be used on any flash device like JFFS, it is commonly seen when working with NAND flashes.

The YAFFS homepage can be found at


The method for managing MTD partition tables is documented in the Partitioning document. Here we will focus on just using the default partition scheme which has a partition setup specifically for a root file system.

Kernel Settings

Please consult the MTD document for relevant kernel settings for the higher MTD layers. If you plan on using YAFFS as your root file system, these options will have to be built into your kernel and not as modules. The method for loading modules before mounting the root file system is not documented here and is left as an exercise for the user.

You will also need to enable support for the YAFFS filesystem itself.

File systems   --->
  Miscellaneous filesystems  --->
    <*> YAFFS2 file system support
    ---   2048 byte (or larger) / page devices
    [*]     Autoselect yaffs2 format
    (select other options as you wish)

uClinux-dist Settings

There is no need to select anything under the uClinux distribution. Root file systems will automatically be created for you when you enable YAFFS support in your kernel. See the images document for more information.

If you wish to create your own file system images, just use the mkfs.yaffs2 program. Once you've compiled the uClinux distribution, you can find it here:

$ ./user/yaffs-utils/mkfs.yaffs2 --help
mkyaffs2image: image building tool for YAFFS2 built Jun 12 2008
usage: mkyaffs2image dir image_file [convert]
           dir        the directory tree to be converted
           image_file the output file to hold the image
           'convert'  produce a big-endian image from a little-endian machine

Note that in older distributions, this utility may be found at uClinux-dist/user/blk-apps/yaffs-utils/utils/mkyaffs2image.

Kernel Messages

In the kernel log we see the NAND device and its partitions being detected on the BF548-EZKIT:

BF5xx on-chip NAND FLash Controller Driver, Version 1.2 (c) 2007 Analog Devices, Inc.
bf5xx-nand bf5xx-nand.0: page_size=256, data_width=8, wr_dly=3, rd_dly=3
NAND device: Manufacturer ID: 0x20, Chip ID: 0xda (ST Micro NAND 256MiB 3,3V 8-bit)
Creating 2 MTD partitions on "NAND 256MiB 3,3V 8-bit":
0x00000000-0x00400000 : "Linux Kernel"
0x00400000-0x10000000 : "File System"

Formatting under the Blackfin

Creating YAFFS2 filesystems on the Blackfin board is easy. First install the flash_eraseall utility from the mtd-utils package. Then simply erase the partition before mounting it.

  • Check the partition table:
    root:/> cat /proc/mtd
    dev:    size   erasesize  name
    mtd0: 00400000 00020000 "Linux Kernel"
    mtd1: 0fc00000 00020000 "File System"
  • Erase the partition:
    root:/> flash_eraseall /dev/mtd1
    Erasing 128 Kibyte @ 3ee0000 -- 24 % complete.
    Skipping bad block at 0x03f00000
    Erasing 128 Kibyte @ c580000 -- 78 % complete.
    Skipping bad block at 0x0c5a0000
    Erasing 128 Kibyte @ eb80000 -- 93 % complete.
    Skipping bad block at 0x0eba0000
    Erasing 128 Kibyte @ fbe0000 -- 99 % complete.
  • Mount as YAFFS2:
    root:/> mount -t yaffs2 /dev/mtdblock0 /mnt/
    yaffs: dev is 32505856 name is "mtdblock0"
    yaffs: Attempting MTD mount on 31.0, "mtdblock0"
    root:/> ls /mnt/