From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.nokia.com ([192.100.105.134] helo=mgw-mx09.nokia.com) by bombadil.infradead.org with esmtps (Exim 4.69 #1 (Red Hat Linux)) id 1MO4SC-0003ZS-QU for linux-mtd@lists.infradead.org; Tue, 07 Jul 2009 06:47:07 +0000 Subject: RE: UBIFS Corrupt during power failure From: Artem Bityutskiy To: Urs Muff In-Reply-To: <1246862635.20721.291.camel@localhost.localdomain> References: <1239979018.3390.298.camel@localhost.localdomain> <200905150916.54091.sr@denx.de> <1242721105.3623.0.camel@localhost.localdomain> <1246627562.20721.190.camel@localhost.localdomain> <1246627771.20721.191.camel@localhost.localdomain> <7207AAC68CE347458026863515A07DA102901F3C@usw-am-xch-02.am.trimblecorp.net> <1246629940.20721.219.camel@localhost.localdomain> <7207AAC68CE347458026863515A07DA102901F9C@usw-am-xch-02.am.trimblecorp.net> <1246633131.20721.224.camel@localhost.localdomain> <1246854654.20721.271.camel@localhost.localdomain> <1246855913.20721.287.camel@localhost.localdomain> <1246862635.20721.291.camel@localhost.localdomain> Content-Type: text/plain; charset="UTF-8" Date: Tue, 07 Jul 2009 09:46:24 +0300 Message-Id: <1246949184.20721.302.camel@localhost.localdomain> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Cc: linux-mtd@lists.infradead.org, Stefan Roese , Nicolas Pitre , Eric Holmberg , Adrian Hunter Reply-To: dedekind@infradead.org List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Mon, 2009-07-06 at 09:43 +0300, Artem Bityutskiy wrote: > On Mon, 2009-07-06 at 07:51 +0300, Artem Bityutskiy wrote: > > > [CCed Nicolas Pitre] > > > > > > OK, I've written a small user-space program which first fills the NOR > > > flash with an '0x89ABCDEF' pattern, then starts erasing it, and then > > > I cut the power at random point. > > > > > > And unfortunately the power cut results in eraseblocks which have > > > 0x89ABCDEF at the beginning, and all zeroes at the end. I've attached > > > one example. > > > > > > So it indeed looks like NOR erasure includes writing zeroes from the > > > end. Unfortunately UBI/UBIFS cannot handle this correctly ATM. > > > > Although I can easily fix this by writing few zeroes at the beginning of > > the eraseblock _before) erasing it, so that UBI will be happy. But it is > > still interesting whether I may just ask NOR to amend it's embedded > > erase algorithm. > > This patch seems to fix the UBI issues Eric and me observed (issue N2). > I'll test the patch for few days, but I couldn't see any problem so far. > > From: Artem Bityutskiy > Subject: [PATCH] UBI: fix NOR flash recovery > > This commit fixes NOR flash recovery issues observed with Spansion > S29GL512N NOR. > > When NOR erases, it first fills PEBs with zeroes, then sets all bytes > to 0xFF. Filling with zeroes starts from the end of the PEB. And when > power is cut, this results in PEBs containing correct EC and VID headers > but corrupted with zeros at the end. This confuses UBI and it mistakinly > accepts these PEBs and associate them with LEBs. > > Fis this issue by zeroing EC and VID magics before erasing PEBs, to > make UBI later refuse zem. > > Signed-off-by: Artem Bityutskiy Yes, it fixes the issue. The device has already survived ~1500 power cuts and no problems. It used to die after about 50 power cuts. I'm pushing this to ubi-2.6.git. So if Eric is still interested, he can try it when he is back from the holidays. -- Best regards, Artem Bityutskiy (Битюцкий Артём)