All of lore.kernel.org
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Bad Block Capable environment for OneNAND
Date: Tue, 28 Apr 2009 18:11:30 -0500	[thread overview]
Message-ID: <20090428231130.GB5266@ld0162-tx32.am.freescale.net> (raw)
In-Reply-To: <E38B6ADC1D594013ADFC5E8CAEAFFBBD@sisodomain.com>

On Mon, Apr 13, 2009 at 06:34:52PM +0530, apgmoorthy wrote:
> +	/* Protect boot-loader and environment variables from badblock testing */
> +	while (start < CONFIG_SYS_MONITOR_LEN + CONFIG_ENV_SIZE + badblocklen) {
> +		if (mtd->block_isbad(&onenand_mtd, start))
> +			badblocklen += blocksize;
> +		start += blocksize;
> +	}

You need to start at zero to determine the number of bad blocks used by
the boot image -- otherwise, if start points in the middle of the image,
it is assuming that there were no bad blocks prior to that location.

Plus, if "start" was not block-aligned (is that allowed?), this should
round up to the next block rather than jumping to the middle of the next
block.

> +#define ONENAND_ENV_END   (CONFIG_SYS_MONITOR_LEN + CONFIG_ENV_SIZE)
> +
>  char *env_name_spec = "OneNAND";
>  
>  #ifdef ENV_IS_EMBEDDED
> @@ -58,23 +68,31 @@ uchar env_get_char_spec(int index)
>  
>  void env_relocate_spec(void)
>  {
> -	unsigned long env_addr;
> -	int use_default = 0;
> +	unsigned long env_addr = CONFIG_SYS_MONITOR_LEN;

As above, you have to check for bad blocks from the beginning.  You do
this in saveenv...

> +	int use_default = 1;
>  	size_t retlen;
> +	int blocksize = onenand_mtd.erasesize;
>  
> -	env_addr = CONFIG_ENV_ADDR;
> +	/* Find environment block. */
> +	while (onenand_mtd.writesize && (env_addr < ONENAND_ENV_END)) {
> +		if (onenand_block_isbad(&onenand_mtd, env_addr)) {
> +			printf("Skip bad block at 0x%x\n", (u32)env_addr);

Why not just use %lx?

> +	 /* update crc */
> +	 env_ptr->crc =
> +	     crc32(0, env_ptr->data, ONENAND_ENV_SIZE(onenand_mtd));

There's an extra space in the above indent.

> +	 return 0;

Here too.

<record state="broken">
Any consolidation we can do between env_nand and env_onenand would be
appreciated... even if they don't share code yet, let's keep the logic
similar.
</record>

-Scott

  reply	other threads:[~2009-04-28 23:11 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-23  9:02 [U-Boot] [PATCH 1/2] Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN apgmoorthy
2009-03-23 21:25 ` Scott Wood
2009-03-23 22:09   ` Wolfgang Denk
2009-03-23 22:22     ` Scott Wood
2009-03-23 22:46       ` Wolfgang Denk
2009-03-25  4:13         ` Amit Kumar Sharma
2009-03-25 15:49   ` apgmoorthy
2009-03-27  9:15   ` apgmoorthy
2009-03-30 22:33     ` Scott Wood
2009-03-31  4:12       ` Amit Kumar Sharma
2009-04-12  7:55       ` apgmoorthy
2009-04-23 22:39         ` Scott Wood
2009-04-24  5:05           ` Amit Kumar Sharma
2009-04-13 13:04       ` [U-Boot] [PATCH] Bad Block Capable environment for OneNAND apgmoorthy
2009-04-28 23:11         ` Scott Wood [this message]
2009-03-31 16:08     ` [U-Boot] [PATCH 1/2] Fix OneNAND ipl to read CONFIG_SYS_MONITOR_LEN Alessandro Rubini
2009-03-31 16:13       ` Scott Wood
2009-04-01  4:10         ` Amit Kumar Sharma
2009-04-01 21:55           ` Scott Wood
2009-04-06  6:05   ` [U-Boot] OneNand support broken for apollon apgmoorthy

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=20090428231130.GB5266@ld0162-tx32.am.freescale.net \
    --to=scottwood@freescale.com \
    --cc=u-boot@lists.denx.de \
    /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.