aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2022-09-23 09:49:50 -0700
committerGitHub <noreply@github.com>2022-09-23 09:49:50 -0700
commit8bb25e007972a153653d3437e63bb50eb8e916e2 (patch)
tree7405e399920d50e71e23ddb85bcd94b5a5b26115
parentb3d64741c2923090bf8fba487450baf175632f24 (diff)
parent4b0379fa16d170d99f2bb303acb972ed92310bbf (diff)
downloadriscv-openocd-8bb25e007972a153653d3437e63bb50eb8e916e2.zip
riscv-openocd-8bb25e007972a153653d3437e63bb50eb8e916e2.tar.gz
riscv-openocd-8bb25e007972a153653d3437e63bb50eb8e916e2.tar.bz2
Merge pull request #729 from mrv96/patch-1
Support for custom TMSC buffer: cJTAG OScan1 improvement
-rw-r--r--doc/openocd.texi19
-rw-r--r--src/jtag/drivers/ftdi.c16
-rw-r--r--tcl/interface/ftdi/digilent-hs2-cjtag.cfg19
3 files changed, 51 insertions, 3 deletions
diff --git a/doc/openocd.texi b/doc/openocd.texi
index 73f53c2..6aa1c49 100644
--- a/doc/openocd.texi
+++ b/doc/openocd.texi
@@ -2583,10 +2583,23 @@ and initially asserted reset signals.
@end deffn
@deffn {Command} {ftdi oscan1_mode} on|off
-Enable or disable OSCAN1 mode. This mode is intended for use with an adapter,
+Enable or disable OScan1 mode. This mode is intended for use with an adapter,
such as the ARM-JTAG-SWD by Olimex, that sits in between the FTDI chip and the
-target. The adapter uses the normal JTAG signals to control TCKC and TMSC
-(bidirectional) signals used in 2-wire cJTAG.
+target. The cJTAG prococol is composed of two wires: TCKC (clock) and TMSC (data).
+TMSC is a bidirectional signal which is time-multiplexed alternating TDI, TMS and
+TDO. The multiplexing is achieved by a tri-state buffer which puts TMSC in Hi-Z
+when the device is supposed to take the control of the line (TDO phase).
+
+The ARM-JTAG-SWD adapter uses standard TRST and TMS signals to control TMSC
+direction. TRST is used by the adapter as selector for the multiplexers which set
+the JTAG probe in 2-wire mode. Whatever signal is used for this purpose, it must
+be defined with the name JTAG_SEL using @command{ftdi layout_signal}. JTAG_SEL is
+set to 0 during OScan1 initialization.
+
+Some JTAG probes like the Digilent JTAG-HS2, support cJTAG by using a
+separate pin to control when TMS is driven onto TMSC. You can use such
+probes by defining the signal TMSC_EN using
+@command{ftdi layout_signal TMSC_EN -data <mask>}.
@end deffn
@deffn {Command} {ftdi layout_signal} name [@option{-data}|@option{-ndata} data_mask] [@option{-input}|@option{-ninput} input_mask] [@option{-oe}|@option{-noe} oe_mask] [@option{-alias}|@option{-nalias} name]
diff --git a/src/jtag/drivers/ftdi.c b/src/jtag/drivers/ftdi.c
index 2ecff7f..9eb1994 100644
--- a/src/jtag/drivers/ftdi.c
+++ b/src/jtag/drivers/ftdi.c
@@ -808,6 +808,8 @@ static void oscan1_mpsse_clock_data(struct mpsse_ctx *ctx, const uint8_t *out, u
static const uint8_t zero;
static const uint8_t one = 1;
+ struct signal *tmsc_en = find_signal_by_name("TMSC_EN");
+
LOG_DEBUG_IO("oscan1_mpsse_clock_data: %sout %d bits", in ? "in" : "", length);
for (unsigned i = 0; i < length; i++) {
@@ -833,8 +835,14 @@ static void oscan1_mpsse_clock_data(struct mpsse_ctx *ctx, const uint8_t *out, u
mpsse_clock_tms_cs_out(mpsse_ctx, &one, 0, 1, false, mode);
}
+ if (tmsc_en)
+ ftdi_set_signal(tmsc_en, '0'); /* put TMSC in high impedance */
+
/* drive another TCK without driving TMSC (TDO cycle) */
mpsse_clock_tms_cs(mpsse_ctx, &zero, 0, in, in_offset+i, 1, false, mode);
+
+ if (tmsc_en)
+ ftdi_set_signal(tmsc_en, '1'); /* drive again TMSC */
}
}
@@ -845,6 +853,8 @@ static void oscan1_mpsse_clock_tms_cs(struct mpsse_ctx *ctx, const uint8_t *out,
static const uint8_t zero;
static const uint8_t one = 1;
+ struct signal *tmsc_en = find_signal_by_name("TMSC_EN");
+
LOG_DEBUG_IO("oscan1_mpsse_clock_tms_cs: %sout %d bits, tdi=%d", in ? "in" : "", length, tdi);
for (unsigned i = 0; i < length; i++) {
@@ -871,8 +881,14 @@ static void oscan1_mpsse_clock_tms_cs(struct mpsse_ctx *ctx, const uint8_t *out,
mpsse_clock_tms_cs_out(mpsse_ctx, &one, 0, 1, (tmsbit != 0), mode);
}
+ if (tmsc_en)
+ ftdi_set_signal(tmsc_en, '0'); /* put TMSC in high impedance */
+
/* drive another TCK without driving TMSC (TDO cycle) */
mpsse_clock_tms_cs(mpsse_ctx, &zero, 0, in, in_offset+i, 1, false, mode);
+
+ if (tmsc_en)
+ ftdi_set_signal(tmsc_en, '1'); /* drive again TMSC */
}
}
diff --git a/tcl/interface/ftdi/digilent-hs2-cjtag.cfg b/tcl/interface/ftdi/digilent-hs2-cjtag.cfg
new file mode 100644
index 0000000..067f664
--- /dev/null
+++ b/tcl/interface/ftdi/digilent-hs2-cjtag.cfg
@@ -0,0 +1,19 @@
+# this supports JTAG-HS2 (and apparently Nexys4 as well)
+
+adapter driver ftdi
+ftdi device_desc "Digilent Adept USB Device"
+ftdi vid_pid 0x0403 0x6014
+
+ftdi channel 0
+ftdi layout_init 0xc0e8 0xe0eb
+
+reset_config none
+
+# These signals are used for cJTAG escape sequence on initialization only
+ftdi layout_signal TCK -data 0x0001
+ftdi layout_signal TDI -data 0x0002
+ftdi layout_signal TDO -input 0x0004
+ftdi layout_signal TMS -data 0x0008
+ftdi layout_signal JTAG_SEL -ndata 0xc000
+
+ftdi layout_signal TMSC_EN -data 0x0020