Below is a patch to the current cvs tree that adds functionality similar to the patch-ker.sh from yaffs and makes it possible to compile yaffs2 directly in a 2.6 kernel tree. I tested this with 2.6.11.12 but it should work for almost any tree. One known problem: You can't build yaffs2 as a module from this, you have to build it into the kernel. diff -ruN yaffs2.pristine/Kconfig yaffs2/Kconfig --- yaffs2.pristine/Kconfig 1969-12-31 16:00:00.000000000 -0800 +++ yaffs2/Kconfig 2005-07-05 22:42:56.000000000 -0700 @@ -0,0 +1,142 @@ +# +# YAFFS file system configurations +# +config YAFFS_FS + tristate "Yet Another Flash Filing System(YAFFS) file system support (version 2)" + help + YAFFS2, for Yet Another Flash Filing System, is a filing system + optimised for NAND Flash chips. + + To compile the YAFFS2 file system support as a module, choose M here: + the module will be called yaffs2. + + If unsure, say N. + + Further information on YAFFS2 is available at + . + +config YAFFS_YAFFS2 + depends on YAFFS_FS + tristate "YAFFS2" + help + Say y + +config YAFFS_MTD_ENABLED + bool "NAND mtd support - 512 byte / page devices" + depends on YAFFS_FS + help + This adds the yaffs file system support for working with a NAND mtd. + + If unsure, say Y. + +config YAFFS2_MTD_ENABLED + bool "NAND mtd support = 2k byte / page devices" + depends on YAFFS_YAFFS2 + help + This adds the yaffs2 file system support for working with a NAND mtd. + + If unsure, say Y. + +config YAFFS_RAM_ENABLED + bool "yaffsram file system support" + depends on YAFFS_FS + help + This adds the yaffs2ram file system support. Nice for testing on x86, + but uses 2MB of RAM. Don't enable for NAND-based targets. + + If unsure, say N. + +config YAFFS2_RAM_ENABLED + bool "yaffs2ram file system support" + depends on YAFFS_YAFFS2 + help + This adds the yaffs2ram file system support. Nice for testing on x86, + but uses 2MB of RAM. Don't enable for NAND-based targets. + + If unsure, say N. + +comment "WARNING: mtd and/or yaffsram support should be selected" + depends on YAFFS_FS && !YAFFS_MTD_ENABLED && !YAFFS_RAM_ENABLED + +comment "WARNING: mtd and/or yaff2sram support should be selected" + depends on YAFFS_YAFFS2 && !YAFFS2_MTD_ENABLED && !YAFFS2_RAM_ENABLED + +config YAFFS_USE_OLD_MTD + bool "Old mtd support" + depends on YAFFS_FS && 0 + help + Enable this to use the old MTD stuff that did not have yaffs2 support. + You can use this to get around compilation problems, but the best + thing to do is to upgrade your MTD support. You will get better speed. + + If unsure, say N. + +config YAFFS_USE_NANDECC + bool "Use ECC functions of the generic MTD-NAND driver" + depends on YAFFS_FS + default y + help + This enables the ECC functions of the generic MTD-NAND driver. + This will not work if you are using the old mtd. + + NB Use NAND ECC does not work at present with yaffsram. + + If unsure, say Y. + +config YAFFS_ECC_WRONG_ORDER + bool "Use the same ecc byte order as Steven Hill's nand_ecc.c" + depends on YAFFS_FS + help + This makes yaffs_ecc.c use the same ecc byte order as + Steven Hill's nand_ecc.c. If not set, then you get the + same ecc byte order as SmartMedia. + + If unsure, say N. + +config YAFFS_USE_GENERIC_RW + bool "Use Linux file caching layer" + default y + depends on YAFFS_FS + help + Use generic_read/generic_write for reading/writing files. This + enables the use of the Linux file caching layer. + + If you disable this, then caching is disabled and file read/write + is direct. + + If unsure, say Y. + +config YAFFS_USE_HEADER_FILE_SIZE + bool "Use object header size" + depends on YAFFS_FS + help + When the flash is scanned, two file sizes are constructed: + * The size taken from the object header for the file. + * The size figured out by scanning the data chunks. + If this option is enabled, then the object header size is used, + otherwise the scanned size is used. + + If unsure, say N. + +config YAFFS_DISABLE_CHUNK_ERASED_CHECK + bool "Turn off debug chunk erase check" + depends on YAFFS_FS + default y + help + Enabling this turns off the test that chunks are erased in flash + before writing to them. This is safe, since the write verification + will fail. Suggest enabling the test (ie. say N) + during development to help debug things. + + If unsure, say Y. + +config YAFFS_SHORT_NAMES_IN_RAM + bool "Cache short names in RAM" + depends on YAFFS_FS + default y + help + If this config is set, then short names are stored with the + yaffs_Object. This costs an extra 16 bytes of RAM per object, + but makes look-ups faster. + + If unsure, say Y. diff -ruN yaffs2.pristine/Makefile.kernel yaffs2/Makefile.kernel --- yaffs2.pristine/Makefile.kernel 1969-12-31 16:00:00.000000000 -0800 +++ yaffs2/Makefile.kernel 2005-07-05 22:42:48.000000000 -0700 @@ -0,0 +1,13 @@ +# +# Makefile for the linux YAFFS filesystem routines. +# + +obj-$(CONFIG_YAFFS_FS) += yaffs.o + +yaffs-y := yaffs_ecc.o yaffs_fs.o yaffs_guts.o +yaffs-y += yaffs_packedtags2.o yaffs_ramem.o yaffs_ramem2k.o +yaffs-y += yaffs_tagscompat.o yaffs_tagsvalidity.o +yaffs-y += yaffs_mtdif.o yaffs_mtdif2.o + +#yaffs2-$(CONFIG_YAFFS2_MTD_ENABLED) += yaffs_mtdif.o yaffs_mtdif2.o +#yaffs2-$(CONFIG_YAFFS2_RAM_ENABLED) += yaffs_ramem.o diff -ruN yaffs2.pristine/patch-ker.sh yaffs2/patch-ker.sh --- yaffs2.pristine/patch-ker.sh 1969-12-31 16:00:00.000000000 -0800 +++ yaffs2/patch-ker.sh 2005-07-05 23:07:34.000000000 -0700 @@ -0,0 +1,109 @@ +#!/bin/sh +# +# YAFFS: Yet another FFS. A NAND-flash specific file system. +# +# Copyright (C) 2002 Aleph One Ltd. +# +# Created by Charles Manning +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# Patch YAFFS into the kernel +# +# args: kpath : Full path to kernel sources to be patched +# +# Somewhat "inspired by" the mtd patchin script +# +# $Id: patch-ker.sh,v 1.1 2005/04/06 01:03:46 charles Exp $ + +VERSION=0 +PATCHLEVEL=0 +SUBLEVEL=0 +LINUXDIR=$1 + +# To be a Linux directory, it must have a Makefile + + +# Display usage of this script +usage () { + echo "usage: $0 kernelpath" + exit 1 +} + + + +if [ -z $LINUXDIR ] +then + usage; +fi + +# Check if kerneldir contains a Makefile +if [ ! -f $LINUXDIR/Makefile ] +then + echo "Directory $LINUXDIR does not exist or is not a kernel source directory"; + exit 1; +fi + +# Get kernel version +VERSION=`grep -s VERSION <$LINUXDIR/Makefile | head -n 1 | sed s/'VERSION = '//` +PATCHLEVEL=`grep -s PATCHLEVEL <$LINUXDIR/Makefile | head -n 1 | sed s/'PATCHLEVEL = '//` +SUBLEVEL=`grep -s SUBLEVEL <$LINUXDIR/Makefile | head -n 1 | sed s/'SUBLEVEL = '//` + +# Can we handle this version? +if [ $VERSION -ne 2 -o $PATCHLEVEL -lt 6 ] +then + echo "Cannot patch kernel version $VERSION.$PATCHLEVEL.$SUBLEVEL, must be 2.6.x or higher" + exit 1; +fi + + +KCONFIG=$LINUXDIR/fs/Kconfig +KCONFIGOLD=$LINUXDIR/fs/Kconfig.pre.yaffs +YAFFS_PATCHED_STRING=`grep -s yaffs <$KCONFIG | head -n 1` + +MAKEFILE=$LINUXDIR/fs/Makefile +MAKEFILEOLD=$LINUXDIR/fs/Makefile.pre.yaffs + +if [ ! -z "$YAFFS_PATCHED_STRING" ] +then + YAFFS_PATCHED=0 + echo "$KCONFIG already mentions YAFFS, so we will not change it" +else + # Change the fs/Kconfig file + # Save the old Kconfig + # Copy all stuff up to JFFS + # Insert some YAFFS stuff + # Copy all the rest of the stuff + + YAFFS_PATCHED=1 + echo "Updating $KCONFIG" + mv -f $KCONFIG $KCONFIGOLD + sed -n -e "/JFFS/,99999 ! p" $KCONFIGOLD >$KCONFIG + echo "">>$KCONFIG + echo "# Patched by YAFFS" >>$KCONFIG + echo "source \"fs/yaffs2/Kconfig\"">>$KCONFIG + echo "">>$KCONFIG + sed -n -e "/JFFS/,99999 p" $KCONFIGOLD >>$KCONFIG + + # now do fs/Makefile -- simply add the target at the end + echo "Updating $MAKEFILE" + cp -f $MAKEFILE $MAKEFILEOLD + echo "">>$MAKEFILE + echo "# Patched by YAFFS" >>$MAKEFILE + echo "obj-\$(CONFIG_YAFFS_FS) += yaffs2/" >>$MAKEFILE + +fi + +YAFFSDIR=$LINUXDIR/fs/yaffs2 + +if [ -e $YAFFSDIR ] +then + echo "$YAFFSDIR exists, not patching" +else + mkdir $LINUXDIR/fs/yaffs2 + cp Makefile.kernel $LINUXDIR/fs/yaffs2/Makefile + cp Kconfig $LINUXDIR/fs/yaffs2 + cp *.c *.h $LINUXDIR/fs/yaffs2 +fi diff -ruN yaffs2.pristine/README yaffs2/README --- yaffs2.pristine/README 1969-12-31 16:00:00.000000000 -0800 +++ yaffs2/README 2005-07-05 22:44:18.000000000 -0700 @@ -0,0 +1,9 @@ +To build YAFFS in the Linux kernel tree you need to run the patch-in-yaffs +script. + +After you've run the script, go back to your normal kernel making procedure +and configure the yaffs settings you want. + +Prolems? Contact the yaffs mailing list. + +$Id: README,v 1.2 2005/04/06 01:03:46 charles Exp $ \ No newline at end of file diff -ruN yaffs2.pristine/yaffs_ecc.c yaffs2/yaffs_ecc.c --- yaffs2.pristine/yaffs_ecc.c 2005-07-05 22:33:39.000000000 -0700 +++ yaffs2/yaffs_ecc.c 2005-07-05 23:14:34.000000000 -0700 @@ -32,6 +32,7 @@ const char *yaffs_ecc_c_version = "$Id: yaffs_ecc.c,v 1.2 2005/03/16 04:00:36 charles Exp $"; +#include #include "yaffs_ecc.h" static const unsigned char column_parity_table[] = { diff -ruN yaffs2.pristine/yaffs_guts.c yaffs2/yaffs_guts.c --- yaffs2.pristine/yaffs_guts.c 2005-07-05 22:33:39.000000000 -0700 +++ yaffs2/yaffs_guts.c 2005-07-05 23:16:53.000000000 -0700 @@ -15,6 +15,7 @@ //yaffs_guts.c const char *yaffs_guts_c_version="$Id: yaffs_guts.c,v 1.8 2005/07/05 23:54:59 charles Exp $"; +#include #include "yportenv.h" diff -ruN yaffs2.pristine/yaffs_mtdif2.c yaffs2/yaffs_mtdif2.c --- yaffs2.pristine/yaffs_mtdif2.c 2005-07-05 22:33:39.000000000 -0700 +++ yaffs2/yaffs_mtdif2.c 2005-07-05 23:15:49.000000000 -0700 @@ -17,6 +17,7 @@ const char *yaffs_mtdif2_c_version = "$Id: yaffs_mtdif2.c,v 1.1 2004/12/17 04:39:04 charles Exp $"; +#include #ifdef CONFIG_YAFFS_MTD_ENABLED #include "yportenv.h" diff -ruN yaffs2.pristine/yaffs_mtdif.c yaffs2/yaffs_mtdif.c --- yaffs2.pristine/yaffs_mtdif.c 2005-07-05 22:33:39.000000000 -0700 +++ yaffs2/yaffs_mtdif.c 2005-07-05 23:15:46.000000000 -0700 @@ -15,6 +15,8 @@ const char *yaffs_mtdif_c_version = "$Id: yaffs_mtdif.c,v 1.1 2004/12/17 04:39:04 charles Exp $"; +#include + #ifdef CONFIG_YAFFS_MTD_ENABLED #include "yportenv.h" diff -ruN yaffs2.pristine/yaffs_packedtags1.c yaffs2/yaffs_packedtags1.c --- yaffs2.pristine/yaffs_packedtags1.c 2005-07-05 22:33:39.000000000 -0700 +++ yaffs2/yaffs_packedtags1.c 2005-07-05 23:16:07.000000000 -0700 @@ -1,3 +1,4 @@ +#include #include "yaffs_packedtags1.h" #include "yportenv.h" diff -ruN yaffs2.pristine/yaffs_packedtags2.c yaffs2/yaffs_packedtags2.c --- yaffs2.pristine/yaffs_packedtags2.c 2005-07-05 22:33:39.000000000 -0700 +++ yaffs2/yaffs_packedtags2.c 2005-07-05 23:16:14.000000000 -0700 @@ -13,6 +13,7 @@ * version 2.1 as published by the Free Software Foundation. */ +#include #include "yaffs_packedtags2.h" #include "yportenv.h" #include "yaffs_tagsvalidity.h" diff -ruN yaffs2.pristine/yaffs_tagscompat.c yaffs2/yaffs_tagscompat.c --- yaffs2.pristine/yaffs_tagscompat.c 2005-07-05 22:33:39.000000000 -0700 +++ yaffs2/yaffs_tagscompat.c 2005-07-05 23:16:27.000000000 -0700 @@ -13,6 +13,7 @@ * $Id: yaffs_tagscompat.c,v 1.2 2005/03/16 04:00:36 charles Exp $ */ +#include #include "yaffs_guts.h" #include "yaffs_tagscompat.h" #include "yaffs_ecc.h" diff -ruN yaffs2.pristine/yaffs_tagsvalidity.c yaffs2/yaffs_tagsvalidity.c --- yaffs2.pristine/yaffs_tagsvalidity.c 2005-07-05 22:33:39.000000000 -0700 +++ yaffs2/yaffs_tagsvalidity.c 2005-07-05 23:16:38.000000000 -0700 @@ -15,6 +15,7 @@ */ //yaffs_tagsvalidity.c +#include #include "yaffs_tagsvalidity.h"