tech-embed archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: TS-72xxx flash and NetBSD
On Fri, Feb 04, 2005 at 04:41:00PM -0700, Jesse Off wrote:
> I'm Cc'ing this to the tech-kern%netbsd.org@localhost mailing list in order
> to
> hopefully solicit a few other expert opinions on the subject.
>
> I haven't implemented anything for the onboard TS72xx flash support because
> the best course of action isn't yet perfectly clear (to me anyway). I know
> what I'd like to see avoided in an implementation, but don't yet have a
> good plan of action to offer that would avoid all the chaos thats currently
> in Linux in the form of "MTD" drivers and special filesystems unique to
> each type of flash chip (JFFS2, YAFFS, YAFFS2, FTL/EXT2, NFTL/EXT2, etc).
> There are certain things unique about using direct mapped NAND/NOR flash
> (as opposed to something like CF, or USB flash which has an onboard
> controller), but a completely new filesystem (and one also for each type
> and variant of chip) seems a bit overkill. Some ideas:
Faced with a similar problem for an embedded device, I did wrote a block
driver with a cache that had the following (rather unusual) properties:
1) Reads return data from the cache, but reads are not saved in the cache
(ie they ususally read from the media)
2) Write follow the following algorith:
2a) If the write sector is cached, update the cache
2b) If the write can be done without erasing the existing sector,
then just update then flash memory (eg if data unchanged, or only
changes convert '1' bits to '0').
2c) If the 'sector' cache isn't full, save the write in the cache.
2d) Erase the flash associated with the cached flash block (maybe 128k)
and write back that cache entry.
2e) Select the flash block that has the most cached (modified) sectors
and read into the cache, freeing up entries in the sector cache.
Save the write in the sector cache (or flash block).
3) On timeout flush out the cache.
This doesn't give the same level of consistency as you get with a disk,
buit significanly reduced the number of flash erases (compared to the
uncached version) especially while copying the OS files to the flash.
IIRC I used a single 128kb block buffer, and 8 512 byte sector buffers
(was a FAT filesystem with 512 byte blocks).
It would help any flash layer (and probably CF cards as well) if the
filesystem requested that sectors were deleted when no longer in use.
It would also help greatly if FS metadata were arranged so that 'unused'
entries were all 0xff, and deleted ones 0x00.
David
--
David Laight: david%l8s.co.uk@localhost
Home |
Main Index |
Thread Index |
Old Index