Add the target name to debug output for better understanding and error identification.
[openocd.git] / src / target / target.c
index dbac9a1fba0ebaf340a51ad191fb296e6a80cd1d..45b45770197d2bb569e034d1665a2ab5f9060748 100644 (file)
@@ -87,7 +87,7 @@ extern struct target_type dsp563xx_target;
 extern struct target_type dsp5680xx_target;
 extern struct target_type testee_target;
 extern struct target_type avr32_ap7k_target;
-extern struct target_type stm32_stlink_target;
+extern struct target_type hla_target;
 
 static struct target_type *target_types[] = {
        &arm7tdmi_target,
@@ -110,7 +110,7 @@ static struct target_type *target_types[] = {
        &dsp5680xx_target,
        &testee_target,
        &avr32_ap7k_target,
-       &stm32_stlink_target,
+       &hla_target,
        NULL,
 };
 
@@ -822,6 +822,7 @@ int target_run_flash_async_algorithm(struct target *target,
                uint32_t entry_point, uint32_t exit_point, void *arch_info)
 {
        int retval;
+       int timeout = 0;
 
        /* Set up working area. First word is write pointer, second word is read pointer,
         * rest is fifo data area. */
@@ -893,9 +894,19 @@ int target_run_flash_async_algorithm(struct target *target,
                         * less than buffer size / flash speed. This is very unlikely to
                         * run when using high latency connections such as USB. */
                        alive_sleep(10);
+
+                       /* to stop an infinite loop on some targets check and increment a timeout
+                        * this issue was observed on a stellaris using the new ICDI interface */
+                       if (timeout++ >= 500) {
+                               LOG_ERROR("timeout waiting for algorithm, a target reset is recommended");
+                               return ERROR_FLASH_OPERATION_FAILED;
+                       }
                        continue;
                }
 
+               /* reset our timeout */
+               timeout = 0;
+
                /* Limit to the amount of data we actually want to write */
                if (thisrun_bytes > count * block_size)
                        thisrun_bytes = count * block_size;
@@ -2237,7 +2248,8 @@ static int handle_target(void *priv)
                                        backoff_times *= 2;
                                        backoff_times++;
                                }
-                               LOG_USER("Polling target failed, GDB will be halted. Polling again in %dms",
+                               LOG_USER("Polling target %s failed, GDB will be halted. Polling again in %dms",
+                                               target_name(target),
                                                backoff_times * polling_interval);
 
                                /* Tell GDB to halt the debugger. This allows the user to
@@ -2248,7 +2260,7 @@ static int handle_target(void *priv)
                        }
                        /* Since we succeeded, we reset backoff count */
                        if (backoff_times > 0)
-                               LOG_USER("Polling succeeded again");
+                               LOG_USER("Polling target %s succeeded again", target_name(target));
                        backoff_times = 0;
                }
        }
@@ -4447,32 +4459,32 @@ static int jim_target_md(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
                        return JIM_ERR;
                }
 
-               command_print(NULL, "0x%08x ", (int)(addr));
+               command_print_sameline(NULL, "0x%08x ", (int)(addr));
                switch (dwidth) {
                case 4:
                        for (x = 0; x < 16 && x < y; x += 4) {
                                z = target_buffer_get_u32(target, &(target_buf[x]));
-                               command_print(NULL, "%08x ", (int)(z));
+                               command_print_sameline(NULL, "%08x ", (int)(z));
                        }
                        for (; (x < 16) ; x += 4)
-                               command_print(NULL, "         ");
+                               command_print_sameline(NULL, "         ");
                        break;
                case 2:
                        for (x = 0; x < 16 && x < y; x += 2) {
                                z = target_buffer_get_u16(target, &(target_buf[x]));
-                               command_print(NULL, "%04x ", (int)(z));
+                               command_print_sameline(NULL, "%04x ", (int)(z));
                        }
                        for (; (x < 16) ; x += 2)
-                               command_print(NULL, "     ");
+                               command_print_sameline(NULL, "     ");
                        break;
                case 1:
                default:
                        for (x = 0 ; (x < 16) && (x < y) ; x += 1) {
                                z = target_buffer_get_u8(target, &(target_buf[x]));
-                               command_print(NULL, "%02x ", (int)(z));
+                               command_print_sameline(NULL, "%02x ", (int)(z));
                        }
                        for (; (x < 16) ; x += 1)
-                               command_print(NULL, "   ");
+                               command_print_sameline(NULL, "   ");
                        break;
                }
                /* ascii-ify the bytes */
@@ -4493,7 +4505,7 @@ static int jim_target_md(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
                /* terminate */
                target_buf[16] = 0;
                /* print - with a newline */
-               command_print(NULL, "%s\n", target_buf);
+               command_print_sameline(NULL, "%s\n", target_buf);
                /* NEXT... */
                bytes -= 16;
                addr += 16;
@@ -4898,6 +4910,15 @@ static int target_create(Jim_GetOptInfo *goi)
                        /* found */
                        break;
                }
+
+               /* check for deprecated name */
+               if (target_types[x]->deprecated_name) {
+                       if (0 == strcmp(cp, target_types[x]->deprecated_name)) {
+                               /* found */
+                               LOG_WARNING("target name is deprecated use: \'%s\'", target_types[x]->name);
+                               break;
+                       }
+               }
        }
        if (target_types[x] == NULL) {
                Jim_SetResultFormatted(goi->interp, "Unknown target type %s, try one of ", cp);
@@ -5131,8 +5152,10 @@ static int jim_target_smp(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
                target->head = head;
                curr = curr->next;
        }
-       if (target->rtos)
+
+       if (target && target->rtos)
                retval = rtos_smp_init(head->target);
+
        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)