changeset 1717:faaea4243d52

* cdl/redboot.cdl: Fixed the type of CYGNUM_REDBOOT_FLASH_BASE * src/flash.c (fis_[un]lock): Fix compiler warnings * src/flash.c (do_flash_init): Removed the MIPS br0ken condition which i wrongly added. My problem was actually a / 0. This roundup is needed otherwise the workspace goes off the end of the RAM.
author asl
date Mon, 16 Aug 2004 08:35:33 +0000
parents e4f7f465ee77
children c8515e560548
files packages/redboot/current/ChangeLog packages/redboot/current/cdl/redboot.cdl packages/redboot/current/src/flash.c
diffstat 3 files changed, 43 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/packages/redboot/current/ChangeLog
+++ b/packages/redboot/current/ChangeLog
@@ -1,3 +1,14 @@
+2004-08-13  Andrew Lunn  <andrew.lunn@ascom.ch>
+
+	* cdl/redboot.cdl: Fixed the type of CYGNUM_REDBOOT_FLASH_BASE
+	* src/flash.c (fis_[un]lock): Fix compiler warnings
+
+2004-08-06  Andrew Lunn  <andrew.lunn@ascom.ch>
+
+	* src/flash.c (do_flash_init): Removed the MIPS br0ken condition
+	which i wrongly added. My problem was actually a / 0. This roundup
+	is needed otherwise the workspace goes off the end of the RAM.
+
 2004-08-05  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* src/flash.c:
--- a/packages/redboot/current/cdl/redboot.cdl
+++ b/packages/redboot/current/cdl/redboot.cdl
@@ -72,7 +72,7 @@ cdl_package CYGPKG_REDBOOT {
         display       "Include support for ELF file format"
         default_value 1
     }
-
+        
 
     cdl_interface CYGINT_REDBOOT_LOAD_METHOD {
         display "Methods of loading images using redboot"
@@ -549,6 +549,19 @@ cdl_package CYGPKG_REDBOOT {
               into memory for execution or executed in place."
             compile -library=libextras.a flash.c
     
+            cdl_option CYGNUM_REDBOOT_FLASH_BASE {
+                display       "Base address of flash device redboot should use"
+                flavor        data
+                default_value 0
+                description   "
+                    This option controls how redboot finds the flash
+                    device. The default value of 0 will cause redboot
+                    to use the flash which has the lowest memory
+                    address. Setting this option to an address will
+                    cause redboot to use that address instead as the 
+                    base of the flash device."
+            }
+                    
             cdl_option CYGOPT_REDBOOT_FIS {
                 display         "RedBoot Flash Image System support"
                 default_value   1
@@ -864,7 +877,7 @@ cdl_package CYGPKG_REDBOOT {
               If this option is enabled then RedBoot will provide commands
               to load files from fileio file systems such as JFFS2."
             compile -library=libextras.a fs/fileio.c
-        }
+	} 
 
         cdl_component CYGPKG_REDBOOT_DISK {
             display       "Allow RedBoot to support disks"
--- a/packages/redboot/current/src/flash.c
+++ b/packages/redboot/current/src/flash.c
@@ -233,7 +233,7 @@ fis_update_directory(void)
 #endif
 #ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL
     // Ensure [quietly] that the directory is unlocked before trying to update
-    cyg_flash_unlock((void *)fis_addr, flash_block_size, &err_addr);
+    cyg_flash_unlock(fis_addr, flash_block_size, &err_addr);
 #endif
     if ((stat = cyg_flash_erase(fis_addr, flash_block_size, &err_addr)) != 0) {
         diag_printf("Error erasing FIS directory at %p: %s\n", err_addr, cyg_flash_errmsg(stat));
@@ -246,7 +246,7 @@ fis_update_directory(void)
     }
 #ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL
     // Ensure [quietly] that the directory is locked after the update
-    cyg_flash_lock((void *)fis_addr, flash_block_size, &err_addr);
+    cyg_flash_lock(fis_addr, flash_block_size, &err_addr);
 #endif
 }
 
@@ -1374,6 +1374,9 @@ do_flash_init(void)
 {
     int stat;
     cyg_flashaddr_t err_addr;
+#ifdef CYGNUM_REDBOOT_FLASH_BASE
+    cyg_flash_info_t info;
+#endif
 
     if (!__flash_init) {
         __flash_init = 1;
@@ -1382,23 +1385,30 @@ do_flash_init(void)
             diag_printf("FLASH: driver init failed: %s\n", cyg_flash_errmsg(stat));
             return false;
         }
-        
+
+#ifdef CYGNUM_REDBOOT_FLASH_BASE
+        stat = cyg_flash_get_info_addr(CYGNUM_REDBOOT_FLASH_BASE, &info);
+        if (stat != CYG_FLASH_ERR_OK) {
+             diag_printf("FLASH: driver init failed: %s\n", 
+                         cyg_flash_errmsg(stat));
+             return false;
+        }
+        flash_start = info.start;
+        flash_end = info.end;
+#else        
         if ((stat = cyg_flash_get_limits(&flash_start, &flash_end)) != 0) {
             diag_printf("FLASH: driver init failed: %s\n", 
                         cyg_flash_errmsg(stat));
             return false;
         }
-
+#endif
         // Keep 'end' address as last valid location, to avoid wrap around problems
         flash_end = ((CYG_ADDRESS)flash_end - 1);
         cyg_flash_get_block_info(&flash_block_size, &flash_num_blocks);
         
 #ifdef CYGOPT_REDBOOT_FIS
         fisdir_size = CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_COUNT * CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_SIZE;
-
-#ifndef CYGPKG_HAL_MIPS // FIXME: compiler is b0rken
         fisdir_size = ((fisdir_size + flash_block_size - 1) / flash_block_size) * flash_block_size;
-#endif
 # if defined(CYGPRI_REDBOOT_ZLIB_FLASH) && defined(CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER)
 	fis_work_block = fis_zlib_common_buffer;
 	if(CYGNUM_REDBOOT_FIS_ZLIB_COMMON_BUFFER_SIZE < fisdir_size) {