From 1d3583d40a016f9e0917804c96e6d3c744016709 Mon Sep 17 00:00:00 2001 From: Colin O'Flynn Date: Sun, 14 Feb 2021 19:43:18 -0400 Subject: [PATCH 1/4] Add raw JTAG support --- pylink/jlink.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/pylink/jlink.py b/pylink/jlink.py index 6df2bc5..ee831e3 100644 --- a/pylink/jlink.py +++ b/pylink/jlink.py @@ -5191,3 +5191,40 @@ def cp15_register_write(self, cr_n, op_1, cr_m, op_2, value): if res != 0: raise errors.JLinkException(res) return res + +############################################################################### +# +# JTAG API (Raw JTAG access for boundary scan or other purposes) +# +############################################################################### + + @interface_required(enums.JLinkInterfaces.JTAG) + def jtag_rawrw(self, tdo, tms, numbits=None): + """Writes a list of raw bits to TDO+TMS, returns TDI input. + + Args: + self (JLink): the ``JLink`` instance + tdo (List): List of bytes to be shifted out tdo. + tms (List): list of bytes to be shifted out tms. + numbits (Int): Number of bits to shift out in total. + + Returns: + tdi (List): Output from device shifted into tdi. + """ + + if len(tdo) != len(tms): + raise ValueError("TMS & TDO arrays must be same length") + + buf_size = len(tdo) + + if numbits is None: + numbits = len(tdo)*8 + + tdobuf = (ctypes.c_ubyte * buf_size)(*bytearray(tdo)) + tmsbuf = (ctypes.c_ubyte * buf_size)(*bytearray(tms)) + tdibuf = (ctypes.c_ubyte * buf_size)() + + self._dll.JLINKARM_JTAG_StoreGetRaw(tdobuf, tdibuf, tmsbuf, numbits) + + return list(tdibuf) + From ac4d31dc71e0551b0925a97ca1815d1b899c5fb1 Mon Sep 17 00:00:00 2001 From: Colin O'Flynn Date: Sun, 14 Feb 2021 21:18:32 -0400 Subject: [PATCH 2/4] add raw support - make stylebot happy --- pylink/jlink.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pylink/jlink.py b/pylink/jlink.py index ee831e3..7bd6c2b 100644 --- a/pylink/jlink.py +++ b/pylink/jlink.py @@ -5191,7 +5191,7 @@ def cp15_register_write(self, cr_n, op_1, cr_m, op_2, value): if res != 0: raise errors.JLinkException(res) return res - + ############################################################################### # # JTAG API (Raw JTAG access for boundary scan or other purposes) @@ -5211,20 +5211,19 @@ def jtag_rawrw(self, tdo, tms, numbits=None): Returns: tdi (List): Output from device shifted into tdi. """ - + if len(tdo) != len(tms): raise ValueError("TMS & TDO arrays must be same length") - + buf_size = len(tdo) - + if numbits is None: numbits = len(tdo)*8 - + tdobuf = (ctypes.c_ubyte * buf_size)(*bytearray(tdo)) tmsbuf = (ctypes.c_ubyte * buf_size)(*bytearray(tms)) tdibuf = (ctypes.c_ubyte * buf_size)() self._dll.JLINKARM_JTAG_StoreGetRaw(tdobuf, tdibuf, tmsbuf, numbits) - - return list(tdibuf) + return list(tdibuf) \ No newline at end of file From cea442e927d44d8698e27f5900b50b9ee0ebd52a Mon Sep 17 00:00:00 2001 From: Colin O'Flynn Date: Sun, 14 Feb 2021 21:30:49 -0400 Subject: [PATCH 3/4] raw support - fix missing newline --- pylink/jlink.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylink/jlink.py b/pylink/jlink.py index 7bd6c2b..d26d6d3 100644 --- a/pylink/jlink.py +++ b/pylink/jlink.py @@ -5226,4 +5226,4 @@ def jtag_rawrw(self, tdo, tms, numbits=None): self._dll.JLINKARM_JTAG_StoreGetRaw(tdobuf, tdibuf, tmsbuf, numbits) - return list(tdibuf) \ No newline at end of file + return list(tdibuf) From 2127ed62eaefc5f3cfda6422de82e9ab5511aa5b Mon Sep 17 00:00:00 2001 From: Colin O'Flynn Date: Mon, 1 Mar 2021 12:56:34 -0400 Subject: [PATCH 4/4] Rename jtag_rawrw -> jtag_raw_rw, fix style issue --- pylink/jlink.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylink/jlink.py b/pylink/jlink.py index d26d6d3..cb395e4 100644 --- a/pylink/jlink.py +++ b/pylink/jlink.py @@ -5199,7 +5199,7 @@ def cp15_register_write(self, cr_n, op_1, cr_m, op_2, value): ############################################################################### @interface_required(enums.JLinkInterfaces.JTAG) - def jtag_rawrw(self, tdo, tms, numbits=None): + def jtag_raw_rw(self, tdo, tms, numbits=None): """Writes a list of raw bits to TDO+TMS, returns TDI input. Args: @@ -5218,7 +5218,7 @@ def jtag_rawrw(self, tdo, tms, numbits=None): buf_size = len(tdo) if numbits is None: - numbits = len(tdo)*8 + numbits = len(tdo) * 8 tdobuf = (ctypes.c_ubyte * buf_size)(*bytearray(tdo)) tmsbuf = (ctypes.c_ubyte * buf_size)(*bytearray(tms))