diff -r -U 0 -N -x CVS -x '*~' -x '.#~' a/packages/redboot/current/cdl/redboot.cdl b/packages/redboot/current/cdl/redboot.cdl
--- a/packages/redboot/current/cdl/redboot.cdl	2007-06-04 22:30:59.000000000 +0200
+++ b/packages/redboot/current/cdl/redboot.cdl	2007-11-27 10:40:40.000000000 +0100
@@ -228,0 +229,14 @@
+            cdl_option CYGOPT_REDBOOT_ZLIB_FLASH_AUTO_DETECT {
+                 display       "Support auto-detection of compressed images"
+                 active_if     CYGPKG_REDBOOT_FLASH
+                 active_if     !CYGSEM_IO_FLASH_READ_INDIRECT
+                 flavor        bool
+                 default_value 0
+                 description   "
+                        Enable this option to support the -a option with
+                        the fis load command. When using the -a option,
+                        first a gzip/zlib decompression will be attempted.
+                        If that one fails, a simple copy of the image to
+                        RAM will be performed.
+                        Only used if CYGPRI_REDBOOT_ZLIB_FLASH is active."
+            }
diff -r -U 0 -N -x CVS -x '*~' -x '.#~' a/packages/redboot/current/src/flash.c b/packages/redboot/current/src/flash.c
--- a/packages/redboot/current/src/flash.c	2007-08-28 12:59:52.000000000 +0200
+++ b/packages/redboot/current/src/flash.c	2007-11-27 10:19:47.000000000 +0100
@@ -104,0 +105,4 @@
+
+#ifdef CYGOPT_REDBOOT_ZLIB_FLASH_AUTO_DETECT
+                      "[-a] "
+#endif
@@ -1226 +1230 @@
-    struct option_info opts[3];
+    struct option_info opts[4];
@@ -1232,0 +1237,4 @@
+    int err = 0;
+#ifdef CYGOPT_REDBOOT_ZLIB_FLASH_AUTO_DETECT
+    bool decompress_auto_detect = false;
+#endif
@@ -1244,0 +1253,5 @@
+#ifdef CYGOPT_REDBOOT_ZLIB_FLASH_AUTO_DETECT
+    init_opts(&opts[num_options], 'a', false, OPTION_ARG_TYPE_FLG, 
+              (void *)&decompress_auto_detect, 0, "auto-detect image format");
+    num_options++;
+#endif
@@ -1268,0 +1282 @@
+#ifdef CYGOPT_REDBOOT_ZLIB_FLASH_AUTO_DETECT
@@ -1270 +1284,9 @@
-        int err;
+        // -d takes precedence over -a
+        decompress_auto_detect = false;
+    }
+#endif
+    if (decompress
+#ifdef CYGOPT_REDBOOT_ZLIB_FLASH_AUTO_DETECT
+        || decompress_auto_detect
+#endif
+    ) {
@@ -1286,5 +1308,9 @@
-
-        if (0 != err && p->msg) {
-            diag_printf("decompression error: %s\n", p->msg);
-        } else {
-            diag_printf("Image loaded from %p-%p\n", (unsigned char *)mem_addr, p->out_buf);
+#ifdef CYGOPT_REDBOOT_ZLIB_FLASH_AUTO_DETECT
+        if(!decompress_auto_detect || err == 0) {
+#endif
+            if (0 != err && p->msg) {
+                diag_printf("decompression error: %s\n", p->msg);
+            } else {
+                diag_printf("Image loaded from %p-%p\n", (unsigned char *)mem_addr, p->out_buf);
+            }
+#ifdef CYGOPT_REDBOOT_ZLIB_FLASH_AUTO_DETECT
@@ -1292 +1318 @@
-
+#endif
@@ -1298,0 +1325,4 @@
+#ifdef CYGOPT_REDBOOT_ZLIB_FLASH_AUTO_DETECT
+    }
+    if(!decompress && (!decompress_auto_detect || err != 0))
+#else
@@ -1300,0 +1331 @@
+#endif // CYGPRI_REDBOOT_ZLIB_FLASH
@@ -1316 +1347,5 @@
-    if (!decompress && img->file_cksum) {
+    if ((!decompress
+#ifdef CYGOPT_REDBOOT_ZLIB_FLASH_AUTO_DETECT    
+    && (!decompress_auto_detect || err)
+#endif
+    ) && img->file_cksum) {
