SPI table updates (some new devices and new info)
[openocd.git] / src / flash / nor / jtagspi.c
index c5c565f2a19301f8a602fea1166126ffb6a9d6b0..0750fdfd5039d07ec0e45081bcf14e856c17499f 100644 (file)
@@ -166,7 +166,7 @@ static int jtagspi_probe(struct flash_bank *bank)
        struct jtagspi_flash_bank *info = bank->driver_priv;
        struct flash_sector *sectors;
        uint8_t in_buf[3];
-       uint32_t id;
+       uint32_t id, sectorsize;
 
        if (info->probed)
                free(bank->sectors);
@@ -199,10 +199,17 @@ static int jtagspi_probe(struct flash_bank *bank)
 
        /* Set correct size value */
        bank->size = info->dev->size_in_bytes;
+       if (bank->size <= (1UL << 16))
+               LOG_WARNING("device needs 2-byte addresses - not implemented");
+       if (bank->size > (1UL << 24))
+               LOG_WARNING("device needs paging or 4-byte addresses - not implemented");
+
+       /* if no sectors, treat whole bank as single sector */
+       sectorsize = info->dev->sectorsize ?
+               info->dev->sectorsize : info->dev->size_in_bytes;
 
        /* create and fill sectors array */
-       bank->num_sectors =
-               info->dev->size_in_bytes / info->dev->sectorsize;
+       bank->num_sectors = info->dev->size_in_bytes / sectorsize;
        sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
        if (sectors == NULL) {
                LOG_ERROR("not enough memory");
@@ -210,8 +217,8 @@ static int jtagspi_probe(struct flash_bank *bank)
        }
 
        for (int sector = 0; sector < bank->num_sectors; sector++) {
-               sectors[sector].offset = sector * info->dev->sectorsize;
-               sectors[sector].size = info->dev->sectorsize;
+               sectors[sector].offset = sector * sectorsize;
+               sectors[sector].size = sectorsize;
                sectors[sector].is_erased = -1;
                sectors[sector].is_protected = 0;
        }
@@ -269,6 +276,9 @@ static int jtagspi_bulk_erase(struct flash_bank *bank)
        int retval;
        int64_t t0 = timeval_ms();
 
+       if (info->dev->chip_erase_cmd == 0x00)
+               return ERROR_FLASH_OPER_UNSUPPORTED;
+
        retval = jtagspi_write_enable(bank);
        if (retval != ERROR_OK)
                return retval;
@@ -328,6 +338,9 @@ static int jtagspi_erase(struct flash_bank *bank, int first, int last)
                        LOG_WARNING("Bulk flash erase failed. Falling back to sector erase.");
        }
 
+       if (info->dev->erase_cmd == 0x00)
+               return ERROR_FLASH_OPER_UNSUPPORTED;
+
        for (sector = first; sector <= last; sector++) {
                retval = jtagspi_sector_erase(bank, sector);
                if (retval != ERROR_OK) {
@@ -376,16 +389,19 @@ static int jtagspi_write(struct flash_bank *bank, const uint8_t *buffer, uint32_
 {
        struct jtagspi_flash_bank *info = bank->driver_priv;
        int retval;
-       uint32_t n;
+       uint32_t n, pagesize;
 
        if (!(info->probed)) {
                LOG_ERROR("Flash bank not yet probed.");
                return ERROR_FLASH_BANK_NOT_PROBED;
        }
 
-       for (n = 0; n < count; n += info->dev->pagesize) {
+       /* if no write pagesize, use reasonable default */
+       pagesize = info->dev->pagesize ? info->dev->pagesize : SPIFLASH_DEF_PAGESIZE;
+
+       for (n = 0; n < count; n += pagesize) {
                retval = jtagspi_page_write(bank, buffer + n, offset + n,
-                               MIN(count - n, info->dev->pagesize));
+                               MIN(count - n, pagesize));
                if (retval != ERROR_OK) {
                        LOG_ERROR("page write error");
                        return retval;

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)