Re: Pass -EUCLEN to userspace?

Boris Brezillon
2016-04-25T07:51:00Z

On Mon, 25 Apr 2016 07:28:57 +0200
Sascha Hauer <s.hauer@pengutronix.de> wrote:

> On Fri, Apr 22, 2016 at 05:48:35PM +0200, Richard Weinberger wrote:
> > Sascha, Boris,
> >
> > Am 22.04.2016 um 17:28 schrieb Boris Brezillon:
> > >>> I am currently working on a program similar to ubihealthd, just for raw
> > >>> mtd pages, not UBI. Basically I want to find out in userspace if my Nand needs
> > >>> scrubbing. Is it possible somehow to get this information in userspace?
> > >>
> > >> Actually we discussed that a year ago with Richard. I told him that we
> > >> should put the read/write/erase statistics at the MTD level so that
> > >> other MTD users (including userspace programs) could use the same infra
> > >> for non-UBI partitions (I need that for the UBOOT and SPL partitions).
> > >>
> > >> My suggestion was to store those information at the MTD level, and let
> > >> UBI implement its own scrubbing layer on top of that, but Richard
> > >> decided to go for a simpler approach for its first implementation.
> >
> > Yeah, I did a first implementation on UBI layer as it had everything we need
> > and I didn't want to replicate UBI at MTD level.
> > Another reason is that we were not sure how sophisticated ubihealthd needs to be.
> >
> > Sasha, what exactly is your use case and why is the UBI approach not sufficient for you?
> > On Linux MTD access should only happen through UBI and UBOOT/SPL partitions stay untouched.
>
> On i.MX6 the Bootloader in Nand can indeed be redundant, so it's
> possible to scrub the pages. This is exactly our usecase, we want to be
> able to detect bitflips in the bootloader area.
> Note that on i.MX6 the first page in the first n blocks on Nand contains
> a structure called FCB (flash control block). This is not encoded with
> the standard ECC algorithm used on the other areas in Nand. Reading
> these pages will always return -EBABDMSG, they have to be read in raw
> mode. That just to say that a "maximum bitflips per block" might not be
> sufficient.

Okay, pretty much the same use-case we have on sunxi platforms: the SPL
partition is written in raw mode because the page layout (in-band/ECC
data disposition) is not the one we're using for the rest of the NAND.
For this specific partition, I see 2 solutions that you can implement
in userspace to count the number of bitflips:

1/ read the partition page by page in raw mode and compare each
page to a reference file. This implies having a reference file stored
on your FS.
2/ if you know the ECC algorithm (and the platform specific config,
like the polynomial for a BCH engine) then you can create a tool
doing the ECC error detection in userspace.

--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering