public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] Bad block skipping for command nboot
@ 2007-07-02 10:57 Thomas Knobloch
  2007-07-03 12:27 ` Stefan Roese
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Knobloch @ 2007-07-02 10:57 UTC (permalink / raw)
  To: u-boot

The old implementation of command nboot does not support reading the image from
NAND flash with skipping of bad blocks. The patch implements a new version of
the nboot command: by calling nboot.jffs2 from the u-boot command line the
command will load the image from NAND flash with respect to bad blocks (by using
nand_read_opts()). This is similar to e.g. the NAND read command: "nand
read.jffs2 ...".


Signed-off-by: Thomas Knobloch <knobloch@siemens.com>

--- a/common/cmd_nand.c	2007-02-02 10:02:06.000000000 +0100
+++ b/common/cmd_nand.c	2007-07-02 10:59:26.000000000 +0200
@@ -476,14 +476,33 @@
  			   ulong offset, ulong addr, char *cmd)
  {
  	int r;
-	char *ep;
+	char *ep, *s;
  	ulong cnt;
  	image_header_t *hdr;
+	int jffs2 = 0;
+
+	s = strchr(cmd, '.');
+	if (s != NULL &&
+	    (!strcmp(s, ".jffs2") || !strcmp(s, ".e") || !strcmp(s, ".i")))
+	{
+		jffs2 = 1;
+	}

  	printf("\nLoading from %s, offset 0x%lx\n", nand->name, offset);

  	cnt = nand->oobblock;
-	r = nand_read(nand, offset, &cnt, (u_char *) addr);
+	if (jffs2) {
+		nand_read_options_t opts;
+		memset(&opts, 0, sizeof(opts));
+		opts.buffer	= (u_char*) addr;
+		opts.length	= cnt;
+		opts.offset	= offset;
+		opts.quiet      = 1;
+		r = nand_read_opts(nand, &opts);
+	} else {
+		r = nand_read(nand, offset, &cnt, (u_char *) addr);
+	}
+
  	if (r) {
  		puts("** Read error\n");
  		SHOW_BOOT_PROGRESS(-1);
@@ -501,8 +520,18 @@
  	print_image_hdr(hdr);

  	cnt = (ntohl(hdr->ih_size) + sizeof (image_header_t));
+	if (jffs2) {
+		nand_read_options_t opts;
+		memset(&opts, 0, sizeof(opts));
+		opts.buffer	= (u_char*) addr;
+		opts.length	= cnt;
+		opts.offset	= offset;
+		opts.quiet      = 1;
+		r = nand_read_opts(nand, &opts);
+	} else {
+		r = nand_read(nand, offset, &cnt, (u_char *) addr);
+	}

-	r = nand_read(nand, offset, &cnt, (u_char *) addr);
  	if (r) {
  		puts("** Read error\n");
  		SHOW_BOOT_PROGRESS(-1);
@@ -550,7 +579,7 @@
  			if (argc > 3)
  				goto usage;
  			if (argc == 3)
-				addr = simple_strtoul(argv[2], NULL, 16);
+				addr = simple_strtoul(argv[1], NULL, 16);
  			else
  				addr = CFG_LOAD_ADDR;
  			return nand_load_image(cmdtp, &nand_info[dev->id->num],
@@ -605,7 +634,7 @@

  U_BOOT_CMD(nboot, 4, 1, do_nandboot,
  	"nboot   - boot from NAND device\n",
-	"[partition] | [[[loadAddr] dev] offset]\n");
+	"[.jffs2] [partition] | [[[loadAddr] dev] offset]\n");

  #endif				/* (CONFIG_COMMANDS & CFG_CMD_NAND) */

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot-Users] [PATCH] Bad block skipping for command nboot
  2007-07-02 10:57 [U-Boot-Users] [PATCH] Bad block skipping for command nboot Thomas Knobloch
@ 2007-07-03 12:27 ` Stefan Roese
  2007-07-03 14:44   ` Thomas Knobloch
  2007-07-03 15:32   ` Thomas Knobloch
  0 siblings, 2 replies; 6+ messages in thread
From: Stefan Roese @ 2007-07-03 12:27 UTC (permalink / raw)
  To: u-boot

Hi Thomas,

On Monday 02 July 2007, Thomas Knobloch wrote:
> The old implementation of command nboot does not support reading the image
> from NAND flash with skipping of bad blocks. The patch implements a new
> version of the nboot command: by calling nboot.jffs2 from the u-boot
> command line the command will load the image from NAND flash with respect
> to bad blocks (by using nand_read_opts()). This is similar to e.g. the NAND
> read command: "nand read.jffs2 ...".

