aboutsummaryrefslogtreecommitdiff
path: root/src/target/target.c
diff options
context:
space:
mode:
authorSpencer Oliver <spen@spen-soft.co.uk>2012-11-05 13:04:15 +0000
committerSpencer Oliver <spen@spen-soft.co.uk>2012-11-06 17:38:37 +0000
commit5c2c269336cc49aa3ea7714d0ffcc4b2edf3057e (patch)
tree138c4011e006e9a3a7f8129fd968980dfd9a93b6 /src/target/target.c
parenta72a42230be9a479dd93687d99d39b9029acb50a (diff)
downloadriscv-openocd-5c2c269336cc49aa3ea7714d0ffcc4b2edf3057e.zip
riscv-openocd-5c2c269336cc49aa3ea7714d0ffcc4b2edf3057e.tar.gz
riscv-openocd-5c2c269336cc49aa3ea7714d0ffcc4b2edf3057e.tar.bz2
target: add async algorithm timeout
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>
Diffstat (limited to 'src/target/target.c')
-rw-r--r--src/target/target.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/target/target.c b/src/target/target.c
index b8e4c2f..6d3a99d 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -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;