This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RedBoot - Improve FIS directory some more


Some changes which should allow FIS to work even with devices
that have very small block sizes.  Also, make the combined FIS/FC
mode be the default.

-- 
Gary Thomas <gary@mlbassoc.com>
MLB Associates
Index: redboot/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/redboot/current/ChangeLog,v
retrieving revision 1.151
diff -u -5 -p -r1.151 ChangeLog
--- redboot/current/ChangeLog	12 Oct 2003 11:39:06 -0000	1.151
+++ redboot/current/ChangeLog	15 Oct 2003 15:48:47 -0000
@@ -1,5 +1,20 @@
+2003-10-15  Gary Thomas  <gary@mlbassoc.com>
+
+	* src/flash.c: 
+	* src/fconfig.c: Better handling of layout of fconfig and fis
+	data within the FLASH.  Should work for even flash devices with
+	very smal block sizes.
+
+	* include/redboot.h (RedBoot_INIT_SECOND): 
+	Finer initialization control.
+
+	* cdl/redboot.cdl: Combine FIS directory and FCONFIG database
+	by default.  This results in better FLASH utilization. Also define
+	number of FIS directory slots.  This will allow support for FLASH
+	devices with very small block sizes.
+
 2003-10-12  Gary Thomas  <gary@mlbassoc.com>
 
 	* src/flash.c (fis_create): Verify that any hard FLASH addresses
 	(given via -f XXX) are known to be free.
 
Index: redboot/current/cdl/redboot.cdl
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/redboot/current/cdl/redboot.cdl,v
retrieving revision 1.57
diff -u -5 -p -r1.57 redboot.cdl
--- redboot/current/cdl/redboot.cdl	11 Oct 2003 21:22:32 -0000	1.57
+++ redboot/current/cdl/redboot.cdl	15 Oct 2003 15:19:40 -0000
@@ -655,10 +655,21 @@ cdl_package CYGPKG_REDBOOT {
                       sector. If your flash has tiny sectors, you may wish
                       to reduce this value in order to get more slots in
                       the FIS directory."
                 }
     
