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

Incorrect detection of OS architecture #45

Open
MBradbury opened this issue Jul 31, 2024 · 0 comments · May be fixed by #46
Open

Incorrect detection of OS architecture #45

MBradbury opened this issue Jul 31, 2024 · 0 comments · May be fixed by #46

Comments

@MBradbury
Copy link

I have an oddly setup machine in which pynrfjprog is being used to interact with nRF52840s.

I have a machine which is reported as aarch64.

Linux iris2 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr  3 17:24:16 BST 2023 aarch64 GNU/Linux

But actually is a 32 bit OS.

sudo dpkg-architecture -l
DEB_BUILD_ARCH=armhf
DEB_BUILD_ARCH_ABI=eabihf
DEB_BUILD_ARCH_BITS=32
DEB_BUILD_ARCH_CPU=arm
DEB_BUILD_ARCH_ENDIAN=little
DEB_BUILD_ARCH_LIBC=gnu
DEB_BUILD_ARCH_OS=linux
DEB_BUILD_GNU_CPU=arm
...

This causes a problem with loading the libhighlevelnrfjprog.so.

Traceback (most recent call last):
  File "/home/mbradbury/.local/lib/python3.9/site-packages/pynrfjprog/HighLevel.py", line 84, in __init__
    self.lib = ctypes.cdll.LoadLibrary(highlevel_nrfjprog_dll_path)
  File "/usr/lib/python3.9/ctypes/__init__.py", line 452, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib/python3.9/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /home/mbradbury/.local/lib/python3.9/site-packages/pynrfjprog/lib_arm64/libhighlevelnrfjprog.so: wrong ELF class: ELFCLASS64

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "...", line 242, in ...
    with pynrfjprog.HighLevel.API() as api:
  File "/home/mbradbury/.local/lib/python3.9/site-packages/pynrfjprog/HighLevel.py", line 86, in __init__
    raise APIError(
pynrfjprog.APIError.APIError: An error was reported by NRFJPROG DLL: -151 NRFJPROG_SUB_DLL_COULD_NOT_BE_OPENED. Got error OSError('/home/mbradbury/.local/lib/python3.9/site-packages/pynrfjprog/lib_arm64/libhighlevelnrfjprog.so: wrong ELF class: ELFCLASS64') for library at /home/mbradbury/.local/lib/python3.9/site-packages/pynrfjprog/lib_arm64/libhighlevelnrfjprog.s

This is because lib_armhf should be used instead of lib_arm64.

In https://github.com/NordicSemiconductor/pynrfjprog/blob/master/pynrfjprog/Parameters.py#L35 it looks like a similar check for sys.maxsize is needed in the arm and aarch branches.

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

Successfully merging a pull request may close this issue.

1 participant