Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add raw JTAG support #86

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions pylink/jlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -5191,3 +5191,39 @@ 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):
colinoflynn marked this conversation as resolved.
Show resolved Hide resolved
"""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
colinoflynn marked this conversation as resolved.
Show resolved Hide resolved

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)