Michael Schwingen <rincewind@discworld.dascon.de> add non-CFI SST flashs
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 21 Apr 2009 05:31:18 +0000 (05:31 +0000)
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 21 Apr 2009 05:31:18 +0000 (05:31 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@1480 b42882b7-edfa-0310-969c-e2dbd0fdcd60

AUTHORS
src/flash/cfi.c
src/flash/cfi.h
src/flash/non_cfi.c
src/flash/non_cfi.h

diff --git a/AUTHORS b/AUTHORS
index 7e5806417089147fd4f2b22a42949575207e4a2a..e76920b47ba591c1916399f02efbe3fd060903f7 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -5,3 +5,4 @@ Spencer Oliver <spen@spen-soft.co.uk>
 Carsten Schlote <schlote@vahanus.net>
 Øyvind Harboe <oyvind.harboe@zylin.com>
 Duane Ellis <openocd@duaneellis.com>
 Carsten Schlote <schlote@vahanus.net>
 Øyvind Harboe <oyvind.harboe@zylin.com>
 Duane Ellis <openocd@duaneellis.com>
+Michael Schwingen <michael@schwingen.org>
index 0426fd2e6f144b3104f5ef6f57a30527f40df186..b4bb605339e9076c732909de4dca69d6e50cfa55 100644 (file)
@@ -296,13 +296,14 @@ u8 cfi_intel_wait_status_busy(flash_bank_t *bank, int timeout)
 int cfi_spansion_wait_status_busy(flash_bank_t *bank, int timeout)
 {
        u8 status, oldstatus;
 int cfi_spansion_wait_status_busy(flash_bank_t *bank, int timeout)
 {
        u8 status, oldstatus;
+       cfi_flash_bank_t *cfi_info = bank->driver_priv;
 
        oldstatus = cfi_get_u8(bank, 0, 0x0);
 
        do {
                status = cfi_get_u8(bank, 0, 0x0);
                if ((status ^ oldstatus) & 0x40) {
 
        oldstatus = cfi_get_u8(bank, 0, 0x0);
 
        do {
                status = cfi_get_u8(bank, 0, 0x0);
                if ((status ^ oldstatus) & 0x40) {
-                       if (status & 0x20) {
+                       if (status & cfi_info->status_poll_mask & 0x20) {
                                oldstatus = cfi_get_u8(bank, 0, 0x0);
                                status = cfi_get_u8(bank, 0, 0x0);
                                if ((status ^ oldstatus) & 0x40) {
                                oldstatus = cfi_get_u8(bank, 0, 0x0);
                                status = cfi_get_u8(bank, 0, 0x0);
                                if ((status ^ oldstatus) & 0x40) {
@@ -313,7 +314,7 @@ int cfi_spansion_wait_status_busy(flash_bank_t *bank, int timeout)
                                        return(ERROR_OK);
                                }
                        }
                                        return(ERROR_OK);
                                }
                        }
-               } else {
+               } else { /* no toggle: finished, OK */
                        LOG_DEBUG("status: 0x%x", status);
                        return(ERROR_OK);
                }
                        LOG_DEBUG("status: 0x%x", status);
                        return(ERROR_OK);
                }
@@ -2283,6 +2284,7 @@ static int cfi_probe(struct flash_bank_s *bank)
                                break;
                        /* AMD/Spansion, Atmel, ... command set */
                        case 0x0002:
                                break;
                        /* AMD/Spansion, Atmel, ... command set */
                        case 0x0002:
+                               cfi_info->status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7; /* default for all CFI flashs */
                                cfi_read_0002_pri_ext(bank);
                                break;
                        default:
                                cfi_read_0002_pri_ext(bank);
                                break;
                        default:
@@ -2303,7 +2305,7 @@ static int cfi_probe(struct flash_bank_s *bank)
                {
                        return retval;
                }
                {
                        return retval;
                }
-       }
+       } /* end CFI case */
 
        /* apply fixups depending on the primary command set */
        switch(cfi_info->pri_id)
 
        /* apply fixups depending on the primary command set */
        switch(cfi_info->pri_id)
index 5eab7efdd9bf47a1e6938a880a17c66952b3736a..dc43dd18bda7523a87645ae287f95f65097a06e7 100644 (file)
 #include "flash.h"
 #include "target.h"
 
 #include "flash.h"
 #include "target.h"
 
+#define CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7 0xE0 /* DQ5..DQ7 */
+#define CFI_STATUS_POLL_MASK_DQ6_DQ7     0xC0 /* DQ6..DQ7 */
+
 typedef struct cfi_flash_bank_s
 {
        working_area_t *write_algorithm;
 
 typedef struct cfi_flash_bank_s
 {
        working_area_t *write_algorithm;
 
-
        int x16_as_x8;
        int jedec_probe;
        int not_cfi;
        int x16_as_x8;
        int jedec_probe;
        int not_cfi;
@@ -58,6 +60,8 @@ typedef struct cfi_flash_bank_s
        u8 block_erase_timeout_max;
        u8 chip_erase_timeout_max;
 
        u8 block_erase_timeout_max;
        u8 chip_erase_timeout_max;
 
+       u8 status_poll_mask;
+
        /* flash geometry */
        u32 dev_size;
        u16 interface_desc;
        /* flash geometry */
        u32 dev_size;
        u16 interface_desc;
index b9ef1127331c435c364b908ef311d77787abdcf7..20aa9f1e1f095185624b43225e6ff6fcca8242ae 100644 (file)
@@ -44,6 +44,7 @@ non_cfi_t non_cfi_flashes[] = {
                .dev_size = 64*KB,
                .interface_desc = 0x0,          /* x8 only device */
                .max_buf_write_size = 0x0,
                .dev_size = 64*KB,
                .interface_desc = 0x0,          /* x8 only device */
                .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7,
                .num_erase_regions = 1,
                .erase_region_info =
                {
                .num_erase_regions = 1,
                .erase_region_info =
                {
@@ -57,6 +58,7 @@ non_cfi_t non_cfi_flashes[] = {
                .dev_size = 128*KB,
                .interface_desc = 0x0,          /* x8 only device */
                .max_buf_write_size = 0x0,
                .dev_size = 128*KB,
                .interface_desc = 0x0,          /* x8 only device */
                .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7,
                .num_erase_regions = 1,
                .erase_region_info =
                {
                .num_erase_regions = 1,
                .erase_region_info =
                {
@@ -70,6 +72,7 @@ non_cfi_t non_cfi_flashes[] = {
                .dev_size = 256*KB,
                .interface_desc = 0x0,          /* x8 only device */
                .max_buf_write_size = 0x0,
                .dev_size = 256*KB,
                .interface_desc = 0x0,          /* x8 only device */
                .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7,
                .num_erase_regions = 1,
                .erase_region_info =
                {
                .num_erase_regions = 1,
                .erase_region_info =
                {
@@ -83,6 +86,7 @@ non_cfi_t non_cfi_flashes[] = {
                .dev_size = 512*KB,
                .interface_desc = 0x0,          /* x8 only device */
                .max_buf_write_size = 0x0,
                .dev_size = 512*KB,
                .interface_desc = 0x0,          /* x8 only device */
                .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7,
                .num_erase_regions = 1,
                .erase_region_info =
                {
                .num_erase_regions = 1,
                .erase_region_info =
                {
@@ -96,6 +100,7 @@ non_cfi_t non_cfi_flashes[] = {
                .dev_size = 512*KB,
                .interface_desc = 0x2,          /* x8 or x16 device */
                .max_buf_write_size = 0x0,
                .dev_size = 512*KB,
                .interface_desc = 0x2,          /* x8 or x16 device */
                .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7,
                .num_erase_regions = 1,
                .erase_region_info =
                {
                .num_erase_regions = 1,
                .erase_region_info =
                {
@@ -109,6 +114,7 @@ non_cfi_t non_cfi_flashes[] = {
                .dev_size = 512*KB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
                .dev_size = 512*KB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7,
                .num_erase_regions = 4,
                .erase_region_info =
                {
                .num_erase_regions = 4,
                .erase_region_info =
                {
@@ -125,6 +131,7 @@ non_cfi_t non_cfi_flashes[] = {
                .dev_size = 512*KB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
                .dev_size = 512*KB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7,
                .num_erase_regions = 4,
                .erase_region_info =
                {
                .num_erase_regions = 4,
                .erase_region_info =
                {
@@ -134,6 +141,94 @@ non_cfi_t non_cfi_flashes[] = {
                        ERASE_REGION( 1, 16*KB)
                }
        },
                        ERASE_REGION( 1, 16*KB)
                }
        },
+
+       /* SST 39VF* do not support DQ5 status polling - this currently is
+          only supported by the host algorithm, not by the target code using
+          the work area. */
+       {
+               .mfr = CFI_MFR_SST,
+               .id = 0x2782,                           /* SST39xF160 */
+               .pri_id = 0x02,
+               .dev_size = 2*MB,
+               .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
+               .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ6_DQ7,
+               .num_erase_regions = 1,
+               .erase_region_info =
+               {
+                       ERASE_REGION(512, 4*KB)
+               }
+       },
+       {
+               .mfr = CFI_MFR_SST,
+               .id = 0x2783,                           /* SST39VF320 */
+               .pri_id = 0x02,
+               .dev_size = 4*MB,
+               .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
+               .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ6_DQ7,
+               .num_erase_regions = 1,
+               .erase_region_info =
+               {
+                       ERASE_REGION(1024, 4*KB)
+               }
+       },
+       {
+               .mfr = CFI_MFR_SST,
+               .id = 0x234b,                           /* SST39VF1601 */
+               .pri_id = 0x02,
+               .dev_size = 2*MB,
+               .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
+               .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ6_DQ7,
+               .num_erase_regions = 1,
+               .erase_region_info =
+               {
+                       ERASE_REGION(512, 4*KB)
+               }
+       },
+       {
+               .mfr = CFI_MFR_SST,
+               .id = 0x234a,                           /* SST39VF1602 */
+               .pri_id = 0x02,
+               .dev_size = 2*MB,
+               .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
+               .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ6_DQ7,
+               .num_erase_regions = 1,
+               .erase_region_info =
+               {
+                       ERASE_REGION(512, 4*KB)
+               }
+       },
+       {
+               .mfr = CFI_MFR_SST,
+               .id = 0x235b,                           /* SST39VF3201 */
+               .pri_id = 0x02,
+               .dev_size = 4*MB,
+               .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
+               .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ6_DQ7,
+               .num_erase_regions = 1,
+               .erase_region_info =
+               {
+                       ERASE_REGION(1024, 4*KB)
+               }
+       },
+       {
+               .mfr = CFI_MFR_SST,
+               .id = 0x235a,                           /* SST39VF3202 */
+               .pri_id = 0x02,
+               .dev_size = 4*MB,
+               .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
+               .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ6_DQ7,
+               .num_erase_regions = 1,
+               .erase_region_info =
+               {
+                       ERASE_REGION(1024, 4*KB)
+               }
+       },
        {
                .mfr = CFI_MFR_AMD,
                .id = 0x22ab,                           /* AM29F400BB */
        {
                .mfr = CFI_MFR_AMD,
                .id = 0x22ab,                           /* AM29F400BB */
@@ -141,6 +236,7 @@ non_cfi_t non_cfi_flashes[] = {
                .dev_size = 512*KB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
                .dev_size = 512*KB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7,
                .num_erase_regions = 4,
                .erase_region_info =
                {
                .num_erase_regions = 4,
                .erase_region_info =
                {
@@ -157,6 +253,7 @@ non_cfi_t non_cfi_flashes[] = {
                .dev_size = 512*KB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
                .dev_size = 512*KB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7,
                .num_erase_regions = 4,
                .erase_region_info =
                {
                .num_erase_regions = 4,
                .erase_region_info =
                {
@@ -173,6 +270,7 @@ non_cfi_t non_cfi_flashes[] = {
                .dev_size = 1*MB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
                .dev_size = 1*MB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7,
                .num_erase_regions = 4,
                .erase_region_info =
                {
                .num_erase_regions = 4,
                .erase_region_info =
                {
@@ -189,6 +287,7 @@ non_cfi_t non_cfi_flashes[] = {
                .dev_size = 1*MB,
                .interface_desc = 0x2,
                .max_buf_write_size = 0x0,
                .dev_size = 1*MB,
                .interface_desc = 0x2,
                .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7,
                .num_erase_regions = 4,
                .erase_region_info =
                {
                .num_erase_regions = 4,
                .erase_region_info =
                {
@@ -205,6 +304,7 @@ non_cfi_t non_cfi_flashes[] = {
                .dev_size = 1*MB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
                .dev_size = 1*MB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7,
                .num_erase_regions = 4,
                .erase_region_info =
                {
                .num_erase_regions = 4,
                .erase_region_info =
                {
@@ -222,6 +322,7 @@ non_cfi_t non_cfi_flashes[] = {
                .dev_size = 2*MB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
                .dev_size = 2*MB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7,
                .num_erase_regions = 4,
                .erase_region_info =
                {
                .num_erase_regions = 4,
                .erase_region_info =
                {
@@ -238,6 +339,7 @@ non_cfi_t non_cfi_flashes[] = {
                .dev_size = 2*MB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
                .dev_size = 2*MB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7,
                .num_erase_regions = 4,
                .erase_region_info =
                {
                .num_erase_regions = 4,
                .erase_region_info =
                {
@@ -247,19 +349,6 @@ non_cfi_t non_cfi_flashes[] = {
                        ERASE_REGION( 1, 16*KB)
                }
        },
                        ERASE_REGION( 1, 16*KB)
                }
        },
-       {
-               .mfr = CFI_MFR_SST,
-               .id = 0x2782,                           /* SST39xF160 */
-               .pri_id = 0x02,
-               .dev_size = 2*MB,
-               .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
-               .max_buf_write_size = 0x0,
-               .num_erase_regions = 1,
-               .erase_region_info =
-               {
-                       ERASE_REGION(512, 4*KB)
-               }
-       },
        {
                .mfr = CFI_MFR_ATMEL,
                .id = 0x00c0,                           /* Atmel 49BV1614 */
        {
                .mfr = CFI_MFR_ATMEL,
                .id = 0x00c0,                           /* Atmel 49BV1614 */
@@ -267,6 +356,7 @@ non_cfi_t non_cfi_flashes[] = {
                .dev_size = 2*MB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
                .dev_size = 2*MB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7,
                .num_erase_regions = 3,
                .erase_region_info =
                {
                .num_erase_regions = 3,
                .erase_region_info =
                {
@@ -282,6 +372,7 @@ non_cfi_t non_cfi_flashes[] = {
                .dev_size = 2*MB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
                .dev_size = 2*MB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7,
                .num_erase_regions = 3,
                .erase_region_info =
                {
                .num_erase_regions = 3,
                .erase_region_info =
                {
@@ -297,6 +388,7 @@ non_cfi_t non_cfi_flashes[] = {
                .dev_size = 1*MB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
                .dev_size = 1*MB,
                .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
                .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7,
                .num_erase_regions = 4,
                .erase_region_info =
                {
                .num_erase_regions = 4,
                .erase_region_info =
                {
@@ -358,6 +450,7 @@ void cfi_fixup_non_cfi(flash_bank_t *bank)
 
        cfi_info->interface_desc = non_cfi->interface_desc;
        cfi_info->max_buf_write_size = non_cfi->max_buf_write_size;
 
        cfi_info->interface_desc = non_cfi->interface_desc;
        cfi_info->max_buf_write_size = non_cfi->max_buf_write_size;
+       cfi_info->status_poll_mask = non_cfi->status_poll_mask;
        cfi_info->num_erase_regions = non_cfi->num_erase_regions;
        cfi_info->erase_region_info = non_cfi->erase_region_info;
        cfi_info->dev_size = non_cfi->dev_size;
        cfi_info->num_erase_regions = non_cfi->num_erase_regions;
        cfi_info->erase_region_info = non_cfi->erase_region_info;
        cfi_info->dev_size = non_cfi->dev_size;
index 19fef85302c96bb8cb9b6329e18cbc4b8f301147..e4b33d403d3274958de06d83fe763b47d1d6c2e3 100644 (file)
@@ -32,6 +32,7 @@ typedef struct non_cfi_s
        u16 max_buf_write_size;
        u8 num_erase_regions;
        u32 erase_region_info[6];
        u16 max_buf_write_size;
        u8 num_erase_regions;
        u32 erase_region_info[6];
+       u8  status_poll_mask;
 } non_cfi_t;
 
 extern non_cfi_t non_cfi_flashes[];
 } non_cfi_t;
 
 extern non_cfi_t non_cfi_flashes[];

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)