This is an automated email from Gerrit. Manuel Wick (man...@matronix.de) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/6044
-- gerrit commit 9ce02df52e47b812baad19cdc91dbef4d90deb8d Author: Manuel Wick <man...@matronix.de> Date: Sat Jan 30 22:46:50 2021 +0100 remote_bitbang: Add SWD support This adds the 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 (swd_drive) 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. Change-Id: I8e998a2cb36905142cb16e534483094cd99e8fa7 Signed-off-by: Manuel Wick <man...@matronix.de> diff --git a/doc/manual/jtag/drivers/remote_bitbang.txt b/doc/manual/jtag/drivers/remote_bitbang.txt index f394d73..5f4fd1b 100644 --- a/doc/manual/jtag/drivers/remote_bitbang.txt +++ b/doc/manual/jtag/drivers/remote_bitbang.txt @@ -1,15 +1,19 @@ /** @remote_bitbangpage OpenOCD Developer's Guide -The remote_bitbang JTAG driver is used to drive JTAG from a remote process. The -remote_bitbang driver communicates via TCP or UNIX sockets with some remote -process using an ASCII encoding of the bitbang interface. The remote process -presumably then drives the JTAG however it pleases. The remote process should -act as a server, listening for connections from the openocd remote_bitbang -driver. +The remote_bitbang JTAG+SWD driver is used to drive JTAG and/or SWD from a +remote process. The remote_bitbang driver communicates via TCP or UNIX +sockets with some remote process using an ASCII encoding of the bitbang +interface. The remote process presumably then drives the JTAG/SWD however +it pleases. The remote process should act as a server, listening for +connections from the openocd remote_bitbang driver. The remote bitbang driver is useful for debugging software running on processors which are being simulated. +There also is an implementation of the server-side protocol for the +Glasgow Debug Tool (https://github.com/glasgowEmbedded/Glasgow) through +the jtag-openocd applet. + The bitbang interface consists of the following functions. blink on @@ -24,11 +28,20 @@ write tck tms tdi reset trst srst Set the value of trst, srst. +swdio_drive + Set the output enable of the bidirectional swdio (tms) pin + +swdio_read + Sample the value of swdio (tms). + +swd_write + Set the value of swclk (tck) and swdio (tms). + An additional function, quit, is added to the remote_bitbang interface to indicate there will be no more requests and the connection with the remote driver should be closed. -These five functions are encoded in ASCII by assigning a single character to +These eight functions are encoded in ASCII by assigning a single character to each possible request. The assignments are: B - Blink on @@ -47,7 +60,14 @@ each possible request. The assignments are: s - Reset 0 1 t - Reset 1 0 u - Reset 1 1 + O - SWDIO drive 1 (swd_drive) + 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 -The read response is encoded in ASCII as either digit 0 or 1. +The read responses are encoded in ASCII as either digit 0 or 1. */ diff --git a/src/jtag/drivers/remote_bitbang.c b/src/jtag/drivers/remote_bitbang.c index 6637952..62366d3 100644 --- a/src/jtag/drivers/remote_bitbang.c +++ b/src/jtag/drivers/remote_bitbang.c @@ -2,6 +2,8 @@ * Copyright (C) 2011 by Richard Uhler * * ruh...@mit.edu * * * + * Copyright (C) 2021 by Manuel Wick <man...@matronix.de> * + * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * @@ -194,11 +196,35 @@ static int remote_bitbang_blink(int on) return remote_bitbang_putc(c); } +static void remote_bitbang_swdio_drive(bool is_output) +{ + char c = is_output ? 'O' : 'o'; + if (0 != remote_bitbang_putc(c)) + LOG_ERROR("Error setting direction for swdio"); +} + +static int remote_bitbang_swdio_read(void) +{ + if (BB_ERROR != remote_bitbang_putc('c')) + return remote_bitbang_rread(); + 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_putc(c); +} + static struct bitbang_interface remote_bitbang_bitbang = { .buf_size = sizeof(remote_bitbang_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, }; @@ -321,6 +347,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_command_handlers[] = { { .name = "remote_bitbang_port", @@ -347,7 +375,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, @@ -355,4 +383,5 @@ struct adapter_driver remote_bitbang_adapter_driver = { .reset = &remote_bitbang_reset, .jtag_ops = &remote_bitbang_interface, + .swd_ops = &bitbang_swd, }; -- _______________________________________________ OpenOCD-devel mailing list OpenOCD-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openocd-devel