add overridable Tcl "init_reset"
[openocd.git] / src / target / arm11.c
index f060da965a1db74dd32e9937c0c9e2dd75c16b1c..b840eb086dd0d48c1bdf9208a54216c4a10226b2 100644 (file)
@@ -29,6 +29,7 @@
 #include "arm11.h"
 #include "armv4_5.h"
 #include "arm_simulator.h"
+#include "time_support.h"
 #include "target_type.h"
 
 
@@ -768,12 +769,29 @@ int arm11_halt(struct target_s *target)
 
        uint32_t dscr;
 
+       int i = 0;
        while (1)
        {
                CHECK_RETVAL(arm11_read_DSCR(arm11, &dscr));
 
                if (dscr & ARM11_DSCR_CORE_HALTED)
                        break;
+
+
+               long long then = 0;
+               if (i == 1000)
+               {
+                       then = timeval_ms();
+               }
+               if (i >= 1000)
+               {
+                       if ((timeval_ms()-then) > 1000)
+                       {
+                               LOG_WARNING("Timeout (1000ms) waiting for instructions to complete");
+                               return ERROR_FAIL;
+                       }
+               }
+               i++;
        }
 
        arm11_on_enter_debug_state(arm11);
@@ -865,6 +883,7 @@ int arm11_resume(struct target_s *target, int current, uint32_t address, int han
 
        CHECK_RETVAL(jtag_execute_queue());
 
+       int i = 0;
        while (1)
        {
                uint32_t dscr;
@@ -875,6 +894,22 @@ int arm11_resume(struct target_s *target, int current, uint32_t address, int han
 
                if (dscr & ARM11_DSCR_CORE_RESTARTED)
                        break;
+
+
+               long long then = 0;
+               if (i == 1000)
+               {
+                       then = timeval_ms();
+               }
+               if (i >= 1000)
+               {
+                       if ((timeval_ms()-then) > 1000)
+                       {
+                               LOG_WARNING("Timeout (1000ms) waiting for instructions to complete");
+                               return ERROR_FAIL;
+                       }
+               }
+               i++;
        }
 
        if (!debug_execution)
@@ -1088,10 +1123,8 @@ int arm11_step(struct target_s *target, int current, uint32_t address, int handl
 
                CHECK_RETVAL(jtag_execute_queue());
 
-               /** \todo TODO: add a timeout */
-
                /* wait for halt */
-
+               int i = 0;
                while (1)
                {
                        uint32_t dscr;
@@ -1103,6 +1136,21 @@ int arm11_step(struct target_s *target, int current, uint32_t address, int handl
                        if ((dscr & (ARM11_DSCR_CORE_RESTARTED | ARM11_DSCR_CORE_HALTED)) ==
                                (ARM11_DSCR_CORE_RESTARTED | ARM11_DSCR_CORE_HALTED))
                                break;
+
+                       long long then = 0;
+                       if (i == 1000)
+                       {
+                               then = timeval_ms();
+                       }
+                       if (i >= 1000)
+                       {
+                               if ((timeval_ms()-then) > 1000)
+                               {
+                                       LOG_WARNING("Timeout (1000ms) waiting for instructions to complete");
+                                       return ERROR_FAIL;
+                               }
+                       }
+                       i++;
                }
 
                /* clear breakpoint */
@@ -1386,7 +1434,8 @@ int arm11_write_memory(struct target_s *target, uint32_t address, uint32_t size,
 
                if (address + size * count != r0)
                {
-                       LOG_ERROR("Data transfer failed. (%d)", (int)((r0 - address) - size * count));
+                       LOG_ERROR("Data transfer failed. Expected end address 0x%08x, got 0x%08x",
+                                       address + size * count, r0);
 
                        if (arm11_config_memwrite_burst)
                                LOG_ERROR("use 'arm11 memwrite burst disable' to disable fast burst mode");
@@ -1936,9 +1985,6 @@ const uint32_t arm11_coproc_instruction_limits[] =
        0xFFFFFFFF,             /* value */
 };
 
-const char arm11_mrc_syntax[] = "Syntax: mrc <jtag_target> <coprocessor> <opcode 1> <CRn> <CRm> <opcode 2>. All parameters are numbers only.";
-const char arm11_mcr_syntax[] = "Syntax: mcr <jtag_target> <coprocessor> <opcode 1> <CRn> <CRm> <opcode 2> <32bit value to write>. All parameters are numbers only.";
-
 arm11_common_t * arm11_find_target(const char * arg)
 {
        jtag_tap_t *    tap;
@@ -1966,18 +2012,16 @@ int arm11_handle_mrc_mcr(struct command_context_s *cmd_ctx, char *cmd, char **ar
 {
        if (argc != (read ? 6 : 7))
        {
-               LOG_ERROR("Invalid number of arguments. %s", read ? arm11_mrc_syntax : arm11_mcr_syntax);
-               return -1;
+               LOG_ERROR("Invalid number of arguments.");
+               return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        arm11_common_t * arm11 = arm11_find_target(args[0]);
 
        if (!arm11)
        {
-               LOG_ERROR("Parameter 1 is not a the JTAG chain position of an ARM11 device. %s",
-                       read ? arm11_mrc_syntax : arm11_mcr_syntax);
-
-               return -1;
+               LOG_ERROR("Parameter 1 is not a the JTAG chain position of an ARM11 device.");
+               return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        if (arm11->target->state != TARGET_HALTED)
@@ -1994,11 +2038,10 @@ int arm11_handle_mrc_mcr(struct command_context_s *cmd_ctx, char *cmd, char **ar
 
                if (values[i] > arm11_coproc_instruction_limits[i])
                {
-                       LOG_ERROR("Parameter %ld out of bounds (%" PRId32 " max). %s",
+                       LOG_ERROR("Parameter %ld out of bounds (%" PRId32 " max).",
                                  (long)(i + 2),
-                                 arm11_coproc_instruction_limits[i],
-                               read ? arm11_mrc_syntax : arm11_mcr_syntax);
-                       return -1;
+                                 arm11_coproc_instruction_limits[i]);
+                       return ERROR_COMMAND_SYNTAX_ERROR;
                }
        }
 
@@ -2072,7 +2115,7 @@ int arm11_register_commands(struct command_context_s *cmd_ctx)
 
        register_command(cmd_ctx, top_cmd, "mcr",
                        arm11_handle_mcr, COMMAND_ANY,
-                       "Write Coprocessor register");
+                       "Write Coprocessor register. mcr <jtag_target> <coprocessor> <opcode 1> <CRn> <CRm> <opcode 2> <32bit value to write>. All parameters are numbers only.");
 
        mw_cmd = register_command(cmd_ctx, top_cmd, "memwrite",
                        NULL, COMMAND_ANY, NULL);
@@ -2087,7 +2130,7 @@ int arm11_register_commands(struct command_context_s *cmd_ctx)
 
        register_command(cmd_ctx, top_cmd, "mrc",
                        arm11_handle_mrc, COMMAND_ANY,
-                       "Read Coprocessor register");
+                       "Read Coprocessor register. mrc <jtag_target> <coprocessor> <opcode 1> <CRn> <CRm> <opcode 2>. All parameters are numbers only.");
        register_command(cmd_ctx, top_cmd, "no_increment",
                        arm11_handle_bool_memrw_no_increment, COMMAND_ANY,
                        "Don't increment address on multi-read/-write"

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)