]> git.sur5r.net Git - openocd/commitdiff
non-CFI flash code uses data from CFI structures. Make sure that timeouts are filled...
authorMichael Schwingen <michael@schwingen.org>
Sun, 2 Jan 2011 20:01:19 +0000 (21:01 +0100)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Sun, 2 Jan 2011 20:15:08 +0000 (21:15 +0100)
Signed-off-by: Michael Schwingen <michael@schwingen.org>
src/flash/nor/cfi.c
src/flash/nor/non_cfi.c

index 74362c4f78809dc01e8dad6452f9ade4880f15e2..5a35aaef92d024efb4895a74858d8c7774dc7ef7 100644 (file)
@@ -2563,39 +2563,6 @@ static int cfi_probe(struct flash_bank *bank)
                if (retval != ERROR_OK)
                        return retval;
 
-               LOG_DEBUG("Vcc min: %x.%x, Vcc max: %x.%x, Vpp min: %u.%x, Vpp max: %u.%x",
-                       (cfi_info->vcc_min & 0xf0) >> 4, cfi_info->vcc_min & 0x0f,
-                       (cfi_info->vcc_max & 0xf0) >> 4, cfi_info->vcc_max & 0x0f,
-                       (cfi_info->vpp_min & 0xf0) >> 4, cfi_info->vpp_min & 0x0f,
-                       (cfi_info->vpp_max & 0xf0) >> 4, cfi_info->vpp_max & 0x0f);
-
-               LOG_DEBUG("typ. word write timeout: %u us, typ. buf write timeout: %u us, "
-                               "typ. block erase timeout: %u ms, typ. chip erase timeout: %u ms",
-                               1 << cfi_info->word_write_timeout_typ, 1 << cfi_info->buf_write_timeout_typ,
-                               1 << cfi_info->block_erase_timeout_typ, 1 << cfi_info->chip_erase_timeout_typ);
-
-               LOG_DEBUG("max. word write timeout: %u us, max. buf write timeout: %u us, "
-                               "max. block erase timeout: %u ms, max. chip erase timeout: %u ms",
-                               (1 << cfi_info->word_write_timeout_max) * (1 << cfi_info->word_write_timeout_typ),
-                               (1 << cfi_info->buf_write_timeout_max) * (1 << cfi_info->buf_write_timeout_typ),
-                               (1 << cfi_info->block_erase_timeout_max) * (1 << cfi_info->block_erase_timeout_typ),
-                               (1 << cfi_info->chip_erase_timeout_max) * (1 << cfi_info->chip_erase_timeout_typ));
-
-               /* convert timeouts to real values in ms */
-               cfi_info->word_write_timeout = DIV_ROUND_UP((1 << cfi_info->word_write_timeout_typ) *
-                                               (1 << cfi_info->word_write_timeout_max), 1000);
-               cfi_info->buf_write_timeout = DIV_ROUND_UP((1 << cfi_info->buf_write_timeout_typ) *
-                               (1 << cfi_info->buf_write_timeout_max), 1000);
-               cfi_info->block_erase_timeout = (1 << cfi_info->block_erase_timeout_typ) *
-                               (1 << cfi_info->block_erase_timeout_max);
-               cfi_info->chip_erase_timeout = (1 << cfi_info->chip_erase_timeout_typ) *
-                               (1 << cfi_info->chip_erase_timeout_max);
-
-               LOG_DEBUG("calculated word write timeout: %u ms, buf write timeout: %u ms, "
-                               "block erase timeout: %u ms, chip erase timeout: %u ms",
-                               cfi_info->word_write_timeout, cfi_info->buf_write_timeout,
-                               cfi_info->block_erase_timeout, cfi_info->chip_erase_timeout);
-
                uint8_t data;
                retval = cfi_query_u8(bank, 0, 0x27, &data);
                if (retval != ERROR_OK)
@@ -2663,6 +2630,39 @@ static int cfi_probe(struct flash_bank *bank)
                }
        } /* end CFI case */
 
