Closed dottspina closed 2 years ago
I'm quite confident that path = ctypes_util.find_library(self._sdk)
is not always correct:
OS | self._sdk |
find_library() |
---|---|---|
Windows | 'JLink{ARM,_x64}' |
should answer the expected file path |
MacOS | 'libjlinkarm' |
will fail (the library name should be 'jlinkarm' ) |
Linux | 'libjlinkarm' |
will fail, and would not return the full file path anyway |
I've written a new patch, going forward my former comment, that completely removes the useless
find_library('libjlinkarm')
call, and makes more fluent we:
/opt/SEGGER/JLink
I agree we are few who install the JLink Sofware pack not in its default location, but there are valid use cases: for e.g. this issue prevents to write a developer guide, involving pyOCD, without assuming the reader has the permission to write in the /opt
directory.
I've created a PR (#132 ), which, if I'm correct, should preserve the code path and semantic on Windows, and honor both LD_LIBRARY_PATH
on Linux and DYLD_LIBRARY_PATH
on MacOS. It should not mess with the whole gymnastic pylink implements to "work around a limitation of the J-Link DLL in which multiple J-Links cannot be accessed from the same process".
Thanks.
-- chris
Should be resolved with #132 (which you added 😛), and available in v0.14.0
. Thanks for the patch.
@hkpeprah, thanks for the prompt PyPI update.
Seems to work fine here:
$ pyocd list
No available debug probes are connected
$ pip install -U pylink-square
[...]
Successfully uninstalled pylink-square-0.13.0
Successfully installed pylink-square-0.14.1
$ pyocd list
# Probe/Board Unique ID Target
-------------------------------------------------------------------
0 Segger J-Link OB-SAM3U128-V2-NordicSem 683529xxx n/a
For me we can close this issue as fixed.
Thanks.
-- chris
Thanks for the confirmation!
Thanks for maintaining this library.
The demonstrable problem assumes:
/opt/SEGGER/JLink
, but rather in an arbitrary directory (typically a sub-directory of the user's home)pylink.JLink()
dllpath='/path/to/libjlinkarm.so'
(as proposed in #33 )pylink
will then fail to load the library, even whenLD_LIBRARY_PATH
includes the actual JLink installation directory.For e.g. with pyOCD (v0.33.1):
Preferable behavior:
pylink
honorsLD_LIBRARY_PATH
on Linux. If I understand correctly it's also the expected behavior.OTOH, in the
ctypes_util.find_library()
reference documentation we read:Which would not match
libjlinkarm
(akaLibrary._sdk
, akaJLINK_SDK_NAME
), but ratherjlinkarm
.And indeed,
ctypes.cdll.LoadLibrary(ctypes_util.find_library('jlinkarm'))
correctly honorsLD_LIBRARY_PATH
.I understand we still have to find the library absolute path to be able to make a temp copy (work around for multiple J-Links within the same process): I've implemented a PoC, with some contortion (see attached patch bellow).
On Linux,
pylink
will then:dlinfo()
dance to retrieve the absolute file path, and with that continue topylink.Library.load()
pylink.Library.load_default()
code path executes as if the patch never existedThis patch is really a PoC, and probably not the right approach: IMHO
path = ctypes_util.find_library(self._sdk)
does not have the intended semantic to begin with (at least on Linux, and probably on MacOS), and a proper fix may imply a bit more rework to the functionpylink.Library.load_default()
.Thanks.
-- chris
I'm not sure we can actually attach a patch file to a GitHub issue: I'm willing to setup a PR if helpful.