+                cdl_option CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_COUNT {
+                    display         "Number of FIS directory entries"
+                    flavor	    data
+                    default_value   8
+                    description "
+                      The FIS directory normally occupies a single flash
+                      sector. Adjusting this value can allow for more than
+                      one flash sector to be used, which is useful if your
+                      sectors are very small."
+                }
+    
                 cdl_option CYGBLD_REDBOOT_MIN_IMAGE_SIZE {
                     display       "Minimum image size"
                     flavor        data
                     default_value 0x20000
                     description "
@@ -764,11 +775,11 @@ cdl_package CYGPKG_REDBOOT {
 
             cdl_option CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG {
                 display       "Merged config data and FIS directory"
                 flavor        bool              
                 active_if     { CYGOPT_REDBOOT_FIS && (CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA == "FLASH") }
-                default_value 0
+                default_value 1
                 description "
                   If this option is set, then the FIS directory and FLASH 
                   configuration database will be stored in the same physical
                   FLASH block."
             }
Index: redboot/current/include/redboot.h
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/redboot/current/include/redboot.h,v
retrieving revision 1.30
diff -u -5 -p -r1.30 redboot.h
--- redboot/current/include/redboot.h	30 Sep 2003 21:17:43 -0000	1.30
+++ redboot/current/include/redboot.h	15 Oct 2003 15:44:07 -0000
@@ -247,11 +247,12 @@ struct cmd _cmd_tab_##_f_ CYG_HAL_TABLE_
 extern _cmd_entry(_s_,_h_,_u_,_f_,_subs_,_sube_,_n_)
 #define local_cmd_entry(_s_,_h_,_u_,_f_,_n_)                             \
 static _cmd_entry(_s_,_h_,_u_,_f_,0,0,_n_)
 
 // Initialization functions
-#define RedBoot_INIT_FIRST 0000
+#define RedBoot_INIT_FIRST  0000
+#define RedBoot_INIT_SECOND 0100
 // Specify a 3 digit numeric value for proper prioritizing
 #define RedBoot_INIT_PRIO(_n_) 1##_n_
 #define RedBoot_INIT_LAST  9999
 typedef void void_fun(void);
 typedef void_fun *void_fun_ptr;
Index: redboot/current/src/fconfig.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/redboot/current/src/fconfig.c,v
retrieving revision 1.5
diff -u -5 -p -r1.5 fconfig.c
--- redboot/current/src/fconfig.c	2 Oct 2003 20:13:29 -0000	1.5
+++ redboot/current/src/fconfig.c	15 Oct 2003 15:45:42 -0000
@@ -970,23 +970,24 @@ load_flash_config(void)
     readonly_config = (struct _config *)cfg_temp;
 #endif
     workspace_end = cfg_temp;
 #ifdef CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_FLASH
     if (!do_flash_init()) return;
-    cfg_size = (flash_block_size > sizeof(struct _config)) ? 
-        sizeof(struct _config) : 
-        _rup(sizeof(struct _config), flash_block_size);
 #ifdef CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG
-    cfg_size = _rup(cfg_size, sizeof(struct fis_image_desc));
-    if ((flash_block_size-cfg_size) < 8*sizeof(struct fis_image_desc)) {
+    cfg_size = _rup(sizeof(struct _config), sizeof(struct fis_image_desc));
+    if ((fisdir_size-cfg_size) < (CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_COUNT *
+                                  CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_SIZE)) {
         // Too bad this can't be checked at compile/build time
         diag_printf("Sorry, FLASH config exceeds available space in FIS directory\n");
         return;
     }
-    fisdir_size = flash_block_size - cfg_size;
-    cfg_base = (void *)(((CYG_ADDRESS)fis_addr + flash_block_size) - cfg_size);
+    cfg_base = (void *)(((CYG_ADDRESS)fis_addr + fisdir_size) - cfg_size);
+    fisdir_size -= cfg_size;
 #else
+    cfg_size = (flash_block_size > sizeof(struct _config)) ? 
+        sizeof(struct _config) : 
+        _rup(sizeof(struct _config), flash_block_size);
     if (CYGNUM_REDBOOT_FLASH_CONFIG_BLOCK < 0) {
         cfg_base = (void *)((CYG_ADDRESS)flash_end + 1 -
            _rup(_rup((-CYGNUM_REDBOOT_FLASH_CONFIG_BLOCK*flash_block_size), cfg_size), flash_block_size));
     } else {
         cfg_base = (void *)((CYG_ADDRESS)flash_start + 
@@ -1001,11 +1002,12 @@ load_flash_config(void)
     memcpy(readonly_config, config, sizeof(struct _config));
 #endif
     if ((cyg_crc32((unsigned char *)config, 
                    sizeof(struct _config)-sizeof(config->cksum)) != config->cksum) ||
         (config->key1 != CONFIG_KEY1)|| (config->key2 != CONFIG_KEY2)) {
-        diag_printf("FLASH configuration checksum error or invalid key\n");
+        diag_printf("**Warning** FLASH configuration checksum error or invalid key\n");
+        diag_printf("Use 'fconfig -i' to [re]intialize database\n");
         config_init();
         return;
     }
     config_ok = true;
     flash_get_config("boot_script", &use_boot_script, CONFIG_BOOL);
@@ -1019,8 +1021,8 @@ load_flash_config(void)
         set_console_baud_rate(console_baud_rate);
     }
 #endif
 }
 
-RedBoot_init(load_flash_config, RedBoot_INIT_FIRST);
+RedBoot_init(load_flash_config, RedBoot_INIT_SECOND);
 
 // EOF fconfig.c
Index: redboot/current/src/flash.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/redboot/current/src/flash.c,v
retrieving revision 1.57
diff -u -5 -p -r1.57 flash.c
--- redboot/current/src/flash.c	12 Oct 2003 11:39:07 -0000	1.57
+++ redboot/current/src/flash.c	15 Oct 2003 15:38:27 -0000
@@ -461,12 +461,11 @@ fis_list(int argc, char *argv[])
               (void **)&show_cksums, (bool *)0, "display checksums");
     i = 2;
 #else
     i = 1;
 #endif
-    if (!scan_opts(argc, argv, 2, opts, i, 0, 0, ""))
-    {
+    if (!scan_opts(argc, argv, 2, opts, i, 0, 0, "")) {
         return;
     }
     flash_read(fis_addr, fis_work_block, fisdir_size, (void **)&err_addr);
     // Let diag_printf do the formatting in both cases, rather than counting
     // cols by hand....
@@ -1313,10 +1312,11 @@ do_flash_init(void)
 {
     int stat;
     void *err_addr;
 
     if (!__flash_init) {
+        __flash_init = 1;
         if ((stat = flash_init((void *)(workspace_end-FLASH_MIN_WORKSPACE), 
                                FLASH_MIN_WORKSPACE, diag_printf)) != 0) {
             diag_printf("FLASH: driver init failed: %s\n", flash_errmsg(stat));
             return false;
         }
@@ -1324,32 +1324,36 @@ do_flash_init(void)
         // Keep 'end' address as last valid location, to avoid wrap around problems
         flash_end = (void *)((CYG_ADDRESS)flash_end - 1);
         flash_get_block_info(&flash_block_size, &flash_num_blocks);
         workspace_end = (unsigned char *)(workspace_end-FLASH_MIN_WORKSPACE);
 #ifdef CYGOPT_REDBOOT_FIS
+        fisdir_size = CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_COUNT * CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_SIZE;
+        fisdir_size = ((fisdir_size + flash_block_size - 1) / flash_block_size) * flash_block_size;
 # ifdef CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER
 	fis_work_block = fis_zlib_common_buffer;
-	if(CYGNUM_REDBOOT_FIS_ZLIB_COMMON_BUFFER_SIZE < flash_block_size) {
+	if(CYGNUM_REDBOOT_FIS_ZLIB_COMMON_BUFFER_SIZE < fisdir_size) {
             diag_printf("FLASH: common buffer too small\n");
 	    workspace_end += FLASH_MIN_WORKSPACE;
             return false;
 	}
 # else
-        workspace_end = (unsigned char *)(workspace_end-flash_block_size);
+        workspace_end = (unsigned char *)(workspace_end-fisdir_size);
         fis_work_block = workspace_end;
 # endif
-        fisdir_size = flash_block_size;
         if (CYGNUM_REDBOOT_FIS_DIRECTORY_BLOCK < 0) {
             fis_addr = (void *)((CYG_ADDRESS)flash_end + 1 +
                                 (CYGNUM_REDBOOT_FIS_DIRECTORY_BLOCK*flash_block_size));
         } else {
             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;
+        }
         flash_read(fis_addr, fis_work_block, fisdir_size, (void **)&err_addr);
 #endif
-        __flash_init = 1;
     }
     return true;
 }
 
 // Wrapper to avoid compiler warnings

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]