target: add async algorithm timeout 49/949/3
authorSpencer Oliver <spen@spen-soft.co.uk>
Mon, 5 Nov 2012 13:04:15 +0000 (13:04 +0000)
committerSpencer Oliver <spen@spen-soft.co.uk>
Tue, 6 Nov 2012 17:38:37 +0000 (17:38 +0000)
An issue was observed when using an async algorithm with a target that had
not been previously reset beforehand. The target would enter a infinite
loop within target_run_flash_async_algorithm.

Add a timeout that will at least prevent this issue from happening. and also
suggest the user resets the target.

Change-Id: I5277e0d64e252d3d353e8d5bc9889a37fdc63060
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/949
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
src/target/target.c

index b8e4c2ff9ed937dc0720b2f98634a3c6923aa074..6d3a99decd8adc9031124c8506a9411601ad7e86 100644 (file)
@@ -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;
                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. */
 
        /* 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);
                         * 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;
                }
 
                        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;
                /* Limit to the amount of data we actually want to write */
                if (thisrun_bytes > count * block_size)
                        thisrun_bytes = count * block_size;

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)