[U-Boot-Users] Patch: flash_write return value in saveenv

Eisenhut, Daniel (MED) Daniel.Eisenhut at med.ge.com
Thu Feb 26 20:19:58 CET 2004


In the CFG_ENV_ADDR_REDUND version of the function saveenv in
common/env_flash.c...

If there is a failure with the flash_write function it
will always display an error message for a Flash Timeout
regardless of what the actual error is.  The variable "rc" is
set to 1 at declaration and flash_perror(rc) is called if there
is an error, but the actual return value of flash_write is not
stored in rc, therefore the error code displayed will always be 1.

The below patch corrects this...

Dan

diff -uNr clean/common/env_flash.c u-boot-1.0.2/common/env_flash.c
--- clean/common/env_flash.c	2004-02-25 16:36:28.000000000 -0600
+++ u-boot-1.0.2/common/env_flash.c	2004-02-26 12:55:38.000000000 -0600
@@ -207,21 +207,21 @@
 	debug (" %08lX ... %08lX ...",
 		(ulong)&(flash_addr_new->data),
 		sizeof(env_ptr->data)+(ulong)&(flash_addr_new->data));
-	if (flash_write(env_ptr->data,
+	if ((rc = flash_write(env_ptr->data,
 			(ulong)&(flash_addr_new->data),
-			sizeof(env_ptr->data)) ||
+			sizeof(env_ptr->data))) ||
 
-	    flash_write((char *)&(env_ptr->crc),
+	    (rc = flash_write((char *)&(env_ptr->crc),
 			(ulong)&(flash_addr_new->crc),
-			sizeof(env_ptr->crc)) ||
+			sizeof(env_ptr->crc))) ||
 
-	    flash_write((char *)&obsolete_flag,
+	    (rc = flash_write((char *)&obsolete_flag,
 			(ulong)&(flash_addr->flags),
-			sizeof(flash_addr->flags)) ||
+			sizeof(flash_addr->flags))) ||
 
-	    flash_write((char *)&active_flag,
+	    (rc = flash_write((char *)&active_flag,
 			(ulong)&(flash_addr_new->flags),
-			sizeof(flash_addr_new->flags)))
+			sizeof(flash_addr_new->flags))))
 	{
 		flash_perror (rc);
 		goto Done;
diff -uNr clean/CHANGELOG u-boot-1.0.2/CHANGELOG
--- clean/CHANGELOG	2004-02-26 13:02:21.000000000 -0600
+++ u-boot-1.0.2/CHANGELOG	2004-02-26 13:03:33.000000000 -0600
@@ -2,6 +2,9 @@
 Changes for U-Boot 1.0.2:
 ======================================================================
 
+* Patch by Dan Eisenhut, 26 Feb 2004:
+  fix flash_write return value in saveenv
+
 * Patch by Masami Komiya, 24 Feb 2004:
   Update NetBootFileXferSize in NFS code
 




More information about the U-Boot mailing list