All of lore.kernel.org
 help / color / mirror / Atom feed
From: borasah@gmail.com
To: linux-mtd@lists.infradead.org
Subject: NAND flash write goes wrong
Date: Thu, 10 May 2007 21:50:30 +0300	[thread overview]
Message-ID: <200705102150.31171.borasah@gmail.com> (raw)

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
Then on the target I do
	flash_eraseall -j /dev/mtd
In the beginning there was no bad block. But after some experiments I see 
many(43) "bad sector" warnings and this continues to increase when I write 
new images.
	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
	...
Everything seems normal. As a last item, I want to see if the image creation 
and write is successfull, do 
	mount -t jffs2 /dev/mtdblock2 /mnt
Results:
jffs2: Erase block size too small (16KiB). Using virtual blocks size (32KiB) 
instead
CLEANMARKER node found at 0x00000000 has totlen 0xc != normal 0x0
Empty flash at 0x00003f5c ends at 0x00004000
CLEANMARKER node found at 0x00004000 has totlen 0xc != normal 0x0
CLEANMARKER node found at 0x00008000 has totlen 0xc != normal 0x0
mtd->read(0x7a8c bytes from 0x8574) returned ECC error
Empty flash at 0x0000bffc ends at 0x0000c000
CLEANMARKER node found at 0x0000c000 has totlen 0xc != normal 0x0
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000e30c: 0x2a1f 
instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000e310: 0x4013 
instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000e314: 0xeb6a 
instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000e318: 0xd754 
instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000e31c: 0xaca8 
instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000e320: 0x0030 
instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000e324: 0x1e8e 
instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000e328: 0xe002 
instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000e330: 0x3481 
instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000e340: 0x03e8 
instead
Further such events for this erase block will not be printed
...

I read the FAQ at http://www.linux-mtd.infradead.org/faq/jffs2.html. "Magic 
bitmask 0x1985 not found" points four things as cause. At my case, seems
	1) you flash driver is severely buggy so it reads trash instead of valid
 data;
	2) you did not manage to flash JFFS2 image correctly so that you ended up 
with garbage on your flash, although the original image was perfectly fine;

Now I am assuming 1 is correct which is vendor provided. But I dont see where 
I did wrong when generating the image? Can someone shed some light on this?
	# mtd_debug info /dev/mtd2
	mtd.type = MTD_NANDFLASH
	mtd.flags = MTD_CLEAR_BITS | MTD_ECC
	mtd.size = 58720256 (56M)
	mtd.erasesize = 16384 (16K)
	mtd.oobblock = 512
	mtd.oobsize = 16
	mtd.ecctype = MTD_ECC_NONE
	regions = 0

Thanks...

--
Bora SAHIN

             reply	other threads:[~2007-05-10 18:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-10 18:50 borasah [this message]
2007-05-10 19:16 ` NAND flash write goes wrong Josh Boyer
2007-05-10 21:37   ` borasah
2007-05-10 22:15     ` Thomas Gleixner
2007-05-10 22:42       ` borasah
2007-05-11  6:36 ` Ricard Wanderlof
2007-05-11  6:57   ` Artem Bityutskiy
2007-05-11  7:16     ` Matthieu CASTET
2007-05-11  7:42       ` Artem Bityutskiy
2007-05-11  7:49         ` Artem Bityutskiy
2007-05-11 13:56   ` borasah
2007-05-11 14:31     ` Ricard Wanderlof
2007-05-11 17:58       ` borasah
2007-05-14  6:56         ` Ricard Wanderlof
2007-05-21  9:30           ` borasah
     [not found] <42E999AD7A0E4647BF159F467EE4FBCB017B5155@BLR-SGM-MSG01.wipro.com>
2007-05-14  7:39 ` Ricard Wanderlof

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200705102150.31171.borasah@gmail.com \
    --to=borasah@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.