Flash mapping questions

Jonathan Larmour jifl@eCosCentric.com
Wed Feb 11 02:05:00 GMT 2004


Gary Thomas wrote:
> [CYGSEM_IO_FLASH_READ_INDIRECT conflicts with CYGBLD_BUILD_REDBOOT_WITH_ZLIB ]
> Having "zlib" included let's you keep compressed images in FIS.  It's
> also necessary if you want to download compressed images and have
> RedBoot uncompress them on the fly. It's probably not too hard to get
> around this problem, I just didn't have the time when I added the
> "indirect" support.

[Old mail I know, I'm just going through my old stuff a bit]

This particular port aside, not supporting compressed FIS images is fair 
enough, but preventing compressed download should be easy to avoid, as per 
the attached patch. It's so easy I feel I'm missing something? Let me know 
if not and I'll commit :-).

Jifl

2004-02-11  Jonathan Larmour  <jifl@eCosCentric.com>

	* cdl/redboot.cdl: Bring CYGNUM_REDBOOT_LOAD_ZLIB_BUFFER under
	CYGBLD_BUILD_REDBOOT_WITH_ZLIB. Add CYGPRI_REDBOOT_ZLIB_FLASH to
	control whether decompression can be used with flash images.
	* src/flash.c: Use CYGPRI_REDBOOT_ZLIB_FLASH instead of
	CYGPKG_COMPRESS_ZLIB.
	* src/load.c: Use CYGBLD_BUILD_REDBOOT_WITH_ZLIB in place of
	CYGPKG_COMPRESS_ZLIB.
	* src/main.c: only set fis_zlib_common_buffer if
	CYGPRI_REDBOOT_ZLIB_FLASH.

Index: cdl/redboot.cdl
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/cdl/redboot.cdl,v
retrieving revision 1.62
diff -u -5 -p -r1.62 redboot.cdl
--- cdl/redboot.cdl	4 Feb 2004 15:44:15 -0000	1.62
+++ cdl/redboot.cdl	11 Feb 2004 01:59:33 -0000
@@ -159,20 +159,41 @@ cdl_package CYGPKG_REDBOOT {
                supported by the platform.  If the value is greater than 1, 
then
                a platform specific function must provide information about the
                additional segments."
          }

-        cdl_option CYGBLD_BUILD_REDBOOT_WITH_ZLIB {
+        cdl_component CYGBLD_BUILD_REDBOOT_WITH_ZLIB {
              display       "Include support gzip/zlib decompression"
              active_if     CYGPKG_COMPRESS_ZLIB
-## FIXME!
-            requires      { !CYGSEM_IO_FLASH_READ_INDIRECT }
-## FIXME!
-            no_define
              default_value 1
              implements    CYGINT_COMPRESS_ZLIB_LOCAL_ALLOC
              compile       decompress.c
+
+            cdl_option CYGNUM_REDBOOT_LOAD_ZLIB_BUFFER {
+                display       "Size of zlib decompression buffer"
+                flavor        data
+                default_value 64
+                legal_values  5 to 256
+                description   "
+                    This is the size of the buffer filled with incoming data
+                    during load before calls are made to the decompressor
+                    function. For ethernet downloads this can be made bigger
+                    (at the cost of memory), but for serial downloads on slow
+                    processors it may be necessary to reduce the size to
+                    avoid serial overruns. zlib appears to bail out if 
less than
+                    five bytes are available initially so this is the 
minimum."
+            }
+
+            cdl_option CYGPRI_REDBOOT_ZLIB_FLASH {
+                 display       "Support compression of Flash images"
+                 active_if     CYGPKG_REDBOOT_FLASH
+                 active_if     !CYGSEM_IO_FLASH_READ_INDIRECT
+                 calculated    1
+                 description   "
+                        This CDL indicates whether flash images can
+                        be decompressed from gzip/zlib format into RAM."
+            }
          }

          cdl_option CYGBLD_BUILD_REDBOOT_WITH_XYZMODEM {
              display       "Include support for xyzModem downloads"
              doc           ref/download-command.html
@@ -501,26 +522,10 @@ cdl_package CYGPKG_REDBOOT {
                This option controls the timeout period before the
                command processing is considered 'idle'.  Making this
                number smaller will cause idle processing to take place
                more often, etc.  The default value of 10ms is a reasonable
                tradeoff between responsiveness and overhead."
-        }
-
-        cdl_option CYGNUM_REDBOOT_LOAD_ZLIB_BUFFER {
-            display       "Size of zlib decompression buffer"
-            active_if     CYGPKG_COMPRESS_ZLIB
-            flavor        data
-            default_value 64
-            legal_values  5 to 256
-            description   "
-                This is the size of the buffer filled with incoming data
-                during load before calls are made to the decompressor
-                function. For ethernet downloads this can be made bigger
-                (at the cost of memory), but for serial downloads on slow
-                processors it may be necessary to reduce the size to
-                avoid serial overruns. zlib appears to bail out if less than
-                five bytes are available initially so this is the minimum."
          }

          cdl_option CYGSEM_REDBOOT_VALIDATE_USER_RAM_LOADS {
              display       "Validate RAM addresses during load"
              flavor        bool
Index: src/flash.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/flash.c,v
retrieving revision 1.62
diff -u -5 -p -r1.62 flash.c
--- src/flash.c	24 Nov 2003 12:17:51 -0000	1.62
+++ src/flash.c	11 Feb 2004 01:59:34 -0000
@@ -96,11 +96,11 @@ local_cmd_entry("delete",
                  fis_delete,
                  FIS_cmds
      );

  static char fis_load_usage[] =
-#ifdef CYGPKG_COMPRESS_ZLIB
+#ifdef CYGPRI_REDBOOT_ZLIB_FLASH
                        "[-d] "
  #endif
                        "[-b <memory_load_address>] [-c] name";

  local_cmd_entry("load",
@@ -984,21 +984,21 @@ fis_load(int argc, char *argv[])
      struct option_info opts[3];
  #ifdef CYGPKG_REDBOOT_FIS_CRC_CHECK
      unsigned long cksum;
  #endif
      int num_options;
-#ifdef CYGPKG_COMPRESS_ZLIB
+#ifdef CYGPRI_REDBOOT_ZLIB_FLASH
      bool decompress = false;
  #endif
      void *err_addr;

      init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM,
                (void **)&mem_addr, (bool *)&mem_addr_set, "memory [load] 
base address");
      init_opts(&opts[1], 'c', false, OPTION_ARG_TYPE_FLG,
                (void **)&show_cksum, (bool *)0, "display checksum");
      num_options = 2;
-#ifdef CYGPKG_COMPRESS_ZLIB
+#ifdef CYGPRI_REDBOOT_ZLIB_FLASH
      init_opts(&opts[num_options], 'd', false, OPTION_ARG_TYPE_FLG,
                (void **)&decompress, 0, "decompress");
      num_options++;
  #endif

@@ -1019,11 +1019,11 @@ fis_load(int argc, char *argv[])
      if (!valid_address((void *)mem_addr)) {
          diag_printf("Not a loadable image - try using -b ADDRESS option\n");
          return;
      }
  #endif
-#ifdef CYGPKG_COMPRESS_ZLIB
+#ifdef CYGPRI_REDBOOT_ZLIB_FLASH
      if (decompress) {
          int err;
          _pipe_t fis_load_pipe;
          _pipe_t* p = &fis_load_pipe;
          p->out_buf = (unsigned char*) mem_addr;
@@ -1328,11 +1328,11 @@ do_flash_init(void)
          flash_end = (void *)((CYG_ADDRESS)flash_end - 1);
          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;
          fisdir_size = ((fisdir_size + flash_block_size - 1) / 
flash_block_size) * flash_block_size;-# ifdef 
CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER
+# 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) {
              diag_printf("FLASH: common buffer too small\n");
              return false;
  	}
Index: src/load.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/load.c,v
retrieving revision 1.37
diff -u -5 -p -r1.37 load.c
--- src/load.c	2 Dec 2003 14:40:19 -0000	1.37
+++ src/load.c	11 Feb 2004 01:59:34 -0000
@@ -72,11 +72,11 @@
  #include <net/http.h>
  #endif
  #endif

  static char usage[] = "[-r] [-v] "
-#ifdef CYGPKG_COMPRESS_ZLIB
+#ifdef CYGBLD_BUILD_REDBOOT_WITH_ZLIB
                        "[-d] "
  #endif
                        "[-h <host>] [-m <varies>] "
  #if CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS > 1
                        "[-c <channel_number>] "
@@ -106,11 +106,11 @@ struct {
      int (*fun)(char *, int len, int *err);
      unsigned char  buf[BUF_SIZE];
      unsigned char *bufp;
      int   avail, len, err;
      int   verbose, decompress, tick;
-#ifdef CYGPKG_COMPRESS_ZLIB
+#ifdef CYGBLD_BUILD_REDBOOT_WITH_ZLIB
      int (*raw_fun)(char *, int len, int *err);
      _pipe_t load_pipe;
      unsigned char _buffer[CYGNUM_REDBOOT_LOAD_ZLIB_BUFFER];
  #endif
  } getc_info;
@@ -154,11 +154,11 @@ redboot_getc(void)
      }
      getc_info.avail--;
      return *getc_info.bufp++;
  }

-#ifdef CYGPKG_COMPRESS_ZLIB
+#ifdef CYGBLD_BUILD_REDBOOT_WITH_ZLIB
  //
  // Called to fetch a new chunk of data and decompress it
  //
  static int
  _decompress_stream(char *buf, int len, int *err)
@@ -209,11 +209,11 @@ redboot_getc_init(connection_info_t *inf
      getc_info.avail = 0;
      getc_info.len = BUF_SIZE;
      getc_info.verbose = verbose;
      getc_info.decompress = decompress;
      getc_info.tick = 0;
-#ifdef CYGPKG_COMPRESS_ZLIB
+#ifdef CYGBLD_BUILD_REDBOOT_WITH_ZLIB
      if (decompress) {
          _pipe_t* p = &getc_info.load_pipe;
          p->out_buf = &getc_info.buf[0];
          p->out_size = 0;
          p->in_avail = 0;
@@ -245,11 +245,11 @@ redboot_getc_terminate(bool abort)

  static void
  redboot_getc_close(void)
  {
      (getc_info.io->close)(&getc_info.err);
-#ifdef CYGPKG_COMPRESS_ZLIB
+#ifdef CYGBLD_BUILD_REDBOOT_WITH_ZLIB
      if (getc_info.decompress) {
          _pipe_t* p = &getc_info.load_pipe;
          int err = getc_info.err;
          if (0 != err && p->msg) {
              diag_printf("decompression error: %s\n", p->msg);
@@ -568,11 +568,11 @@ load_srec_image(getc_t getc, unsigned lo
  //
  // 'load' CLI command processing
  //   -b - specify a load [base] address
  //   -m - specify an I/O stream/method
  //   -c - Alternate serial I/O channel
-#ifdef CYGPKG_COMPRESS_ZLIB
+#ifdef CYGBLD_BUILD_REDBOOT_WITH_ZLIB
  //   -d - Decompress data [packed via 'zlib']
  #endif
  //
  void
  do_load(int argc, char *argv[])
@@ -629,11 +629,11 @@ do_load(int argc, char *argv[])
  #ifdef CYGPKG_REDBOOT_NETWORKING
      init_opts(&opts[num_options], 'h', true, OPTION_ARG_TYPE_STR,
                (void **)&hostname, (bool *)&hostname_set, "host name or IP 
address");
      num_options++;
  #endif
-#ifdef CYGPKG_COMPRESS_ZLIB
+#ifdef CYGBLD_BUILD_REDBOOT_WITH_ZLIB
      init_opts(&opts[num_options], 'd', false, OPTION_ARG_TYPE_FLG,
                (void **)&decompress, 0, "decompress");
      num_options++;
  #endif

Index: src/main.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/main.c,v
retrieving revision 1.53
diff -u -5 -p -r1.53 main.c
--- src/main.c	11 Feb 2004 01:25:45 -0000	1.53
+++ src/main.c	11 Feb 2004 01:59:35 -0000
@@ -295,11 +295,11 @@ cyg_start(void)
      // Nothing has ever been loaded into memory
      entry_address = (unsigned long)NO_MEMORY;

      bist();

-#ifdef CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER
+#if defined(CYGPRI_REDBOOT_ZLIB_FLASH) && 
defined(CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER)
      fis_zlib_common_buffer =
      workspace_end -= CYGNUM_REDBOOT_FIS_ZLIB_COMMON_BUFFER_SIZE;
  #endif

  #ifdef CYGFUN_REDBOOT_BOOT_SCRIPT

-- 
eCosCentric    http://www.eCosCentric.com/    The eCos and RedBoot experts
Visit us at Embedded World 2004, Nürnberg, Germany, 17-19 Feb, Stand 12-449
--["No sense being pessimistic, it wouldn't work anyway"]-- Opinions==mine



More information about the Ecos-devel mailing list