And that's why I have to ask: Do we really need this command extension? Why 
not just use a combination of commands (e.g. "nand read.jffs2 ...;bootm ...)?

Nevertheless one short remark in the patch below:

> Signed-off-by: Thomas Knobloch <knobloch@siemens.com>
>
> --- a/common/cmd_nand.c	2007-02-02 10:02:06.000000000 +0100
> +++ b/common/cmd_nand.c	2007-07-02 10:59:26.000000000 +0200
> @@ -476,14 +476,33 @@
>   			   ulong offset, ulong addr, char *cmd)
>   {
>   	int r;
> -	char *ep;
> +	char *ep, *s;
>   	ulong cnt;
>   	image_header_t *hdr;
> +	int jffs2 = 0;
> +
> +	s = strchr(cmd, '.');
> +	if (s != NULL &&
> +	    (!strcmp(s, ".jffs2") || !strcmp(s, ".e") || !strcmp(s, ".i")))
> +	{
> +		jffs2 = 1;
> +	}

No parentheses for one lined statements please.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot-Users] [PATCH] Bad block skipping for command nboot
  2007-07-03 12:27 ` Stefan Roese
@ 2007-07-03 14:44   ` Thomas Knobloch
  2007-07-03 14:55     ` Stefan Roese
  2007-07-03 15:32   ` Thomas Knobloch
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Knobloch @ 2007-07-03 14:44 UTC (permalink / raw)
  To: u-boot

On 7/3/2007 2:27 PM, Stefan Roese wrote:
> And that's why I have to ask: Do we really need this command extension? Why
> not just use a combination of commands (e.g. "nand read.jffs2 ...;bootm
> ...)?

Using "nand read.jffs2 ...;bootm ..." has one disadvantage compared to the new
"nboot.jffs2 ...". For the first command sequence u-boot has to read a fixed
number of bytes from the NAND. You have to make big enough to support the
largest possible image for your application. If the image is smaller u-boot will
still have to read this fixed number of bytes.
For "nboot" resp. "nboot.jffs2" u-boot will read only as much data from NAND as
necessary. This might give some performance improvement. BTW: when you ask for
the need of the command "nboot.jffs2" you probably should question the pure
"nboot" as well. It can be replaced by "nand read ...;bootm ..." as well.

>  > +     if (s != NULL &&
>  > +         (!strcmp(s, ".jffs2") || !strcmp(s, ".e") || !strcmp(s, ".i")))
>  > +     {
>  > +             jffs2 = 1;
>  > +     }
>
> No parentheses for one lined statements please.

Sorry for that.

Best regards,
Thomas


SECM PD Mch
Siemens Enterprise Communications Manufacturing GmbH & Co KG
Hertzstrasse 2
04329 Leipzig

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot-Users] [PATCH] Bad block skipping for command nboot
  2007-07-03 14:44   ` Thomas Knobloch
@ 2007-07-03 14:55     ` Stefan Roese
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Roese @ 2007-07-03 14:55 UTC (permalink / raw)
  To: u-boot

Hi Thomas,

On Tuesday 03 July 2007, Thomas Knobloch wrote:
> > And that's why I have to ask: Do we really need this command extension?
> > Why not just use a combination of commands (e.g. "nand read.jffs2
> > ...;bootm ...)?
>
> Using "nand read.jffs2 ...;bootm ..." has one disadvantage compared to the
> new "nboot.jffs2 ...". For the first command sequence u-boot has to read a
> fixed number of bytes from the NAND. You have to make big enough to support
> the largest possible image for your application. If the image is smaller
> u-boot will still have to read this fixed number of bytes.
> For "nboot" resp. "nboot.jffs2" u-boot will read only as much data from
> NAND as necessary. This might give some performance improvement.

Understood.

> BTW: when 
> you ask for the need of the command "nboot.jffs2" you probably should
> question the pure "nboot" as well. It can be replaced by "nand read
> ...;bootm ..." as well.

Yep, correct. That's what was asking myself. I never used it so far.

Please resend the patch and I'll commit it to the NAND repository.

Thanks.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot-Users] [PATCH] Bad block skipping for command nboot
  2007-07-03 12:27 ` Stefan Roese
  2007-07-03 14:44   ` Thomas Knobloch
@ 2007-07-03 15:32   ` Thomas Knobloch
  2007-07-06 12:59     ` Stefan Roese
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Knobloch @ 2007-07-03 15:32 UTC (permalink / raw)
  To: u-boot

