pylink
pylink copied to clipboard
Can support C-JTAG
Segger support c-jtag,can pylink implement it?
I'm not sure. Have you tried to connect and use it with your target? What is the output?
In my chip that supports both C-JTAG and JTAG protocols, in pylink enum type, i can't find corresponding C-JTAG type, so i just use set_tif(pylink.enums.JLinkInterfaces.JTAG) function? i will try
I would try that.
__jlink_dll = pylink.library.Library("JLink_x64.dll")
jtag = pylink.JLink(lib=__jlink_dll)
jtag.open()
jtag.set_tif(pylink.enums.JLinkInterfaces.JTAG)
jtag.connect(chip_name="N308")
print(jtag.connected()) # Ture
print(jtag.target_connected()) # False
I ran the above code and found that it can connect to J-Link, but the target cannot be connected. I'm not sure what the reason is
Maybe something naive, but could you try passing a different target interface from here for the target interfaces?
Maybe C2?
https://github.com/square/pylink/blob/master/pylink/enums.py#L274
i try it, but when i use C2, it will print "RISC-V is not supported via C2", and i then try other option, all trigger error
Are you sure your target is supported via C2? This seems to suggest that C2 is proprietary to Silicon Labs MCUs: https://community.silabs.com/s/article/jtag-and-c2-debug-interfaces?language=en_US, which to my understanding are ARM-based.
Maybe you need to perform your own connect sequence for cJTAG, and use that instead of C2: https://wiki.segger.com/J-Link_cJTAG_specifics
Ok, i will try that
Hello, sorry to bother you again. I tried to use the DLL file provided by SEGGER to access CJTAG devices. However, when using JLINKARM_TIF_Select, I was unsure about the specific enum type and just filled in one randomly. It seems like I was still able to access the device, but I'm not clear on what happened in the middle. The specific code is as follows:
////////////////////////////////////////////////////////////
import ctypes
#
my_dll = ctypes.windll.LoadLibrary("../Jlink_x64.dll")
# # Open USB
my_dll.JLINKARM_SelectUSB(0)
# Connect to JLINK
my_dll.JLINKARM_Open()
uint_var = ctypes.c_uint32()
my_dll.JLINKARM_TIF_GetAvailable(ctypes.byref(uint_var))
print(uint_var.value)
value = my_dll.JLINKARM_TIF_Select(1 << 7)
print("prv: ", ctypes.c_uint32(value).value)
# my_dll.JLINKARM_DEVICE_GetIndex("N308".encode("ascii"))
err_buf = (ctypes.c_char * 336)()
# my_dll.JLINKARM_ExecCommand("Tif = T".encode(), err_buf, 336) // error
# err_buf = ctypes.string_at(err_buf).decode()
# print("TIF:", err_buf)
my_dll.JLINKARM_ExecCommand("Device = N308".encode(), err_buf, 336)
err_buf = ctypes.string_at(err_buf).decode()
print("DEVICE:", err_buf)
result = my_dll.JLINKARM_Connect()
print("RESULT:", result)
value = my_dll.JLINKARM_ReadMem(0, 4, ctypes.byref(uint_var)) /// I can get the correct value
print("ret: ", value)
print("value: ", hex(uint_var.value))
my_dll.JLINKARM_Close()
Do you happen to know what error you saw?
I found the macro for CJTAG in SEGGER, and by using version 7.9.4 of the DLL, calling my_dll.JLINKARM_TIF_Select(7) can successfully connect to CJTAG. Will this parameter be considered for inclusion in PyLink in the future?
Feel free to make a PR to add the enum value.