From 8df529fa663cef2004a6a26e8f147b8c96e03de9 Mon Sep 17 00:00:00 2001 From: Aleksey Shargalin Date: Tue, 31 Oct 2017 17:23:40 +0300 Subject: 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 Signed-off-by: David Ryskalczyk Reviewed-on: https://review.openocd.org/c/openocd/+/4284 Reviewed-by: Antonio Borneo Tested-by: jenkins --- src/jtag/drivers/bitbang.c | 2 ++ src/jtag/drivers/bitbang.h | 3 +++ src/jtag/drivers/remote_bitbang.c | 1 + 3 files changed, 6 insertions(+) (limited to 'src/jtag') 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) -- cgit v1.1