Writing JFFS2 image to Nand flash

John Hall John.Hall at optionexist.co.uk
Fri Apr 12 09:09:33 EDT 2002

Elizabeth Clarke <eclarke at aminocom.com> wrote:
> > I'm having problems writing a JFFS2 image to a Nand flash device
> > whose first block is bad. cp and dd fail in this case. Do I need to
> > write a utility that checks for bad blocks and skips them, or am I
> > missing something?
> What messages is it giving? debug enabled? are you using the JFFS2
> code from the jffs2_nand_branch code from cvs?

>From my understanding, mkfs.jffs2 creates a JFFS2 image without any
reference to the device that is being targeted (with the possible
exception of specifying an erase size if the erase size is bigger than
64K). This image should then be written to the device with cp or dd.
However, if I have bad blocks on the device then dd fails.

This is an example of the erase finding that the first block is bad:

	root at board:/tmp# eraseall /dev/mtd/0
	Erasing nand_erase: attempt to erase a bad block at page
	8 Kibyte @ 0 --  0 % complete.
	eraseall: /dev/mtd/0: MTD Erase failure: Input/output error
	Erased 8192 Kibyte @ 0 -- 100% complete.

Then create a jffs2 image:

	root at board:/tmp# mkfs.jffs2 -d /tmp/files -o /tmp/img

Then write it:

	root at board:/tmp# dd if=/tmp/img of=/dev/mtd/0
	dd: writing `/dev/mtd/0': Input/output error
	0+1 records in
	0+0 records out

I'm not using the jffs2_nand_branch - I had not realised there was one.
I have the latest CVS code from the trunk. What changes are there to
support nand flash - is it just limiting the number of writes to a page,
or are there other things?
I will switch to the nand branch and try that.

John Hall

More information about the linux-mtd mailing list