NAND flash write goes wrong

Ricard Wanderlof ricard.wanderlof at axis.com
Fri May 11 02:36:28 EDT 2007


On Thu, 10 May 2007, borasah at gmail.com wrote:

> Hi,
>
> I have a MIPS based board and want to use its NAND flash for storage. NAND
> chip is a Samsung part: K9F1208UDA. It has 16KB erase block size and 512 byte
> page size.
> 	cat /proc/mtd
> 	dev:    size   erasesize  name
> 	mtd0: 02000000 00020000 "mtdram test device"
> 	mtd1: 00800000 00004000 "NAND FS 0"
> 	mtd2: 03800000 00004000 "NAND FS 1"
>
> As you see there are two partitions on it. I want to use "NAND FS 1"(56MB) for
> rootFS storage. I obtained mtd-utils from the site and compiled them for both
> the host and the target. I am using "mkfs.jffs2 command on the host" to
> generate a jffs2 image.
> 	./mkfs.jffs2 -p 0x3800000 -s 0x200 -e 0x4000 -r rootfs -o img -l

I don't know if this is it but

- I wouldn't pad the output image using -p <padsize>. Since there may be
   bad blocks in the flash, the image might not fit if padded to the
   whole partition size. Just skip the -p and its argument. As long as
   the whole partition into which the image is written has been erased
   beforehand, jffs2 will be able to make use of the unused space.

- The -s <pagesize>  argument doesn't specify the page size of the
   flash chip, rather it should be the same as the 'page size' in the
   Linux system, normally 4096 for most architectures.

- In nand flash, the cleanmarkers are normally not part of the image
   as they reside in the 'spare area' in the flash. The JFFS2 driver will
   automatically create cleanmarkers when it scans the chip at first boot,
   and having them in the image will confuse the issue, even if it normally
   works anway (but with lots of warnings at boot time).
   So, add -n to the list of arguments to inhibit cleanmarker
   generation by mkfs.jffs2.

> ...
> 	Erasing 16 Kibyte @ 24000 --  0 % complete. Cleanmarker written at 24000.
> 	Skipping bad block at 0x00028000
> 	...
> Is this normal? Then I do
> 	./nandwrite /dev/mtd2 img
> It writes by skipping bad blocks.
> 	...
> 	Writing data to block 189c000
> 	Bad block at 189c000, 1 block(s) from 189c000 will be skipped
> 	Writing data to block 18a0000
> 	...

If there indeed are bad blocks it is correct to skip them both when 
erasing and writing.

/Ricard
--
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30




More information about the linux-mtd mailing list