The old implementation of command nboot does not support reading the image from
NAND flash with skipping of bad blocks. The patch implements a new version of
the nboot command: by calling nboot.jffs2 from the u-boot command line the
command will load the image from NAND flash with respect to bad blocks (by using
nand_read_opts()). This is similar to e.g. the NAND read command: "nand
read.jffs2 ...".


Signed-off-by: Thomas Knobloch <knobloch@siemens.com>

--- a/common/cmd_nand.c	2007-02-02 10:02:06.000000000 +0100
+++ b/common/cmd_nand.c	2007-07-03 17:21:47.000000000 +0200
@@ -476,14 +476,31 @@ static int nand_load_image(cmd_tbl_t *cm
  			   ulong offset, ulong addr, char *cmd)
  {
  	int r;
-	char *ep;
+	char *ep, *s;
  	ulong cnt;
  	image_header_t *hdr;
+	int jffs2 = 0;
+
+	s = strchr(cmd, '.');
+	if (s != NULL &&
+	    (!strcmp(s, ".jffs2") || !strcmp(s, ".e") || !strcmp(s, ".i")))
+		jffs2 = 1;

  	printf("\nLoading from %s, offset 0x%lx\n", nand->name, offset);

  	cnt = nand->oobblock;
-	r = nand_read(nand, offset, &cnt, (u_char *) addr);
+	if (jffs2) {
+		nand_read_options_t opts;
+		memset(&opts, 0, sizeof(opts));
+		opts.buffer	= (u_char*) addr;
+		opts.length	= cnt;
+		opts.offset	= offset;
+		opts.quiet      = 1;
+		r = nand_read_opts(nand, &opts);
+	} else {
+		r = nand_read(nand, offset, &cnt, (u_char *) addr);
+	}
+
  	if (r) {
  		puts("** Read error\n");
  		SHOW_BOOT_PROGRESS(-1);
@@ -501,8 +518,18 @@ static int nand_load_image(cmd_tbl_t *cm
  	print_image_hdr(hdr);

  	cnt = (ntohl(hdr->ih_size) + sizeof (image_header_t));
+	if (jffs2) {
+		nand_read_options_t opts;
+		memset(&opts, 0, sizeof(opts));
+		opts.buffer	= (u_char*) addr;
+		opts.length	= cnt;
+		opts.offset	= offset;
+		opts.quiet      = 1;
+		r = nand_read_opts(nand, &opts);
+	} else {
+		r = nand_read(nand, offset, &cnt, (u_char *) addr);
+	}

-	r = nand_read(nand, offset, &cnt, (u_char *) addr);
  	if (r) {
  		puts("** Read error\n");
  		SHOW_BOOT_PROGRESS(-1);
@@ -550,7 +577,7 @@ int do_nandboot(cmd_tbl_t * cmdtp, int f
  			if (argc > 3)
  				goto usage;
  			if (argc == 3)
-				addr = simple_strtoul(argv[2], NULL, 16);
+				addr = simple_strtoul(argv[1], NULL, 16);
  			else
  				addr = CFG_LOAD_ADDR;
  			return nand_load_image(cmdtp, &nand_info[dev->id->num],
@@ -605,7 +632,7 @@ usage:

  U_BOOT_CMD(nboot, 4, 1, do_nandboot,
  	"nboot   - boot from NAND device\n",
-	"[partition] | [[[loadAddr] dev] offset]\n");
+	"[.jffs2] [partition] | [[[loadAddr] dev] offset]\n");

  #endif				/* (CONFIG_COMMANDS & CFG_CMD_NAND) */

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot-Users] [PATCH] Bad block skipping for command nboot
  2007-07-03 15:32   ` Thomas Knobloch
@ 2007-07-06 12:59     ` Stefan Roese
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Roese @ 2007-07-06 12:59 UTC (permalink / raw)
  To: u-boot

Hi Thomas,

On Tuesday 03 July 2007, Thomas Knobloch wrote:
> The old implementation of command nboot does not support reading the image
> from NAND flash with skipping of bad blocks. The patch implements a new
> version of the nboot command: by calling nboot.jffs2 from the u-boot
> command line the command will load the image from NAND flash with respect
> to bad blocks (by using nand_read_opts()). This is similar to e.g. the NAND
> read command: "nand read.jffs2 ...".

Applied to the u-boot-nand-flash repository.

Thanks.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-07-06 12:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-02 10:57 [U-Boot-Users] [PATCH] Bad block skipping for command nboot Thomas Knobloch
2007-07-03 12:27 ` Stefan Roese
2007-07-03 14:44   ` Thomas Knobloch
2007-07-03 14:55     ` Stefan Roese
2007-07-03 15:32   ` Thomas Knobloch
2007-07-06 12:59     ` Stefan Roese

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox