Hi,

I have erased NAND flash using the low level functions.

I mounted YAFFS2 file-system on NAND flash block driver.

At the time of mounting it shows the following data

mtdblock_open
ok
yaffs: dev is 32505856 name is "mtdblock0"
yaffs: passed flags ""
yaffs_read_super: Using yaffs2
yaffs_read_super: block size 4096
yaffs: Attempting MTD mount on 31.0, "mtdblock0"
 erase 80413d50
 read 80414118
 write 80413b54
 readoob 8041402c
 writeoob 80413c3c
 block_isbad 80413f4c
 block_markbad 80413f98
 writesize 2048
 oobsize 64
 erasesize 131072
 size 2097152
yaffs: yaffs_GutsInitialise()
restore entry: isCheckpointed 0
read checkpoint validity
find next checkpt block: start:  blocks 0 next 1
nandmtd2_ReadChunkWithTagsFromNAND chunk 0 data 00000000 tags 9d603a20
nand_read_oob: from = 0x00000000, len = 28


Page Address=0
ulSpareAddress=800
packed tags obj -1 chunk -1 byte -1 seq -1
ext.tags eccres 0 blkbad 0 chused 0 obj 0 chunk0 byte 0 del 0 ser 0 seq 0
packed tags obj -1 chunk -1 byte -1 seq -1
ext.tags eccres 1 blkbad 0 chused 0 obj 0 chunk0 byte 0 del 0 ser 0 seq 0
find next checkpt block: search: block 1 oid 0 seq 0 eccr 1
nandmtd2_ReadChunkWithTagsFromNAND chunk 64 data 00000000 tags 9d603a20
nand_read_oob: from = 0x00020000, len = 28


After that I did mkdir and observe the following result.

yaffs_lookup for 1:a
yaffs_lookup not found
yaffs_mkdir
yaffs_mknod: parent object 1 type 3
yaffs_mknod: making oject for a, mode 41ed dev 0
yaffs_mknod: making directory

Allocated block 1, seq  4097, 15 left
nandmtd2_ReadChunkWithTagsFromNAND chunk 0 data 80960000 tags 9d585b28
packed tags obj 0 chunk 0 byte 0 seq 0
ext.tags eccres 0 blkbad 0 chused 1 obj 0 chunk0 byte 0 del 0 ser 0 seq 0
packed tags obj 0 chunk 0 byte 0 seq 0
ext.tags eccres 1 blkbad 0 chused 1 obj 0 chunk0 byte 0 del 0 ser 0 seq 0
Chunk 64 not erased
**>> yaffs chunk 64 was not erased
line 1012 delete of chunk 64

Allocated block 2, seq  4098, 14 left
nandmtd2_ReadChunkWithTagsFromNAND chunk 64 data 80960000 tags 9d585b28
packed tags obj 0 chunk 0 byte 0 seq 0
ext.tags eccres 0 blkbad 0 chused 1 obj 0 chunk0 byte 0 del 0 ser 0 seq 0
packed tags obj 0 chunk 0 byte 0 seq 0
ext.tags eccres 1 blkbad 0 chused 1 obj 0 chunk0 byte 0 del 0 ser 0 seq 0
Chunk 128 not erased
**>> yaffs chunk 128 was not erased
line 1012 delete of chunk 128

Allocated block 3, seq  4099, 13 left
nandmtd2_ReadChunkWithTagsFromNAND chunk 128 data 80960000 tags 9d585b28
packed tags obj 0 chunk 0 byte 0 seq 0
ext.tags eccres 0 blkbad 0 chused 1 obj 0 chunk0 byte 0 del 0 ser 0 seq 0
packed tags obj 0 chunk 0 byte 0 seq 0
ext.tags eccres 1 blkbad 0 chused 1 obj 0 chunk0 byte 0 del 0 ser 0 seq 0
Chunk 192 not erased
**>> yaffs chunk 192 was not erased
line 1012 delete of chunk 192
.
.
.
.upto 16th block
.
.
Allocated block 16, seq  4112, 0 left
Allocating reserve
nandmtd2_ReadChunkWithTagsFromNAND chunk 960 data 80960000 tags 9d585b28
packed tags obj 0 chunk 0 byte 0 seq 0
ext.tags eccres 0 blkbad 0 chused 1 obj 0 chunk0 byte 0 del 0 ser 0 seq 0
packed tags obj 0 chunk 0 byte 0 seq 0
ext.tags eccres 1 blkbad 0 chused 1 obj 0 chunk0 byte 0 del 0 ser 0 seq 0
Chunk 1024 not erased
**>> yaffs chunk 1024 was not erased
line 1012 delete of chunk 1024

yaffs tragedy: no more erased blocks
Allocating reserve
!!!!!!!!! Allocator out !!!!!!!!!!!!!!!!!
**>> yaffs write required 16 attempts
GC Selected block 1 with 64 free, prioritised:1
yaffs: GC erasedBlocks 0 aggressive 1
Collecting block 1, in use 0, shrink 0, wholeBlock 1
Collecting block 1 that has no chunks in use
yaffs_BlockBecameDirty block 1 state 8



I am just thinking whether mkyaffs2image needs to be executed before writing any data to flash after erasing it. Is my understanding correct or wrong?

Thanks,
Saquib