Dear All,
I have a build with the cvs version of yaffs1/yaffs2
integrated. I can successfully mount the partition and copy
large/small files to the chip without any problems. The issue is that
all the data is lost when i umount and remount it . I have tried this
with different kernel versions , frank's yaffs patch , balloon
kernels, cvs yaffs but the issue remains the same. Below is a detailed
log
My .config is
CONFIG_YAFFS_FS=y
CONFIG_YAFFS_YAFFS1=y
CONFIG_YAFFS_DOES_ECC=n
CONFIG_YAFFS_ECC_WRONG_ORDER=y
CONFIG_YAFFS_YAFFS2=y (* Had to enable this else it compilation cracks up)
CONFIG_YAFFS_DISABLE_CHUNK_ERASED_CHECK=y
CONFIG_YAFFS_SHORT_NAMES_IN_RAM=y
[root@Sarva 2.6.13]#insmod manavd.ko
.........
Bad eraseblock 4087 at 0x03fdc000
Bad eraseblock 4088 at 0x03fe0000
Bad eraseblock 4091 at 0x03fec000
Bad eraseblock 4092 at 0x03ff0000
Bad eraseblock 4093 at 0x03ff4000
Creating 1 MTD partitions on "NAND 64MiB 3,3V 8-bit":
0x00000000-0x04000000 : "Filesystem on nand"
mtd: Giving out device 3 to Filesystem on nand
Sarva_mtd->erasesize = 16384
Sarva_mtd->oobblock = 512
Sarva_mtd->oobsize = 16
Sarva_mtd->eccsize = 256
Sarva_chip->page_shift = 9
[root@Sarva ] mount -t yaffs /dev/mtdblock3 /mnt/flash/
........................................
Block scanning block 4091 state 3 seq 0
Block empty
Block scanning block 4092 state 8 seq 0
block 4092 is bad
Block scanning block 4093 state 8 seq 0
block 4093 is bad
Block scanning block 4094 state 8 seq 0
block 4094 is bad
Block scanning block 4095 state 3 seq 0
Block empty
Block scanning block 4096 state 3 seq 0
Block empty
yaffs_Scan ends
yaffs: yaffs_GutsInitialise() done.
yaffs_read_super: guts initialised OK
yaffs_read_super: got root inode
yaffs_read_super: d_alloc_root done
yaffs_read_super: done
[root@Sarva /mnt]#ls
cf flash image.img jffs2 usb
[root@Sarva 2.6.13]#df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/mtdblock2 31488 25056 6432 80% /
/dev/mtdblock3 65536 41072 24464 63% /mnt/flash
[root@Sarva 2.6.13]#cat /proc/yaffs
YAFFS built:Aug 25 2005 09:02:20
$Id: yaffs_fs.c,v 1.29 2005/08/11 01:07:43 marty Exp $
$Id: yaffs_guts.c,v 1.18 2005/08/16 02:28:04 charles Exp $
Device 0 "Filesystem on nand"
startBlock......... 0
endBlock........... 4095
chunkGroupBits..... 2
chunkGroupSize..... 4
nErasedBlocks...... 1535
nTnodesCreated..... 0
nFreeTnodes........ 0
nObjectsCreated.... 100
nFreeObjects....... 96
nFreeChunks........ 49120
nPageWrites........ 0
nPageReads......... 0
nBlockErasures..... 0
nGCCopies.......... 0
garbageCollections. 0
passiveGCs......... 0
nRetriedWrites..... 0
nRetireBlocks...... 0
eccFixed........... 0
eccUnfixed......... 0
tagsEccFixed....... 0
tagsEccUnfixed..... 0
cacheHits.......... 0
nDeletedFiles...... 0
nUnlinkedFiles..... 0
nBackgroudDeletions 0
useNANDECC......... 1
isYaffs2........... 0
[root@Sarva 2.6.13]#cp /root/exp/nanddump.c /mnt/flash/
yaffs_mknod: making oject for nanddump.c, mode 81a4 dev 0
yaffs: Tnodes added
Allocated block 1, seq 4097, 1534 left
Writing chunk 0 tags 261 0
Inside yaffs_WriteChunkWithTagsToNAND<7>yaffs_get_inode for object 261
Writing chunk 1 tags 261 1
Inside yaffs_WriteChunkWithTagsToNAND<4>Writing chunk 2 tags 261 2
Inside yaffs_WriteChunkWithTagsToNAND<4>Writing chunk 3 tags 261 3
Inside yaffs_WriteChunkWithTagsToNAND<4>Writing chunk 4 tags 261 4
Inside yaffs_WriteChunkWithTagsToNAND<4>Writing chunk 5 tags 261 5
Inside yaffs_WriteChunkWithTagsToNAND<4>Writing chunk 6 tags 261 6
Inside yaffs_WriteChunkWithTagsToNAND<4>Writing chunk 7 tags 261 7
Inside yaffs_WriteChunkWithTagsToNAND<4>Writing chunk 8 tags 261 8
Inside yaffs_WriteChunkWithTagsToNAND<7>yaffs_file_write writing 4096
bytes, 4096 written at 0
Chunk -1 not found zero instead
Chunk -1 not found zero instead
Chunk -1 not found zero instead
Chunk -1 not found zero instead
Chunk -1 not found zero instead
Chunk -1 not found zero instead
Chunk -1 not found zero instead
Chunk -1 not found zero instead
Writing chunk 9 tags 261 9
Inside yaffs_WriteChunkWithTagsToNAND<4>Writing chunk 10 tags 261 10
Inside yaffs_WriteChunkWithTagsToNAND<4>Writing chunk 11 tags 261 11
Inside yaffs_WriteChunkWithTagsToNAND<4>Writing chunk 12 tags 261 12
Inside yaffs_WriteChunkWithTagsToNAND<4>Writing chunk 13 tags 261 13
Inside yaffs_WriteChunkWithTagsToNAND<4>Writing chunk 14 tags 261 14
Inside yaffs_WriteChunkWithTagsToNAND<4>Chunk -1 not found zero instead
Writing chunk 15 tags 261 15
Inside yaffs_WriteChunkWithTagsToNAND<4>Writing chunk 16 tags 261 0
Inside yaffs_WriteChunkWithTagsToNAND<4>line 2865 delete of chunk 32
Writing chunk 0 tags 0 0
Inside yaffs_WriteChunkWithTagsToNAND<7>yaffs unlocking
[root@Sarva 2.6.13]#df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/mtdblock2 31488 25056 6432 80% /
/dev/mtdblock3 65536 41080 24456 63% /mnt/flash
[root@Sarva 2.6.13]#cat /proc/yaffs
YAFFS built:Aug 25 2005 09:02:20
$Id: yaffs_fs.c,v 1.29 2005/08/11 01:07:43 marty Exp $
$Id: yaffs_guts.c,v 1.18 2005/08/16 02:28:04 charles Exp $
Device 0 "Filesystem on nand"
startBlock......... 0
endBlock........... 4095
chunkGroupBits..... 2
chunkGroupSize..... 4
nErasedBlocks...... 1534
nTnodesCreated..... 100
nFreeTnodes........ 99
nObjectsCreated.... 100
nFreeObjects....... 95
nFreeChunks........ 49104
nPageWrites........ 18
nPageReads......... 1
nBlockErasures..... 0
nGCCopies.......... 0
garbageCollections. 0
passiveGCs......... 0
nRetriedWrites..... 0
nRetireBlocks...... 0
eccFixed........... 0
eccUnfixed......... 0
tagsEccFixed....... 0
tagsEccUnfixed..... 0
cacheHits.......... 0
nDeletedFiles...... 0
nUnlinkedFiles..... 0
nBackgroudDeletions 0
useNANDECC......... 1
isYaffs2........... 0
[root@Sarva 2.6.13]#cd /mnt/flash/
[root@Sarva flash]#ls -la
yaffs_readdir: starting at 0
yaffs_readdir: starting at 4
drw-rw-rw- 1 root root 512 Jan 1 00:04 .
drwxr-xr-x 6 root root 0 Jan 1 00:12 ..
drw-rw-rw- 1 root root 512 Jan 1 00:04 lost+found
-rw-r--r-- 1 root root 7372 Jan 1 00:05 nanddump.c
[root@Sarva /mnt]#umount flash/
yaffs_put_inode: ino 261, count 1
yaffs_put_inode: ino 2, count 1
yaffs_put_inode: ino 1, count 1
yaffs_put_inode: ino 1, count 1
yaffs_clear_inode: ino 1, count 0 object exists
yaffs_clear_inode: ino 261, count 0 object exists
yaffs_clear_inode: ino 2, count 0 object exists
lets mount and see again
[root@Sarva /mnt]#mount -t yaffs /dev/mtdblock3 /mnt/usb/
...........
Block scanning block 4091 state 3 seq 0
Block empty
Block scanning block 4092 state 8 seq 0
block 4092 is bad
Block scanning block 4093 state 8 seq 0
block 4093 is bad
Block scanning block 4094 state 8 seq 0
block 4094 is bad
Block scanning block 4095 state 3 seq 0
Block empty
Block scanning block 4096 state 3 seq 0
Block empty
yaffs_Scan ends
yaffs: yaffs_GutsInitialise() done.
yaffs_read_super: guts initialised OK
yaffs_read_super: got root inode
yaffs_read_super: d_alloc_root done
yaffs_read_super: done
[root@Sarva /mnt]#df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/mtdblock2 31488 25056 6432 80% /
/dev/mtdblock3 65536 41056 24480 63% /mnt/flash
[root@Sarva /mnt]#cd flash/
[root@Sarva flash]#ls
yaffs_readdir: starting at 0
yaffs_readdir: starting at 3
lost+found
[root@Sarva flash]#
My nand driver is a implementation of spia and drives a samsung k9f1208UOM
/*
* drivers/mtd/nand/spia.c
*
* Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com)
*
*
* 10-29-2001 TG change to support hardwarespecific access
* to controllines (due to change in nand.c)
* page_cache added
*
* $Id: spia.c,v 1.21 2003/07/11 15:12:29 dwmw2 Exp $
*
* 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.
*
* Overview:
* This is a device driver for the NAND flash device found on the
* SPIA board which utilizes the Toshiba TC58V64AFT part. This is
* a 64Mibit (8MiB x 8 bits) NAND flash device.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
#include <asm/io.h>
#include <asm/sizes.h>
#include <asm/arch-pxa/pxa-regs.h>
/*
* MTD structure for SPIA board
*/
static struct mtd_info *spia_mtd = NULL;
/*
* Values specific to the SPIA board (used with EP7212 processor)
*/
#define SPIA_FIO_BASE 0x06000000 /* Address where flash is mapped */
static unsigned char data_buf[512+16];
static unsigned char oob_buf[16*32];
static struct nand_oobinfo nand_oobsel = {
useecc: 1,
eccbytes: 6,
eccpos: {8, 9, 10, 13, 14, 15}
};
static int spia_fio_base = SPIA_FIO_BASE;
/*
* Define partitions for flash device
*/
const static struct mtd_partition partition_info[] = {
{ name: "Filesystem on nand",
offset: 0,
oobsel: &nand_oobsel,
size: 64 * SZ_1M},
};
#define NUM_PARTITIONS 1
/*
* hardware specific access to control-lines
*/
static void spia_hwcontrol(struct mtd_info *mtd, int cmd){
switch(cmd){
case NAND_CTL_SETCLE: GPSR2 = 0x80000; break;
case NAND_CTL_CLRCLE:GPCR2 = 0x80000; break;
case NAND_CTL_SETALE: GPSR2 = 0x100000; break;
case NAND_CTL_CLRALE: GPCR2 = 0x100000; break;
case NAND_CTL_SETNCE: GPCR2 = 0x20000; break;
case NAND_CTL_CLRNCE: GPSR2 = 0x20000; break;
}
}
/*
* Main initialization routine
*/
int __init spia_init (void)
{
struct nand_chip *this;
GPSR2 = 0x60000;
GPDR2 |= 0x1e0000;
GPCR2 = 0x20000;
/* Allocate memory for MTD device structure and private data */
spia_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip),
GFP_KERNEL);
if (!spia_mtd) {
printk ("Unable to allocate SPIA NAND MTD device structure.\n");
return -ENOMEM;
}
/* Get pointer to private data */
this = (struct nand_chip *) (&spia_mtd[1]);
/* Initialize structures */
memset((char *) spia_mtd, 0, sizeof(struct mtd_info));
memset((char *) this, 0, sizeof(struct nand_chip));
spia_fio_base=(unsigned long)ioremap(spia_fio_base,SZ_1K);
/* Link the private data with the MTD structure */
spia_mtd->priv = this;
/* Set address of NAND IO lines */
this->IO_ADDR_R = spia_fio_base;
this->IO_ADDR_W = spia_fio_base;
/* Set address of hardware control function */
this->hwcontrol = spia_hwcontrol;
/* 15 us command delay time */
this->chip_delay = 20;
this->eccmode = NAND_ECC_SOFT;
//this->eccmode= MTD_NANDECC_PLACE;
// this->eccmode= NAND_ECC_NONE;
/* Scan to find existence of the device */
if (nand_scan (spia_mtd, 1)) {
kfree (spia_mtd);
return -ENXIO;
}
/* Allocate memory for internal data buffer */
// this->data_buf = kmalloc (sizeof(u_char) * (spia_mtd->oobblock
+ spia_mtd->oobsize), GFP_KERNEL);
this->data_buf = data_buf;
this->oob_buf = oob_buf;
if (!this->data_buf) {
printk ("Unable to allocate NAND data buffer for SPIA.\n");
kfree (spia_mtd);
return -ENOMEM;
}
if (!this->oob_buf) {
printk ("Unable to allocate NAND data buffer for SPIA.\n");
kfree (spia_mtd);
return -ENOMEM;
}
/* Register the partitions */
add_mtd_partitions(spia_mtd, partition_info, NUM_PARTITIONS);
printk("Sarva_mtd->erasesize = %d\n", spia_mtd->erasesize);
printk("Sarva_mtd->oobblock = %d\n", spia_mtd->oobblock);
printk("Sarva_mtd->oobsize = %d\n", spia_mtd->oobsize);
printk("Sarva_mtd->eccsize = %d\n", spia_mtd->eccsize);
printk("Sarva_chip->page_shift = %d\n", this->page_shift);
/* Return happy */
return 0;
}
module_init(spia_init);
/*
* Clean up routine
*/
#ifdef MODULE
static void __exit spia_cleanup (void)
{
struct nand_chip *this = (struct nand_chip *) &spia_mtd[1];
/* Unregister the device */
del_mtd_device (spia_mtd);
/* Free internal data buffer */
kfree (this->data_buf);
/* Free the MTD device structure */
kfree (spia_mtd);
}
module_exit(spia_cleanup);
#endif
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Steven J. Hill <
sjhill@realitydiluted.com");
MODULE_DESCRIPTION("Board-specific glue layer for NAND flash on SPIA board");
---------
Is there anything am overlooking ? Any clues or pointers ?
Warm regards,
manav