+       LOG_DEBUG("Vcc min: %x.%x, Vcc max: %x.%x, Vpp min: %u.%x, Vpp max: %u.%x",
+               (cfi_info->vcc_min & 0xf0) >> 4, cfi_info->vcc_min & 0x0f,
+               (cfi_info->vcc_max & 0xf0) >> 4, cfi_info->vcc_max & 0x0f,
+               (cfi_info->vpp_min & 0xf0) >> 4, cfi_info->vpp_min & 0x0f,
+               (cfi_info->vpp_max & 0xf0) >> 4, cfi_info->vpp_max & 0x0f);
+
+       LOG_DEBUG("typ. word write timeout: %u us, typ. buf write timeout: %u us, "
+                       "typ. block erase timeout: %u ms, typ. chip erase timeout: %u ms",
+                       1 << cfi_info->word_write_timeout_typ, 1 << cfi_info->buf_write_timeout_typ,
+                       1 << cfi_info->block_erase_timeout_typ, 1 << cfi_info->chip_erase_timeout_typ);
+
+       LOG_DEBUG("max. word write timeout: %u us, max. buf write timeout: %u us, "
+                       "max. block erase timeout: %u ms, max. chip erase timeout: %u ms",
+                       (1 << cfi_info->word_write_timeout_max) * (1 << cfi_info->word_write_timeout_typ),
+                       (1 << cfi_info->buf_write_timeout_max) * (1 << cfi_info->buf_write_timeout_typ),
+                       (1 << cfi_info->block_erase_timeout_max) * (1 << cfi_info->block_erase_timeout_typ),
+                       (1 << cfi_info->chip_erase_timeout_max) * (1 << cfi_info->chip_erase_timeout_typ));
+
+       /* convert timeouts to real values in ms */
+       cfi_info->word_write_timeout = DIV_ROUND_UP((1L << cfi_info->word_write_timeout_typ) *
+                               (1L << cfi_info->word_write_timeout_max), 1000);
+       cfi_info->buf_write_timeout = DIV_ROUND_UP((1L << cfi_info->buf_write_timeout_typ) *
+                               (1L << cfi_info->buf_write_timeout_max), 1000);
+       cfi_info->block_erase_timeout = (1L << cfi_info->block_erase_timeout_typ) *
+                               (1L << cfi_info->block_erase_timeout_max);
+       cfi_info->chip_erase_timeout = (1L << cfi_info->chip_erase_timeout_typ) *
+                               (1L << cfi_info->chip_erase_timeout_max);
+
+       LOG_DEBUG("calculated word write timeout: %u ms, buf write timeout: %u ms, "
+                       "block erase timeout: %u ms, chip erase timeout: %u ms",
+                       cfi_info->word_write_timeout, cfi_info->buf_write_timeout,
+                       cfi_info->block_erase_timeout, cfi_info->chip_erase_timeout);
+
        /* apply fixups depending on the primary command set */
        switch (cfi_info->pri_id)
        {
@@ -2858,77 +2858,74 @@ static int get_cfi_info(struct flash_bank *bank, char *buf, int buf_size)
        }
 
        if (cfi_info->not_cfi == 0)
-               printed = snprintf(buf, buf_size, "\ncfi information:\n");
+               printed = snprintf(buf, buf_size, "\nCFI flash: ");
        else
-               printed = snprintf(buf, buf_size, "\nnon-cfi flash:\n");
+               printed = snprintf(buf, buf_size, "\nnon-CFI flash: ");
        buf += printed;
        buf_size -= printed;
 
