MTD device with multiple regions & JFFS2

Josh Boyer jwboyer at gmail.com
Fri Jun 30 10:36:40 EDT 2006


On 6/30/06, Angelos Manousarides <amanous at inaccessnetworks.com> wrote::
>
> The code in mtdpart.c does not propagate erase region information to the
> slave device. I have ckeched with the git repository online and it is
> still the same. Here is the code I am talking about, it is the only reference
> in regions in mtdpard.c:
>
>     if (master->numeraseregions>1) {
>       /* Deal with variable erase size stuff */
>       int i;
>       struct mtd_erase_region_info *regions = master->eraseregions;
>
>       /* Find the first erase regions which is part of this partition. */
>       for (i=0; i < master->numeraseregions && slave->offset >= regions[i].offset; i++)
>         ;
>
>       for (i--; i < master->numeraseregions && slave->offset + slave->mtd.size > regions[i].offset; i++) {
>         if (slave->mtd.erasesize < regions[i].erasesize) {
>           slave->mtd.erasesize = regions[i].erasesize;
>         }
>       }
>     } else {
>       /* Single erase size */
>       slave->mtd.erasesize = master->erasesize;
>     }
>
> I have changed this to allocate slave->mtd.eraseregions and set
> slave->mtd.numeraseregions properly.
>
> If this is not needed, then definately I am missing something here.

It should really only make a difference if a partition actually spans
two different erase regions.  And even then I'm not sure it really
matters much.  But I suppose there is nothing bad about doing it
correctly.

> Now that I think of it, my first comment about the JFFS2 might be wrong.
> The jffs2 layer calls mtd->erase(). Because normally all "small" sectors
> are enclosed in "large" sector binaries, the erase() function will
> probably handle the erase properly. The JFFS layer might be thinking it
> is erasing a single block, but the mtd->erase will actually erase a few
> small blocks. This is probably the reason that the erasesize in a
> multi-region flash is set to the maximum block size. But this is just a
> guess.

Good guess.  That is what should be happening, so JFFS2 should be
fine.  Unless I am the one that's missing something :).

josh




More information about the linux-mtd mailing list