From bddfe9799752e819561734c08058e7e02965ad9c Mon Sep 17 00:00:00 2001 From: Andrew Dennison Date: Mon, 29 May 2023 11:19:12 +1000 Subject: [PATCH] jlink: suport writeTDI() with tx=NULL fixes crash and is consistent with other jtag cables --- src/jlink.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/jlink.cpp b/src/jlink.cpp index af55a2b..4df3679 100644 --- a/src/jlink.cpp +++ b/src/jlink.cpp @@ -137,7 +137,10 @@ int Jlink::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end) xfer_len = len - rest; // reduce xfer len uint16_t tt = (xfer_len + 7) >> 3; // convert to Byte memset(_tms, tms, tt); // fill tms buffer - memcpy(_tdi, tx_ptr, tt); // fill tdi buffer + if (tx) + memcpy(_tdi, tx_ptr, tt); // fill tdi buffer + else + memset(_tdi, 0, tt); // clear tdi buffer _num_bits = xfer_len; // set buffer size in bit if (end && xfer_len + rest == len) { // last sequence: set tms 1 _last_tms = 1;