All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: "Gaëtan Carlier" <gcembed@gmail.com>
Cc: Artem Bityutskiy <dedekind1@gmail.com>,
	J.Lambrecht@televic.com, Juergen Beisert <jbe@pengutronix.de>,
	linux-mtd@lists.infradead.org,
	Sascha Hauer <kernel@pengutronix.de>,
	David Woodhouse <dwmw2@infradead.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/1] mxc_nand : allow swapping the Bad block Indicator for NFC v1.
Date: Tue, 11 Sep 2012 10:47:03 +0200	[thread overview]
Message-ID: <20120911084703.GO18243@pengutronix.de> (raw)
In-Reply-To: <504EF035.2090508@gmail.com>

On Tue, Sep 11, 2012 at 10:03:01AM +0200, Gaëtan Carlier wrote:
> >>The point is not the necessity of swapping bytes if factory bad
> >>block markers are not used.
> >>In my case, the bytes must be swapped because all previous
> >>operations on flash swapped these bytes :
> >>* Flashes redboot (bootloader) via JTAG using OpenOCD which swaps bytes;
> >>* Writes kernel and rootfs via TFTP using redboot which swaps bytes;
> >>So to be able to read rootfs partition, mxc-nand driver have to swap
> >>bytes otherwise, JFFS2 detects error on partition and is unable to
> >>mount it.
> >
> >I am all in favour to be able to swap the factory bad block marker with
> >the position the mtd framework expects it.
> >
> >That according to our understanding are bytes 0x7d0 in the main area
> >and byte 0x0 in the spare area.
> >
> >>
> >>I have not chosen to swap these bytes. In a training, I received
> >>redboot and kernel 2.6.22 with set of patches to support i.MX27 and
> >>these patches included swap of bytes in nand driver. So I start my
> >>development with this workaround and it is now impossible to get
> >>back because boards are already in production.
> >
> >So you are swapping the factory bad block marker with some position
> >where the mtd layer does not expect the bad block marker. With this
> >you preserve the factor bad block marker, but do not use it to detect
> >bad blocks.
> The factor bad block marker are used by redboot. I don't know how
> kernel handles them.

This depends on chip->badblockpos. Normally this defaults to
NAND_LARGE_BADBLOCK_POS for 2k nands. This would be the first oob byte.

So you would have to swap the factory bad block marker with some other
oob byte, but you would also have to make sure that you set
chip->badblockpos to the location you swap with.

One BIG problem is that I've seen multiple variants of this patch, for
example one variant I've seen swaps with oob byte 5 or 6 (the standard
badblock marker for 512byte page nands). So you would not only have
to put a 'bool swap' into platformdata, but also the information with
which byte to swap.

This is all very annoying, because the swap location (or no swap at all)
is specific to a single board, *not* to a board type. This makes this
information unsuitable for platform_data (For example someone might
use redboot on some board which swaps the bad block marker, some other
persion might use another bootloader which does not swap on the very
same board type). The only sane solution would be to store this
information inside the flash chip itself.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

WARNING: multiple messages have this Message-ID (diff)
From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/1] mxc_nand : allow swapping the Bad block Indicator for NFC v1.
Date: Tue, 11 Sep 2012 10:47:03 +0200	[thread overview]
Message-ID: <20120911084703.GO18243@pengutronix.de> (raw)
In-Reply-To: <504EF035.2090508@gmail.com>

