[U-Boot-Users] Reading or writing jffs2 - how?

Detlev Zundel dzu at denx.de
Wed Dec 15 21:47:38 CET 2004


Hi Martin,

> I have tried to create a jffs2-image of the linux-filesystem I wish to
> use, and then write it to my flash using "nand write.jffs2 100000 0
> $(filesize)". But with no luck...
> Then I began to investigate the fundamental "ls" and "nand erase"
> commands, but neither there did I have any success. Below is a trace
> of what I've tried in order to get something working.
>
> In section 2, I'd expect the nand to be mountable from Linux - but's
> it's not.
> In section 3, I'd expect the filesystem to be ls'ed correct from
> u-boot - but it's not...
>
> Can someone tell me if there is something I've misunderstood?
>
> ********************************
> ********** 1 U-Boot ************
> ********************************
> U-Boot 1.1.2 (Nov 27 2004 - 11:50:10)
> CPU:   IBM PowerPC 405EP Rev. B at 333.333 MHz (PLB=111, OPB=55, EBC=37 MHz)
>
> ==== 8< 8< 8< ====
>
> NAND:Probing at 0xff400000
>    64 MB
>
> ==== 8< 8< 8< ====
>
> => nand erase clean
>
> NAND erase: device 0 offset 0, size 67108864 ... OK
>
> => ls
> Scanning JFFS2 FS:  done.
> =>
>
> *******************************
> ********** 2 Linux ************
> *******************************

Which Linux kernel with which mtd code version?

> # cat /proc/mtd
>
> dev:    size   erasesize  name
> mtd0: 04000000 00004000 "Trampoline Nand Flash (128 MB)"
>
> # mount -t jffs2 /dev/mtdblock0 mnt/nand0
>
> jffs2: Erase block size too small (16KiB). Using virtual blocks size
> (32KiB) instead
> Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes
> empty_blocks 1325, bad_blocks 4, c->nr_blocks 2048
> mount: Mounting /dev/mtdblock0 on /mnt/nand0 failed: Invalid argument
>
> # eraseall /dev/mtd0

Use -j (--jffs2) in the future.

> Erasingnand_erase: attempt to erase a bad block at p 16 Kibyte @
> 400age 0x00000020
> 0 --  0 % complenand_erase: attempt to erase te.
> eraseall: /a bad block at page 0x00000040
> dev/mtd0: MTD Ernand_erase: attempt to erasase failure: Inpe a bad
> block at page 0x00000060
> nand_erase: attempt to erase a bad blo
> Erasing 16 Kibck at page 0x00000080
> yte @ 8000 --  0nand_erase: attempt to er % complete.
> erase a bad block at page 0x000000a0
> aseall: /dev/mtd0: MTD Erase fainalure: Input/outpnd_erase: attempt to
> erase a b
> ad block at page 0x000000c0
> ut error
> Erasinand_erng 16 Kibyte @ case: attempt to erase a bad block at page
> 0x000000e0
> 000 --  0 % complete.
> eraseall: /dev/mtd0: MTD Erase failure: Input/output error
> Erasing 16 Kibyte @ 10000 --  0 % complete.
> eraseall: /dev/mtd0: MTD Erase failure: Input/output error
> Erasing 16 Kibyte @ 14000 --  0 % complete.
> eraseall: /dev/mtd0: MTD Erase failure: Input/output error
> Erasing 16 Kibyte @ 18000 --  0 % complete.
> eraseall: /dev/mtd0: MTD Erase failure: Input/output error
> Erasing 16 Kibyte @ 1c000 --  0 % complete.
> eraseall: /dev/mtd0: MTD Erase failure: Input/output error
> Erased 65536 Kibyte @ 0 -- 100% complete.

Might be caused be eraseall without -j ignoring bad blocks but I'm not
sure.

> # mount -t jffs2 /dev/mtdblock0 /mnt/nand0/
>
> jffs2: Erase block size too small (16KiB). Using virtual blocks size
> (32KiB) instead
>
> # touch /mnt/nand0/testfile
> # mkdir /mnt/nand0/testdir
> # umount /mnt/nand0
>
> jffs2: No clean, dirty _or_ erasable blocks to GC from! Where are they all?
> jffs2: Couldn't find erase block to garbage collect!

Thats just a warning and can be ignored - iirc it means the unmount
triggered a garbage collection which found nothing to collect.

> # mount -t jffs2 /dev/mtdblock0 /mnt/nand0/
>
> jffs2: Erase block size too small (16KiB). Using virtual blocks size
> (32KiB) instead
>
> # ls -l /mnt/nand0/
> drwxr-xr-x    2 0        0               0 Feb  8 05:59 testdir
> -rw-r--r--    1 0        0               0 Feb  8 05:59 testfile
>
> ********************************
> ********** 3 U-Boot ************
> ********************************
>
> => ls
> Scanning JFFS2 FS:  done.
> =>

This should definitely work (it worked for me on 8xx and 4xx in the
past).

Check the mtd code in your Linux version - many improvements related
to NAND went in there not long ago.

Cheers
  Detlev

-- 
In God we trust.  All others we monitor
                       -- NSA motto




More information about the U-Boot mailing list