pyOCD
pyOCD copied to clipboard
Failure to load J-Link driver after upgrading from 0.27.3 to 0.28.0 (or above)
Hi,
We are encountering the following exception when upgrading to 0.28.0 or above:
15:34:42 [2021-07-20T13:34:42.862Z] Traceback (most recent call last):
15:34:42 [2021-07-20T13:34:42.862Z] File "bin/automator/Automator.py", line 478, in <module>
15:34:42 [2021-07-20T13:34:42.862Z] PluginMgr.init(settings)
15:34:42 [2021-07-20T13:34:42.862Z] File "/opt/jenkins_workspace/workspace/General/linklayer_integrator_pipeline@3/bin/automator/PluginMgr.py", line 36, in init
15:34:42 [2021-07-20T13:34:42.862Z] eval("__import__(\"{}\")".format(plugin))
15:34:42 [2021-07-20T13:34:42.862Z] File "<string>", line 1, in <module>
15:34:42 [2021-07-20T13:34:42.862Z] File "/opt/jenkins_workspace/workspace/General/linklayer_integrator_pipeline@3/bin/automator/Plugins/ConnectionSwd/ConnectionSwd.py", line 14, in <module>
15:34:42 [2021-07-20T13:34:42.862Z] from pyocd.board.mbed_board import MbedBoard
15:34:42 [2021-07-20T13:34:42.862Z] File "/usr/local/lib/python3.6/site-packages/pyocd/__init__.py", line 21, in <module>
15:34:42 [2021-07-20T13:34:42.862Z] from . import gdbserver
15:34:42 [2021-07-20T13:34:42.862Z] File "/usr/local/lib/python3.6/site-packages/pyocd/gdbserver/__init__.py", line 17, in <module>
15:34:42 [2021-07-20T13:34:42.862Z] from .gdbserver import GDBServer
15:34:42 [2021-07-20T13:34:42.862Z] File "/usr/local/lib/python3.6/site-packages/pyocd/gdbserver/gdbserver.py", line 49, in <module>
15:34:42 [2021-07-20T13:34:42.862Z] from ..commands.commander import ToolExitException
15:34:42 [2021-07-20T13:34:42.862Z] File "/usr/local/lib/python3.6/site-packages/pyocd/commands/commander.py", line 22, in <module>
15:34:42 [2021-07-20T13:34:42.862Z] from ..core.helpers import ConnectHelper
15:34:42 [2021-07-20T13:34:42.862Z] File "/usr/local/lib/python3.6/site-packages/pyocd/core/helpers.py", line 19, in <module>
15:34:42 [2021-07-20T13:34:42.862Z] from ..probe.aggregator import DebugProbeAggregator
15:34:42 [2021-07-20T13:34:42.862Z] File "/usr/local/lib/python3.6/site-packages/pyocd/probe/aggregator.py", line 84, in <module>
15:34:42 [2021-07-20T13:34:42.862Z] load_plugin_classes_of_type('pyocd.probe', PROBE_CLASSES, DebugProbe)
15:34:42 [2021-07-20T13:34:42.862Z] File "/usr/local/lib/python3.6/site-packages/pyocd/core/plugin.py", line 95, in load_plugin_classes_of_type
15:34:42 [2021-07-20T13:34:42.862Z] if plugin.should_load():
15:34:42 [2021-07-20T13:34:42.862Z] File "/usr/local/lib/python3.6/site-packages/pyocd/probe/jlink_probe.py", line 370, in should_load
15:34:42 [2021-07-20T13:34:42.862Z] return JLinkProbe._get_jlink() is not None
15:34:42 [2021-07-20T13:34:42.862Z] File "/usr/local/lib/python3.6/site-packages/pyocd/probe/jlink_probe.py", line 54, in _get_jlink
15:34:42 [2021-07-20T13:34:42.862Z] warn=TRACE.warn,
15:34:42 [2021-07-20T13:34:42.862Z] File "/usr/local/lib/python3.6/site-packages/pylink/jlink.py", line 292, in __init__
15:34:42 [2021-07-20T13:34:42.862Z] lib = library.Library()
15:34:42 [2021-07-20T13:34:42.862Z] File "/usr/local/lib/python3.6/site-packages/pylink/library.py", line 261, in __init__
15:34:42 [2021-07-20T13:34:42.862Z] self.load_default()
15:34:42 [2021-07-20T13:34:42.862Z] File "/usr/local/lib/python3.6/site-packages/pylink/library.py", line 299, in load_default
15:34:42 [2021-07-20T13:34:42.862Z] return self.load(path)
15:34:42 [2021-07-20T13:34:42.862Z] File "/usr/local/lib/python3.6/site-packages/pylink/library.py", line 353, in load
15:34:42 [2021-07-20T13:34:42.862Z] self._lib = ctypes.cdll.LoadLibrary(tf.name)
15:34:42 [2021-07-20T13:34:42.862Z] File "/usr/local/lib/python3.6/ctypes/__init__.py", line 426, in LoadLibrary
15:34:42 [2021-07-20T13:34:42.862Z] return self._dlltype(name)
15:34:42 [2021-07-20T13:34:42.862Z] File "/usr/local/lib/python3.6/ctypes/__init__.py", line 348, in __init__
15:34:42 [2021-07-20T13:34:42.862Z] self._handle = _dlopen(self._name, mode)
15:34:42 [2021-07-20T13:34:42.862Z] OSError: /tmp/tmpd06y3kfm.so: failed to map segment from shared object
Looking at the release notes, I see that in 0.28.0, gdbserver
has significant changes. Is there something we need to take care of when upgrading to this version? Thanks!
It looks like this a failure to load the J-Link shared lib .so. The actual error comes from the OS dlopen()
call. It seems like it's a problem the OS has with the .so itself, as the Python code hasn't done anything yet but ask the shared lib to be loaded. So I doubt it has any direct connection with the pyocd changes.
Pyocd uses the pylink-square package for interfacing with the J-Link driver. One possibility is that this package was updated at the same as pyocd was upgraded, and it changed something (but again, the error is before pylink-square has really had a chance to do anything). Although I haven't noticed any problems (but I also tend to keep the J-Link driver updated).
Other possibilities: Did you change from Python 2 to 3? (In v0.30, pyocd dropped Python 2 support.) How about 32- to 64-bit (or vice versa)?
My only real suggestion at this point is to try reinstalling the J-Link drivers.