On Tue, Sep 11, 2012 at 10:03:01AM +0200, Ga?tan Carlier wrote:
> >>The point is not the necessity of swapping bytes if factory bad
> >>block markers are not used.
> >>In my case, the bytes must be swapped because all previous
> >>operations on flash swapped these bytes :
> >>* Flashes redboot (bootloader) via JTAG using OpenOCD which swaps bytes;
> >>* Writes kernel and rootfs via TFTP using redboot which swaps bytes;
> >>So to be able to read rootfs partition, mxc-nand driver have to swap
> >>bytes otherwise, JFFS2 detects error on partition and is unable to
> >>mount it.
> >
> >I am all in favour to be able to swap the factory bad block marker with
> >the position the mtd framework expects it.
> >
> >That according to our understanding are bytes 0x7d0 in the main area
> >and byte 0x0 in the spare area.
> >
> >>
> >>I have not chosen to swap these bytes. In a training, I received
> >>redboot and kernel 2.6.22 with set of patches to support i.MX27 and
> >>these patches included swap of bytes in nand driver. So I start my
> >>development with this workaround and it is now impossible to get
> >>back because boards are already in production.
> >
> >So you are swapping the factory bad block marker with some position
> >where the mtd layer does not expect the bad block marker. With this
> >you preserve the factor bad block marker, but do not use it to detect
> >bad blocks.
> The factor bad block marker are used by redboot. I don't know how
> kernel handles them.

This depends on chip->badblockpos. Normally this defaults to
NAND_LARGE_BADBLOCK_POS for 2k nands. This would be the first oob byte.

So you would have to swap the factory bad block marker with some other
oob byte, but you would also have to make sure that you set
chip->badblockpos to the location you swap with.

One BIG problem is that I've seen multiple variants of this patch, for
example one variant I've seen swaps with oob byte 5 or 6 (the standard
badblock marker for 512byte page nands). So you would not only have
to put a 'bool swap' into platformdata, but also the information with
which byte to swap.

This is all very annoying, because the swap location (or no swap at all)
is specific to a single board, *not* to a board type. This makes this
information unsuitable for platform_data (For example someone might
use redboot on some board which swaps the bad block marker, some other
persion might use another bootloader which does not swap on the very
same board type). The only sane solution would be to store this
information inside the flash chip itself.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2012-09-11  8:47 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-15 13:04 [PATCH v2] mxc_nand : allow swapping the Bad block Indicator for NFC v1 Gaëtan Carlier
2012-08-15 13:04 ` Gaëtan Carlier
2012-08-24 12:28 ` Artem Bityutskiy
2012-08-24 12:28   ` Artem Bityutskiy
2012-08-24 16:17   ` [PATCH 1/1] " Gaëtan Carlier
2012-08-24 16:17     ` Gaëtan Carlier
2012-08-28 10:33     ` Gaëtan Carlier
2012-08-28 10:33       ` Gaëtan Carlier
2012-08-29  7:56     ` Artem Bityutskiy
2012-08-29  7:56       ` Artem Bityutskiy
2012-09-06  8:56     ` Juergen Beisert
2012-09-06  8:56       ` Juergen Beisert
2012-09-10 14:31       ` Gaëtan Carlier
2012-09-10 14:31         ` Gaëtan Carlier
2012-09-11  7:17         ` Sascha Hauer
2012-09-11  7:17           ` Sascha Hauer
2012-09-11  8:03           ` Gaëtan Carlier
2012-09-11  8:03             ` Gaëtan Carlier
2012-09-11  8:47             ` Sascha Hauer [this message]
2012-09-11  8:47               ` Sascha Hauer
2012-09-23 13:00           ` Artem Bityutskiy
2012-09-23 13:00             ` Artem Bityutskiy
2014-03-26 13:53           ` Gaëtan Carlier
2014-03-26 13:53             ` Gaëtan Carlier
2014-03-28  9:11             ` Sascha Hauer
2014-03-28  9:11               ` Sascha Hauer
2014-03-28  9:52               ` Gaëtan Carlier
2014-03-28  9:52                 ` Gaëtan Carlier
2012-09-06 13:03     ` Juergen Beisert
2012-09-06 13:03       ` Juergen Beisert

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=20120911084703.GO18243@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=J.Lambrecht@televic.com \
    --cc=dedekind1@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=gcembed@gmail.com \
    --cc=jbe@pengutronix.de \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --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.