UBIFS Corrupt during power failure

Urs Muff urs_muff at trimble.com
Tue Jul 7 03:05:24 EDT 2009

He will be very glad to hear this!

- Urs

-----Original Message-----
From: Artem Bityutskiy [mailto:dedekind at infradead.org]
Sent: Tue 7/7/2009 12:46 AM
To: Urs Muff
Cc: Nicolas Pitre; Stefan Roese; linux-mtd at lists.infradead.org; Eric Holmberg; Adrian Hunter
Subject: RE: UBIFS Corrupt during power failure
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 <Artem.Bityutskiy at nokia.com>
> 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 <Artem.Bityutskiy at nokia.com>

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

Best regards,
Artem Bityutskiy (???????? ?????)

More information about the linux-mtd mailing list