Re: [patch] Allow any filesystem on MTD Nand when Read Only

David Daney
2004-05-05T15:26:55Z

Pantelis Antoniou wrote:

> Hello there.
>
> The following patch allows you to have any filesystem over NAND when
> mounted
> read only.
>
> The main drive for this was that I wanted to use CRAMFS over NAND
> flash since
> it has a much higher compression ratio than JFFS2.
>
> How it works is pretty simple.
>
> It's pretty reasonable assumption that bad blocks are created only when
> writting to NAND. So in the read-only case it is possible to skip over
> the bad
> blocks and offer a bad-block free block device to the upper layers.
> This allows us to utilize any filesystem when read-only.
>
> In order to speed the mount operation the bad block detection is
> performed lazilly.
>
> Using the patch I was able to mount as read-only CRAMFS/JFFS2 partitions
> which contained simulated bad-blocks.
>
> Awaiting your comments...
>
> Regards
>
> Pantelis
>
After more thought, I am in the process of doing something similar.

However my changes are not quite done yet. Roughly it goes like this:

Write a new read-only block driver that skips bad blocks and uses ECC
reads. This allows any read only file system to use it (ie cramfs).
The bad block map is kept in the first non-bad page in the partition,
when the driver is installed it reads the bad block map.

To write the data into the mtd, you have a special version of nandwrite
that checks for bad blocks while writing the image and finally writes
the bad block map.

One difference between my approach and yours is that no existing mtd
driver code is touched, it is simply another mtd block driver.

David Daney.