Hi Folks

The attached patch to redboot fixes two issues:

fis_update_directory() used the size of a flash block when
reading/writing instead of the size of the configuration
information. This causes problems with devices which have small blocks
and a number of blocks are being used to hold the FIS directory.

fis unlock and fis lock would not compile when the FIS directory is
disabled because the function to lookup a name does not exist.

        Andrew
Index: redboot/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/ChangeLog,v
retrieving revision 1.237
diff -u -r1.237 ChangeLog
--- redboot/current/ChangeLog   30 Jan 2006 21:04:04 -0000      1.237
+++ redboot/current/ChangeLog   19 Feb 2006 17:10:44 -0000
@@ -1,3 +1,10 @@
+2006-02-17  Andrew Lunn  <[EMAIL PROTECTED]>
+
+       * src/flash.c (fis_lock & fis_unlock): Allow compilation without
+       FIS being enabled.
+       * src/flash.c (fis_update_directory): When reading/writing flash
+       use the full size of the fis directory, not just one block.
+
 2005-11-23  Peter Korsgaard  <[EMAIL PROTECTED]>
 
        * src/gunzip.c (do_gunzip): Fixed diag_printf format string warnings.
Index: redboot/current/src/flash.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/flash.c,v
retrieving revision 1.76
diff -u -r1.76 flash.c
--- redboot/current/src/flash.c 8 Sep 2005 12:14:33 -0000       1.76
+++ redboot/current/src/flash.c 19 Feb 2006 17:10:46 -0000
@@ -255,20 +255,20 @@
 #endif
 #ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL
     // Ensure [quietly] that the directory is unlocked before trying to update
-    flash_unlock((void *)fis_addr, flash_block_size, (void **)&err_addr);
+    flash_unlock((void *)fis_addr, fisdir_size, (void **)&err_addr);
 #endif
-    if ((stat = flash_erase(fis_addr, flash_block_size, (void **)&err_addr)) 
!= 0) {
+    if ((stat = flash_erase(fis_addr, fisdir_size, (void **)&err_addr)) != 0) {
         diag_printf("Error erasing FIS directory at %p: %s\n", err_addr, 
flash_errmsg(stat));
     } else {
         if ((stat = FLASH_PROGRAM(fis_addr, fis_work_block,
-                                  flash_block_size, (void **)&err_addr)) != 0) 
{
+                                  fisdir_size, (void **)&err_addr)) != 0) {
             diag_printf("Error writing FIS directory at %p: %s\n", 
                         err_addr, flash_errmsg(stat));
         }
     }
 #ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL
     // Ensure [quietly] that the directory is locked after the update
-    flash_lock((void *)fis_addr, flash_block_size, (void **)&err_addr);
+    flash_lock((void *)fis_addr, fisdir_size, (void **)&err_addr);
 #endif
     fis_endian_fixup(fis_work_block);
 }
@@ -1273,7 +1273,7 @@
         fis_usage("invalid arguments");
         return;
     }
-
+#ifdef CYGOPT_REDBOOT_FIS
     /* Get parameters from image if specified */
     if (name) {
         struct fis_image_desc *img;
@@ -1284,7 +1284,9 @@
 
         flash_addr = img->flash_base;
         length = img->size;
-    } else if (!flash_addr_set || !length_set) {
+    } else
+#endif
+      if (!flash_addr_set || !length_set) {
         fis_usage("missing argument");
         return;
     }
@@ -1320,7 +1322,7 @@
         fis_usage("invalid arguments");
         return;
     }
-
+#ifdef CYGOPT_REDBOOT_FIS
     if (name) {
         struct fis_image_desc *img;
         if ((img = fis_lookup(name, NULL)) == (struct fis_image_desc *)0) {
@@ -1330,7 +1332,9 @@
 
         flash_addr = img->flash_base;
         length = img->size;
-    } else  if (!flash_addr_set || !length_set) {
+    } else
+#endif
+      if (!flash_addr_set || !length_set) {
         fis_usage("missing argument");
         return;
     }
@@ -1393,6 +1397,7 @@
             fis_addr = (void *)((CYG_ADDRESS)flash_start + 
                                 
(CYGNUM_REDBOOT_FIS_DIRECTORY_BLOCK*flash_block_size));
         }
+        
         if (((CYG_ADDRESS)fis_addr + fisdir_size - 1) > 
(CYG_ADDRESS)flash_end) {
             diag_printf("FIS directory doesn't fit\n");
             return false;

Reply via email to