flash/jtagspi: sending command and setting parameters without probing.
[openocd.git] / src / flash / nor / jtagspi.c
index 0047d22bb7df01950f171382417d98decc74bd5c..866548a7e0148b44c71d5d5e0622145b37a6b6d3 100644 (file)
@@ -41,7 +41,11 @@ FLASH_BANK_COMMAND_HANDLER(jtagspi_flash_bank_command)
        bank->sectors = NULL;
        bank->driver_priv = info;
 
-       info->tap = NULL;
+       if (!bank->target->tap) {
+               LOG_ERROR("Target has no JTAG tap");
+               return ERROR_FAIL;
+       }
+       info->tap = bank->target->tap;
        info->probed = false;
        COMMAND_PARSE_NUMBER(u32, CMD_ARGV[6], info->ir);
 
@@ -161,7 +165,12 @@ COMMAND_HANDLER(jtagspi_handle_set)
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
-       retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
+       /* calling flash_command_get_bank without probing because handle_set is used
+          to set device parameters if not autodetected. So probing would fail
+          anyhow.
+       */
+       retval = CALL_COMMAND_HANDLER(flash_command_get_bank_probe_optional, 0,
+               &bank, false);
        if (ERROR_OK != retval)
                return retval;
        info = bank->driver_priv;
@@ -312,7 +321,13 @@ COMMAND_HANDLER(jtagspi_handle_cmd)
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
-       retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
+       /* calling flash_command_get_bank without probing because we like to be
+          able to send commands before auto-probing occurred. For example sending
+          "release from power down" is needed before probing when flash is in
+          power down mode.
+        */
+       retval = CALL_COMMAND_HANDLER(flash_command_get_bank_probe_optional, 0,
+                                                               &bank, false);
        if (ERROR_OK != retval)
                return retval;
 
@@ -381,12 +396,6 @@ static int jtagspi_probe(struct flash_bank *bank)
        }
        info->probed = false;
 
-       if (!bank->target->tap) {
-               LOG_ERROR("Target has no JTAG tap");
-               return ERROR_FAIL;
-       }
-       info->tap = bank->target->tap;
-
        jtagspi_cmd(bank, SPIFLASH_READ_ID, NULL, 0, in_buf, -3);
        /* the table in spi.c has the manufacturer byte (first) as the lsb */
        id = le_to_h_u24(in_buf);

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)