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

Python3 interface for library #4

Open
colinoflynn opened this issue Feb 12, 2021 · 2 comments
Open

Python3 interface for library #4

colinoflynn opened this issue Feb 12, 2021 · 2 comments

Comments

@colinoflynn
Copy link

colinoflynn commented Feb 12, 2021

Short comment first - thanks so much for this library, I spent a while playing with various JTAG boundary scan options and it's frustrating how hard it is to toggle some IO pins for testing with other tools. I came close to buying some of the very expensive tools even but they wouldn't provide enough up-front information.

I'm adding a Python interface to this library, so far it seems to work OK (tested on Windows 10 w/ JLINK). See https://github.com/colinoflynn/jtag-boundary-scanner/tree/python-interface/pylibjtag

You use it something like this:

jtag = JTAGCore()
probes = jtag.get_probe_names()
jtag.open_probe(probes[b"USB JLINK ARM"])
jtag.scan_init_chain()
numdev = jtag.get_number_devices()

print("Found %d devices."%numdev)

for n in range(0, numdev):
    print("Device %d: %x"%(n, jtag.get_devid(n)))

jtag.bsdl_attach(r"bsdl_files/STM32F405_415_407_417_WLCSP90.bsd", 1)

total_pins = jtag.pins_get_number(1)

for pinid in range(0, total_pins):
    pinname, pinprop = jtag.pin_get_properties(1, pinid)
    print("{:3d} {} {}".format(pinid, pinname, pinprop))

jtag.set_scan_mode(1, "passive")

jtag.scan() #Get updated pin status
print(jtag.pin_get_state(1, "PA9")) #Print status of a pin

jtag.set_scan_mode(1, "active")

jtag.pin_set_state(1, "PA11", True) #set pin high (active out)
jtag.pin_set_state(1, "PA11", False) #Set pin low (active out)
jtag.pin_set_state(1, "PA11", None) #Set pin to high-z

I've included my library build in that repo to make it easier for other people to use. I had a few issues I ran into - I can open separate issues for them or just paste as comments here, roughly around:

  • Library segfaulted because script_printf was set to null and isn't checked (I routed it to just not print)
  • Windows build would hang checking drv_LPT_libGetDrv so I commented them out (I'm nowhere near LPTs these days)
  • Would be nice to have 64-bit build, as most Python these days is 64-bit versions (and it can't call a 32-bit library)

Finally - do you want to have the Python interface as part of the repo (i.e. - I can open a PR once it's cleaner)? If you're not using Python you might be hesitant too for future support. I can start it as a separate project if you prefer, but it makes more sense to have it here to me (especially to keep any changes in the library & Python API in sync).

@colinoflynn
Copy link
Author

I'm going to be reorganizing the python module - I decided in the end it might be easier keeping the python side in a separate project (which could work with other backends later). Could still easily add the "core" part to this project - I'm open. For now I'll keep all my Python stuff separate to avoid problems!

@nowinnovation
Copy link

nowinnovation commented Jun 21, 2022

I read your article on Circuit Cellar and share your interest in this codebase as an extensible library of JTAG boundary scan algorithms. Take a look at my pull request. Does this offer a simpler way to build your Python3 interface?

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

No branches or pull requests

2 participants