remote_bitbang: Add SWD support
This adds new command characters to make SWD work with the new split
jtag and swd operations of bitbang.
The command characters are as follows:
O - SWDIO drive 1
o - SWDIO drive 0
c - SWDIO read request
d - SWD write 0 0
e - SWD write 0 1
f - SWD write 1 0
g - SWD write 1 1
Documentation has been updated accordingly. The new commands will be
used by an adapted version of the jtag-openocd applet of the "Glasgow
Debug Tool" (https://github.com/glasgowEmbedded/Glasgow). It has been
tested against an stm32f103 and an at91samd21 target.
contrib/remote/bitbang/remote_bitbang_sysfsgpio.c has also been adapted
to support SWD via the new command set. Some limited testing has been
done using a Raspberry Pi 2 with an stm32f103 and an at91samd21 target
attached.
Change-Id: I8e998a2cb36905142cb16e534483094cd99e8fa7
Signed-off-by: Manuel Wick <manuel@matronix.de>
Signed-off-by: David Ryskalczyk <david.rysk@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6044
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2011 by Richard Uhler *
|
||||
* ruhler@mit.edu *
|
||||
* *
|
||||
* Copyright (C) 2021 by Manuel Wick <manuel@matronix.de> *
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -220,11 +222,35 @@ static int remote_bitbang_blink(int on)
|
||||
return remote_bitbang_queue(c, FLUSH_SEND_BUF);
|
||||
}
|
||||
|
||||
static void remote_bitbang_swdio_drive(bool is_output)
|
||||
{
|
||||
char c = is_output ? 'O' : 'o';
|
||||
if (remote_bitbang_queue(c, FLUSH_SEND_BUF) == ERROR_FAIL)
|
||||
LOG_ERROR("Error setting direction for swdio");
|
||||
}
|
||||
|
||||
static int remote_bitbang_swdio_read(void)
|
||||
{
|
||||
if (remote_bitbang_queue('c', FLUSH_SEND_BUF) != ERROR_FAIL)
|
||||
return remote_bitbang_read_sample();
|
||||
else
|
||||
return BB_ERROR;
|
||||
}
|
||||
|
||||
static int remote_bitbang_swd_write(int swclk, int swdio)
|
||||
{
|
||||
char c = 'd' + ((swclk ? 0x2 : 0x0) | (swdio ? 0x1 : 0x0));
|
||||
return remote_bitbang_queue(c, NO_FLUSH);
|
||||
}
|
||||
|
||||
static struct bitbang_interface remote_bitbang_bitbang = {
|
||||
.buf_size = sizeof(remote_bitbang_recv_buf) - 1,
|
||||
.sample = &remote_bitbang_sample,
|
||||
.read_sample = &remote_bitbang_read_sample,
|
||||
.write = &remote_bitbang_write,
|
||||
.swdio_read = &remote_bitbang_swdio_read,
|
||||
.swdio_drive = &remote_bitbang_swdio_drive,
|
||||
.swd_write = &remote_bitbang_swd_write,
|
||||
.blink = &remote_bitbang_blink,
|
||||
};
|
||||
|
||||
@@ -349,6 +375,8 @@ COMMAND_HANDLER(remote_bitbang_handle_remote_bitbang_host_command)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
static const char * const remote_bitbang_transports[] = { "jtag", "swd", NULL };
|
||||
|
||||
static const struct command_registration remote_bitbang_subcommand_handlers[] = {
|
||||
{
|
||||
.name = "port",
|
||||
@@ -401,7 +429,7 @@ static struct jtag_interface remote_bitbang_interface = {
|
||||
|
||||
struct adapter_driver remote_bitbang_adapter_driver = {
|
||||
.name = "remote_bitbang",
|
||||
.transports = jtag_only,
|
||||
.transports = remote_bitbang_transports,
|
||||
.commands = remote_bitbang_command_handlers,
|
||||
|
||||
.init = &remote_bitbang_init,
|
||||
@@ -409,4 +437,5 @@ struct adapter_driver remote_bitbang_adapter_driver = {
|
||||
.reset = &remote_bitbang_reset,
|
||||
|
||||
.jtag_ops = &remote_bitbang_interface,
|
||||
.swd_ops = &bitbang_swd,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user