Creating an Empty JFFS2 File System

Grant Erickson gerickson at nuovations.com
Sat Aug 23 11:34:38 EDT 2008


On 3/7/08 12:39 PM, Grant Erickson wrote:
> On 3/7/08 10:37 AM, Josh Boyer wrote:
>> On Fri, 07 Mar 2008 09:55:13 -0800
>> Grant Erickson <gerickson at nuovations.com> wrote:
>>> Is creating an empty JFFS2 file system supported or is this a deprecated
>>> capability? The following steps seem to be incorrect or failing:
>>> 
>>>     # flash_eraseall -q -j /dev/mtd9
>>>     # mount -t jffs2 /dev/mtdblock9 /mnt
>>>     Cowardly refusing to erase blocks on filesystem with no valid JFFS2
>>>     nodes
>>>     empty_blocks 0, bad_blocks 0, c->nr_blocks 3840
>>> 
>>> Or, is the only way to accomplish this to create a NULL JFFS2 image with
>>> mkfs.jffs2 and then nandwrite it?
>> 
>> Just erase it completely without the -j option and mount.  JFFS2 will go
>> through and erase them all again and add the cleanmarkers itself.
> 
> Josh:
> 
> That technique is a no-go as well:
> 
>     # flash_eraseall -q /dev/mtd8
>     # mount -t jffs2 /dev/mtdblock8 /mnt
>     Cowardly refusing to erase blocks on filesystem with no valid JFFS2
>     nodes
>     empty_blocks 0, bad_blocks 0, c->nr_blocks 3840
>     mount: mounting /dev/mtdblock8 on /mnt failed: Input/output error

For those following this thread via Google, I finally had time to debug this
upon arrival of our prototype boards and thought I would close the thread
out with the root cause.

On the prototype board, which uses a Numonyx NAND01GW3B2B (128 KiB block / 2
KiB page), I found that I COULD successfully erase a NAND partition with
'nand erase' in u-boot or 'flash_eraseall' in Linux and then mount it:

    # flash_eraseall -q /dev/mtd9
    # mount -t jffs2 /dev/mtdblock9 /mnt/root0
    # df
    Filesystem           1k-blocks      Used Available Use% Mounted on
    ...
    /dev/mtdblock9            8192       512      7680   6% /mnt/root0

However, as before, I tried this on Haleakala/Kilauea with its Samsung
K9F1208U0B (16 KiB block / 512 B page) part using the same 2.6.25-rc3 DENX
kernel, I saw the following:

    # flash_eraseall -q /dev/mtd9
    # mount -t jffs2 /dev/mtdblock9 /mnt/root0
    Cowardly refusing to erase blocks on filesystem with no valid JFFS2
nodes
    empty_blocks 0, bad_blocks 0, c->nr_blocks 512
    mount: mounting /dev/mtdblock9 on /mnt/root0 failed: Input/output error

My suspicion was that this was somehow related to the custom OOB/ECC layout
specified in arch/powerpc/platforms/40x/kilauea-nand.c because an erase from
either u-boot with 'nand erase' or Linux with 'flash_eraseall' produced
identical results.

The larger page part on the prototype board uses a default OOB/ECC layout
(similar to Canyonlands, et al) and worked correctly in either case.

So, I made the following change in arch/powerpc/platforms/40x/kilauea-nand.c
in the DENX-2.6.26.2 kernel:

    -    .ecclayout = &nand_oob_16,
    +    .ecclayout = NULL,

and an empty/erased partition mount worked, both with an erase from u-boot
using 'nand erase' and from Linux using 'flash erase_all'.

Stefan Roese at DENX confirmed this was likely an arch/ppc to arch/powerpc
porting error/typo.

Regards,

Grant Erickson





More information about the linux-mtd mailing list