diff options
author | Aleksey Shargalin <myokaski@gmail.com> | 2017-10-31 17:23:40 +0300 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2023-12-30 13:10:08 +0000 |
commit | 8df529fa663cef2004a6a26e8f147b8c96e03de9 (patch) | |
tree | 5f0c654c765af0977383924b00699d6d45bf94ce | |
parent | 65fc586d6ee18813937ec0fdb264b9e0d4bc1c76 (diff) | |
download | riscv-openocd-8df529fa663cef2004a6a26e8f147b8c96e03de9.zip riscv-openocd-8df529fa663cef2004a6a26e8f147b8c96e03de9.tar.gz riscv-openocd-8df529fa663cef2004a6a26e8f147b8c96e03de9.tar.bz2 |
bitbang: Add flush before sleep
Some bitbang interfaces have no speed regulation and work as fast as
they can. Only the sequence of execuded commands is guaranteed but
not the timing. It works most of time with one exception: when the
JTAG_SLEEP command is executed, we expect that all previous commands
already finished so that the sleep interval is guaranteed.
For now there may be situations when the sleep time has passed but
previous commands are not actually executed.
This patch adds a flush command to the bitbang interface, connects it
to the existing implementation for remote_bitbang, and runs it when
the JTAG_SLEEP command is executed.
Change-Id: If40894a63d29a260a4ded134b008df6dd1e89c46
Signed-off-by: Aleksey Shargalin <myokaski@gmail.com>
Signed-off-by: David Ryskalczyk <david.rysk@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/4284
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
-rw-r--r-- | src/jtag/drivers/bitbang.c | 2 | ||||
-rw-r--r-- | src/jtag/drivers/bitbang.h | 3 | ||||
-rw-r--r-- | src/jtag/drivers/remote_bitbang.c | 1 |
3 files changed, 6 insertions, 0 deletions
diff --git a/src/jtag/drivers/bitbang.c b/src/jtag/drivers/bitbang.c index 6e97d15..186d209 100644 --- a/src/jtag/drivers/bitbang.c +++ b/src/jtag/drivers/bitbang.c @@ -360,6 +360,8 @@ int bitbang_execute_queue(void) break; case JTAG_SLEEP: LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us); + if (bitbang_interface->flush && (bitbang_interface->flush() != ERROR_OK)) + return ERROR_FAIL; bitbang_sleep(cmd->cmd.sleep->us); break; case JTAG_TMS: diff --git a/src/jtag/drivers/bitbang.h b/src/jtag/drivers/bitbang.h index e3714df..097a5c0 100644 --- a/src/jtag/drivers/bitbang.h +++ b/src/jtag/drivers/bitbang.h @@ -57,6 +57,9 @@ struct bitbang_interface { /** Sleep for some number of microseconds. **/ int (*sleep)(unsigned int microseconds); + + /** Force a flush. */ + int (*flush)(void); }; extern const struct swd_driver bitbang_swd; diff --git a/src/jtag/drivers/remote_bitbang.c b/src/jtag/drivers/remote_bitbang.c index c488f83..6d0fba2 100644 --- a/src/jtag/drivers/remote_bitbang.c +++ b/src/jtag/drivers/remote_bitbang.c @@ -281,6 +281,7 @@ static struct bitbang_interface remote_bitbang_bitbang = { .swd_write = &remote_bitbang_swd_write, .blink = &remote_bitbang_blink, .sleep = &remote_bitbang_sleep, + .flush = &remote_bitbang_flush, }; static int remote_bitbang_init_tcp(void) |