[Yaffs-archive] Re: mounting yaffs fs on MTD

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Charles Manning
Date:  
To: Tim M. Sanders, yaffs
Subject: [Yaffs-archive] Re: mounting yaffs fs on MTD
On Friday 09 January 2004 12:34, Tim M. Sanders wrote:
> I have written a character MTD driver for a NAND flash board (PCI). I use
> the tools in the MTD driver package (nanddump, nandwrite, erase, eraseall,
> etc) and have verified that my driver is working.
>
> I start by erasing the entire NAND device.
>
> I load the yaffs.o module
>
>     yaffs Jan  7 2004 06:59:15 Initialisation
>     yaffs is using direct read/write (uncached)
>     yaffs: dev is 7936 name is "1f:00"
>     yaffs: Attempting MTD mount on 31.0, "1f:00"

>
> and try to mount the device (char device /dev/mtd0, major 90, minor 0.
> This does not work. So I create a MTD block device (block device
> /dev/mtdblock0, major 31, minor 0). The mount works with the block device.
>
>     mount -t yaffs /dev/mtdblock0 /mnt/yaffs

>
> When I try to copy a file (cp yaffs_guts.c /mnt/yaffs) I get the following
> error(s):
>
> cp yaffs_guts.c /mnt/yaffs
> cp: cannot create regular file `/mnt/yaffs/yaffs_guts.c': Cannot allocate
> memory
>
> Any experience with this error?



The answer lies in the log messages below:

YAFFS was not seeing erased blocks when it was reading them to allocate. It
could thus not find anywhere to write the data and failed.

The function doing the check is:

static int yaffs_CheckChunkErased(struct yaffs_DeviceStruct *dev,int
chunkInNAND)
{

    static int init = 0;
    static __u8 cmpbuf[YAFFS_BYTES_PER_CHUNK];
    static __u8 data[YAFFS_BYTES_PER_CHUNK];
    // Might as well always allocate the larger size for dev->useNANDECC == 
true;
    static __u8 spare[sizeof(struct yaffs_NANDSpare)];    


      dev->readChunkFromNAND(dev,chunkInNAND,data,(yaffs_Spare *)spare);


    if(!init)
    {
        memset(cmpbuf,0xff,YAFFS_BYTES_PER_CHUNK);
        init = 1;
    }


    if(memcmp(cmpbuf,data,YAFFS_BYTES_PER_CHUNK)) return  YAFFS_FAIL;
    if(memcmp(cmpbuf,spare,16)) return YAFFS_FAIL;



    return YAFFS_OK;

    
}

Thus, either the spare or data regions are not erased.

I am unsure as to what the utils you are using erase, but an alternative is
to use mkyaffs.

Also, if you have hardware ECC, this might be contaminating the spare.
Perhaps add more debugging to determine where the problem is coming from.



> **>> yaffs chunk 130877 was not erased
> **>> yaffs chunk 130878 was not erased
> **>> yaffs chunk 130879 was not erased
> **>> Block 4089 retired
> **>> yaffs write required 130848 attempts


---------------------------------------------------------------------------------------
This mailing list is hosted by Toby Churchill open software (www.toby-churchill.org).
If mailing list membership is no longer wanted you can remove yourself from the list by
sending an email to with the text "unsubscribe"
(without the quotes) as the subject.