[Yaffs-archive] Re: Block size of Sandisk 256MB SD Card

Charles Manning manningc2@actrix.gen.nz
Tue, 25 Feb 2003 14:13:59 +1300


On Tue, 25 Feb 2003 11:49, Steven Reddie wrote:
> Thanks for the reply.
>
> I'm an iPAQ Windows CE user (and developer).  Yaffs seems to support
> Windows CE so I'm wondering why I might need to use it.  I got hold on a
> Sandisk spec for a flash part which may or may not be used in their card. 
> It has a 16KB block size.  I take this to mean that when writing a 512-byte
> sector over the top of an old one that the entire 16KB block needs to be
> erased. It would therefore seem that one could write and then delete a 4MB
> file on a FAT16 filesystem only 36.6 times before the card is dead due to
> wearing out the allocation table block.  I hope my understanding about this
> is wrong, and was hoping that someone on this list may know the truth.  I
> arrived at 36.6 time by using a 512-byte cluster size, a 16KB erase block
> size, and FAT16 filesystem.  Since an allocation sector contains 16-bit
> entries that chain together clusters it would seem that a full 16KB block
> would contain 8192 entries which would account for 4MB of storage
> (8192*(512 byte clusters)).  So, writing and then deleting a 4MB file 36.6
> times would cause 300,000 erasures of the allocation block.
>
> Regards,
>
> Steven
>
The main reason people use YAFFS with WinCE is to build large "disks"  in 
handheld/embedded devices. Sure, you could use a FAT-based system but that is 
way slower and not very robust.  Mainly people use soldered-down NAND chips 
with YAFFS, but some use SmartMedia.

However, YAFFS is not the way to go for removeable media that you want to 
share with your camera, PC etc, since these will 99.99% chance only 
understand FAT. 

I will answer your SD/FAT query even though it is off thread and has no 
bearing on YAFFS. SmartMedia (and I assume SD) run a block driver which does 
a mapping between physical and logical blocks. When you overwrite a logical 
block, the data is written to a new physical block and the old physical block 
gets scrubbed. Thus logical blocks which get a lot of activity, like FAT 
blocks,  don't get written to the same place. THerefore the writing gets 
spread out on the flash. This is called wear levelling (though some file 
systems go further and do explicite wear levelling). Now, should a block wear 
out, it gets retired and is never used again. SmartMedia reserves approx 2% 
of the disk for retirement losses.

-- Charles

---------------------------------------------------------------------------------------
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 yaffs-request@toby-churchill.org with the text "unsubscribe" 
(without the quotes) as the subject.