fix flash bank auto_probe() fail with multiple targets 13/1813/2
authorSergey A. Borshch <sb-sf@users.sourceforge.net>
Fri, 22 Nov 2013 15:27:40 +0000 (17:27 +0200)
committerAndreas Fritiofson <andreas.fritiofson@gmail.com>
Tue, 17 Dec 2013 23:04:01 +0000 (23:04 +0000)
  get_flash_bank_by_addr() iterates through all flash banks
trying to auto_probe() every bank, even if bank can belongs to
target other than requested, and this other target can be
in non-halted state, which leads to error message and
operation abort.
  Same situation in gdb_new_connection() and gdb_memory_map():
get_flash_bank_by_num() tries to auto_probe() requested bank,
so first get bank by get_flash_bank_by_num_noprobe(), check
if it belongs to current connection's target and skip
get_flash_bank_by_num() (actually autoprobing) if not.

Change-Id: I48b3f93dddcd9283394f14ad2de3248397c75ab3
Signed-off-by: Sergey A. Borshch <sb-sf@users.sourceforge.net>
Reviewed-on: http://openocd.zylin.com/1813
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
src/flash/nor/core.c
src/server/gdb_server.c

index cc2ecac08538a7c413826c14af1473224561a4ea..4410d5c6a20df9dd0036953cb0bb0ab3457e0d71 100644 (file)
@@ -232,6 +232,9 @@ int get_flash_bank_by_addr(struct target *target,
 
        /* cycle through bank list */
        for (c = flash_banks; c; c = c->next) {
+               if (c->target != target)
+                       continue;
+
                int retval;
                retval = c->driver->auto_probe(c);
 
@@ -240,7 +243,7 @@ int get_flash_bank_by_addr(struct target *target,
                        return retval;
                }
                /* check whether address belongs to this flash bank */
-               if ((addr >= c->base) && (addr <= c->base + (c->size - 1)) && target == c->target) {
+               if ((addr >= c->base) && (addr <= c->base + (c->size - 1))) {
                        *result_bank = c;
                        return ERROR_OK;
                }
index c578780c8d374cc865c3d2de90a7d2dc95894682..28cb3ab71baaa42f2a31f9bb7cfd34a877543e79 100644 (file)
@@ -957,6 +957,9 @@ static int gdb_new_connection(struct connection *connection)
                int i;
                for (i = 0; i < flash_get_bank_count(); i++) {
                        struct flash_bank *p;
+                       p = get_flash_bank_by_num_noprobe(i);
+                       if (p->target != gdb_service->target)
+                               continue;
                        retval = get_flash_bank_by_num(i, &p);
                        if (retval != ERROR_OK) {
                                LOG_ERROR("Connect failed. Consider setting up a gdb-attach event for the target " \
@@ -1732,14 +1735,16 @@ static int gdb_memory_map(struct connection *connection,
        banks = malloc(sizeof(struct flash_bank *)*flash_get_bank_count());
 
        for (i = 0; i < flash_get_bank_count(); i++) {
+               p = get_flash_bank_by_num_noprobe(i);
+               if (p->target != target)
+                       continue;
                retval = get_flash_bank_by_num(i, &p);
                if (retval != ERROR_OK) {
                        free(banks);
                        gdb_error(connection, retval);
                        return retval;
                }
-               if (p->target == target)
-                       banks[target_flash_banks++] = p;
+               banks[target_flash_banks++] = p;
        }
 
        qsort(banks, target_flash_banks, sizeof(struct flash_bank *),

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)