NordicSemiconductor / pynrfjprog

Python wrapper around the nrfjprog dynamic link library (DLL)
Other
74 stars 26 forks source link

macOS ARM libraries missing and x64 throw an error on ARM #28

Open Sn0wfreezeDev opened 2 years ago

Sn0wfreezeDev commented 2 years ago

Hi,

I recently tested the tool on macOS with an M1 ARM chip. It defaults back to x64, which throws an error:

with LowLevel.API(
File "/private/var/folders/dw/679j8kp90psgk8pxq06vmnzc0000gp/T/OpenHaystack/venv/lib/python3.8/site-packages/pynrfjprog/LowLevel.py", line 1798, in __enter__
self.open()
File "/private/var/folders/dw/679j8kp90psgk8pxq06vmnzc0000gp/T/OpenHaystack/venv/lib/python3.8/site-packages/pynrfjprog/LowLevel.py", line 177, in open
raise APIError(result, error_data=self.get_errors())
pynrfjprog.APIError.APIError: An error was reported by NRFJPROG DLL: -254 INTERNAL_ERROR.

Since the error occurs in the NRFJPROG DLL I cannot really find out where it occurs. I guess that a recompile for ARM64 with the libraries could solve the issue.

chrta commented 2 years ago

I see the same error with nrf-command-line-tools-10.15.1_linux-amd64.zip on Ubuntu 20.04.3 LTS on x86_64 from this sample code:

from pynrfjprog import LowLevel

with LowLevel.API('NRF91') as api:
    api.enum_emu_snr()
    api.connect_to_emu_without_snr()
    api.disconnect_from_emu()

I installed above version of command line tools and JLink via included deb packages and pynrfjprog via pip.

Addition: I managed so solve it (i am not sure why) on my PC. There seems to be some issue with pyenv https://github.com/pyenv/pyenv which i use. Instead of installing it via python3 -m pip install pynrfjprog, i installed it from the incuded sources via:

cd /opt/nrf-command-line-tools/python
python3 -m pip install .

I suspect the native libs are not installed to the correct path when something like pyenv is being used. I am not sure if this is the same issue on the M1 ARM chip.

simtind commented 2 years ago

Hi, Unfortunately 10.15.1 shipped with binaries without execute-rights, which causes execution of the worker process to fail. This should be fixed in 10.15.2.