probe: jlink: open emulator before issuing commands#1927
probe: jlink: open emulator before issuing commands#1927dottspina wants to merge 1 commit intopyocd:developfrom
Conversation
|
Yes, almost simultaneously, I also discovered the issue and the solution: |
@StarSphere-1024, yes same issue and same root cause identified. AFAICT #1889 does not include the fix, rightly since its purpose is to "add support for nRF54LM20A". I think we can merge both pull requests, one per topic. Would that be good for you? |
|
Sure.my PR (#1889) is strictly for nRF54LM20A support. Since I use DAPLink, this J-Link issue doesn't affect me personally. However, it definitely needs a quick fix. Hope it gets merged soon—the review process has been so slow (my PR waited ~4 months) that I had to switch to OpenOCD for my project. |
With JLink DLL versions 9.14 and above, calling disable_dialog_boxes() before open() puts the pylink adapter into an inconsistent state. As a result pyOCD will fail to open the J-Link emulator, and possibly segfault. The approach here is to preserve the current behavior as much as possible, while allowing to develop/test/use pyOCD with current versions of the JLink DLL. See: - pyocd#1925 "Jlink V9.22 No emulator with serial number" - pyocd#1927 "probe: jlink: open emulator before issuing commands" - square/pylink#259 "Fix exec command"
ce37041 to
2907441
Compare
|
Follow-up. Problem description (update) Currently, when using JLink DLL above version 9.12:
It is confirmed that the issue comes from automatic connections created by This is being investigated on the pylink side (square/pylink#259), and the real fix will eventually come from there. Proposed change (update) The initial version of this PR, i.e. the reordering of calls to This second version instead adds a workaround that should:
Once the root cause is fixed in pylink and the fix is available (PyPI), we should be able to:
Thanks. |
Problem description
Using a JLink probe (USB) with JLink DLL version 9.14a and above (latest immune version is 9.12), pyOCD will fail to connect to the emulator, raising "No emulator with serial number XXXXXXXXXX" or "Could not connect to default emulator", depending on the command line arguments.
I myself encountered this problem (programming/debugging an nRF52840-DK), as did at least one other pyOCD user [1], and one pylink user [2].
On my machine (Linux), pyOCD will additionally segfault in
JLINKARM_Close(), probably on library unload (seen in coredump).Proposed solution
It seems that the required emulator status (opened, connected) for executing some commands in
JLink.disable_dialog_boxes()have changed in the JLink SDK v9.14, triggering automatic connections the pylink interface does not take into account (yet ?).They've started looking into it, but they're working (like most of us probably) without the JLink SDK documentation, and reverse engineering the state machine might not be straightforward: It is not even certain that
JLINKARM Open()should not have to be called, in one way or another, before dispatching commands.Proposed solution: in pyOCD
JLinkProbe.open(), callJLink.disable_dialog_boxes()afterJLink.open().This fix Works for me (TM), and
test/automated_test.py -dsucceeds, expect "Gdb Test" which is ignored (I don't have the right Python runtime for the versions of arm-none-eabi-gdb that I have at hand).Bellow is my
pyocd.yaml:Hope this helps.
[1] #1925 Jlink V9.22 No emulator with serial number
[2] square/pylink#254 Can't connect to the emulator