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
This commit is contained in:
Aleksey Shargalin 2017-10-31 17:23:40 +03:00 committed by Antonio Borneo
parent 65fc586d6e
commit 8df529fa66
3 changed files with 6 additions and 0 deletions

View File

@ -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:

View File

@ -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;

View File

@ -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)