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

Conversation

colinoflynn
Copy link

This adds a single feature from the 'raw jtag' API allowing TMS/TDI/TDO control. This is useful to implement boundary scan mode (which I'm working on in another library called pyjtagbs). Other raw commands could be added, but are harder to use in practice as they require more information about the scan chain sent to the J-Link, most software seems to use this API only.

You should be able to use the code like this:

import pylink
jl = pylink.JLink() #Defaults to JTAG (not SWD)
jl.open() #Open but *do not* connect
jl.jtag_rawrw([0], [0x1F], 5) #JTAG Reset (tms = 1 for 5 bits)
jl.jtag_rawrw([0], [0x02], 4) #JTAG ID read
result = jl.jtag_rawrw([0]*8, [0]*8) #Shift to see what's on scan chain
print(result)
hex_id = hex(struct.unpack("<I", bytes(result[0:4]))[0])
print(hex_id)

If a single item - will just see 4 bytes. You can print the hex_id to see the standard format - testing on a Spartan 6 LX9 shows me 0x3622093 which matches the expected device id.

Note there is no .connect() - you can't connect to the chain as that will start trying to discover devices on it (which may be unsupported devices).

@CLAassistant
Copy link

CLAassistant commented Feb 14, 2021

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@hkpeprah hkpeprah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the changes. Sorry it took me so long to get back to this. Could you add unit tests for the function you introduced? Otherwise, besides the minor comments, LGTM.

pylink/jlink.py Outdated Show resolved Hide resolved
pylink/jlink.py Outdated Show resolved Hide resolved
@colinoflynn
Copy link
Author

No worries on lag - considering the state of the world I hardly think 2 weeks delay for some JTAG raw access is worth apologizing over ;-) I'll figure out the unit test thing - will fix the easy issues first then comment again once tests are there (hadn't looked at how they were working in this repo).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants