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

Loading library on Aarch64 fails because pylink attempts to load 32-bit library #183

Open
FletcherD opened this issue Sep 2, 2023 · 3 comments

Comments

@FletcherD
Copy link
Contributor

FletcherD commented Sep 2, 2023

The ARM64 version of the JLink software contains two library files, libjlinkarm.so (64 bit) and libjlinkarm_arm.so (32 bit). Pylink attempts to load libjlinkarm_arm.so first, which fails on ARM64 due to the architecture mismatch and causes an error. This is the error message:

>>> jlink = pylink.JLink(use_tmpcpy=False)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/odroid/.local/lib/python3.11/site-packages/pylink/jlink.py", line 293, in __init__
    lib = library.Library(use_tmpcpy=use_tmpcpy)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/odroid/.local/lib/python3.11/site-packages/pylink/library.py", line 293, in __init__
    self.load_default()
  File "/home/odroid/.local/lib/python3.11/site-packages/pylink/library.py", line 351, in load_default
    return self.load(path)
           ^^^^^^^^^^^^^^^
  File "/home/odroid/.local/lib/python3.11/site-packages/pylink/library.py", line 410, in load
    self._lib = ctypes.cdll.LoadLibrary(lib_path)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/ctypes/__init__.py", line 454, in LoadLibrary
    return self._dlltype(name)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/ctypes/__init__.py", line 376, in __init__
    self._handle = _dlopen(self._name, mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: /opt/SEGGER/JLink_V792c/libjlinkarm_arm.so.7.92.3: wrong ELF class: ELFCLASS32

I have a proposed fix in #182 .

@rviollette
Copy link

The same error occurs on Linux too (64-bit Debian-based system).
However, this fix only targets Windows.

In our case, the workaround is to instantiate Library class with dllpath parameter set to the full path of the libjlinkarm.so file.

@FletcherD
Copy link
Contributor Author

The fix is meant to target Linux and works for me, what issue are you having?

@hkpeprah
Copy link
Contributor

This is resolved by #182 right?

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

3 participants