-       printed = snprintf(buf, buf_size, "\nmfr: 0x%4.4x, id:0x%4.4x\n",
+       printed = snprintf(buf, buf_size, "mfr: 0x%4.4x, id:0x%4.4x\n\n",
                cfi_info->manufacturer, cfi_info->device_id);
        buf += printed;
        buf_size -= printed;
 
-       if (cfi_info->not_cfi == 0)
-       {
-               printed = snprintf(buf, buf_size, "qry: '%c%c%c', pri_id: 0x%4.4x, pri_addr: "
-                               "0x%4.4x, alt_id: 0x%4.4x, alt_addr: 0x%4.4x\n",
-                               cfi_info->qry[0], cfi_info->qry[1], cfi_info->qry[2],
-                               cfi_info->pri_id, cfi_info->pri_addr, cfi_info->alt_id, cfi_info->alt_addr);
-               buf += printed;
-               buf_size -= printed;
-
-               printed = snprintf(buf, buf_size, "Vcc min: %x.%x, Vcc max: %x.%x, "
-                               "Vpp min: %u.%x, Vpp max: %u.%x\n",
-                               (cfi_info->vcc_min & 0xf0) >> 4, cfi_info->vcc_min & 0x0f,
-                               (cfi_info->vcc_max & 0xf0) >> 4, cfi_info->vcc_max & 0x0f,
-                               (cfi_info->vpp_min & 0xf0) >> 4, cfi_info->vpp_min & 0x0f,
-                               (cfi_info->vpp_max & 0xf0) >> 4, cfi_info->vpp_max & 0x0f);
-               buf += printed;
-               buf_size -= printed;
-
-               printed = snprintf(buf, buf_size, "typ. word write timeout: %u us, "
-                               "typ. buf write timeout: %u us, "
-                               "typ. block erase timeout: %u ms, "
-                               "typ. chip erase timeout: %u ms\n",
-                               1 << cfi_info->word_write_timeout_typ,
-                               1 << cfi_info->buf_write_timeout_typ,
-                               1 << cfi_info->block_erase_timeout_typ,
-                               1 << cfi_info->chip_erase_timeout_typ);
-               buf += printed;
-               buf_size -= printed;
-
-               printed = snprintf(buf, buf_size, "max. word write timeout: %u us, "
-                               "max. buf write timeout: %u us, max. "
-                               "block erase timeout: %u ms, max. chip erase timeout: %u ms\n",
-                               (1 << cfi_info->word_write_timeout_max) * (1 << cfi_info->word_write_timeout_typ),
-                               (1 << cfi_info->buf_write_timeout_max) * (1 << cfi_info->buf_write_timeout_typ),
-                               (1 << cfi_info->block_erase_timeout_max) * (1 << cfi_info->block_erase_timeout_typ),
-                               (1 << cfi_info->chip_erase_timeout_max) * (1 << cfi_info->chip_erase_timeout_typ));
-               buf += printed;
-               buf_size -= printed;
-
-               printed = snprintf(buf, buf_size, "size: 0x%" PRIx32 ", interface desc: %i, "
-                               "max buffer write size: 0x%x\n",
-                               cfi_info->dev_size,
-                               cfi_info->interface_desc,
-                               1 << cfi_info->max_buf_write_size);
-               buf += printed;
-               buf_size -= printed;
+       printed = snprintf(buf, buf_size, "qry: '%c%c%c', pri_id: 0x%4.4x, pri_addr: "
+                       "0x%4.4x, alt_id: 0x%4.4x, alt_addr: 0x%4.4x\n",
+                       cfi_info->qry[0], cfi_info->qry[1], cfi_info->qry[2],
+                       cfi_info->pri_id, cfi_info->pri_addr, cfi_info->alt_id, cfi_info->alt_addr);
+       buf += printed;
+       buf_size -= printed;
 
-               switch (cfi_info->pri_id)
-               {
-                       case 1:
-                       case 3:
-                               cfi_intel_info(bank, buf, buf_size);
-                               break;
-                       case 2:
-                               cfi_spansion_info(bank, buf, buf_size);
-                               break;
-                       default:
-                               LOG_ERROR("cfi primary command set %i unsupported", cfi_info->pri_id);
-                               break;
-               }
+       printed = snprintf(buf, buf_size, "Vcc min: %x.%x, Vcc max: %x.%x, "
+                       "Vpp min: %u.%x, Vpp max: %u.%x\n",
+                       (cfi_info->vcc_min & 0xf0) >> 4, cfi_info->vcc_min & 0x0f,
+                       (cfi_info->vcc_max & 0xf0) >> 4, cfi_info->vcc_max & 0x0f,
+                       (cfi_info->vpp_min & 0xf0) >> 4, cfi_info->vpp_min & 0x0f,
+                       (cfi_info->vpp_max & 0xf0) >> 4, cfi_info->vpp_max & 0x0f);
+       buf += printed;
+       buf_size -= printed;
+
+       printed = snprintf(buf, buf_size, "typ. word write timeout: %u us, "
+                       "typ. buf write timeout: %u us, "
+                       "typ. block erase timeout: %u ms, "
+                       "typ. chip erase timeout: %u ms\n",
+                       1 << cfi_info->word_write_timeout_typ,
+                       1 << cfi_info->buf_write_timeout_typ,
+                       1 << cfi_info->block_erase_timeout_typ,
+                       1 << cfi_info->chip_erase_timeout_typ);
+       buf += printed;
+       buf_size -= printed;
+
+       printed = snprintf(buf, buf_size, "max. word write timeout: %u us, "
+                       "max. buf write timeout: %u us, max. "
+                       "block erase timeout: %u ms, max. chip erase timeout: %u ms\n",
+                       (1 << cfi_info->word_write_timeout_max) * (1 << cfi_info->word_write_timeout_typ),
+                       (1 << cfi_info->buf_write_timeout_max) * (1 << cfi_info->buf_write_timeout_typ),
+                       (1 << cfi_info->block_erase_timeout_max) * (1 << cfi_info->block_erase_timeout_typ),
+                       (1 << cfi_info->chip_erase_timeout_max) * (1 << cfi_info->chip_erase_timeout_typ));
+       buf += printed;
+       buf_size -= printed;
+
+       printed = snprintf(buf, buf_size, "size: 0x%" PRIx32 ", interface desc: %i, "
+                       "max buffer write size: 0x%x\n",
+                       cfi_info->dev_size,
+                       cfi_info->interface_desc,
+                       1 << cfi_info->max_buf_write_size);
+       buf += printed;
+       buf_size -= printed;
+
+       switch (cfi_info->pri_id)
+       {
+               case 1:
+               case 3:
+                       cfi_intel_info(bank, buf, buf_size);
+                       break;
+               case 2:
+                       cfi_spansion_info(bank, buf, buf_size);
+                       break;
+               default:
+                       LOG_ERROR("cfi primary command set %i unsupported", cfi_info->pri_id);
+                       break;
        }
 
        return ERROR_OK;
index c68ace67e82454f56e5810d08b15ddccc3ed2dca..b6739043ce969704199e2a1a9fdd4252f2a0efbc 100644 (file)
@@ -477,10 +477,12 @@ void cfi_fixup_non_cfi(struct flash_bank *bank)
        cfi_info->vcc_max = 0x0;
        cfi_info->vpp_min = 0x0;
        cfi_info->vpp_max = 0x0;
-       cfi_info->word_write_timeout_typ = 0x0;
-       cfi_info->buf_write_timeout_typ = 0x0;
-       cfi_info->block_erase_timeout_typ = 0x0;
-       cfi_info->chip_erase_timeout_typ = 0x0;
+       /* these are used for timeouts - use vales that should be long enough
+          for normal operation. */
+       cfi_info->word_write_timeout_typ = 0x0a;
+       cfi_info->buf_write_timeout_typ = 0x0d;
+       cfi_info->block_erase_timeout_typ = 0x0d;
+       cfi_info->chip_erase_timeout_typ = 0x10;
        cfi_info->word_write_timeout_max = 0x0;
        cfi_info->buf_write_timeout_max = 0x0;
        cfi_info->block_erase_timeout_max = 0x0;