This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

pynrfjprog not working on Raspberry Pi 4

Hi,

I come from here: https://devzone.nordicsemi.com/f/nordic-q-a/80874/nrfjprog-not-working-on-raspberry-pi-4/336129

But for me the nrfjprog comand works fine:

pi@raspberrypi:~/Desktop/repo/gateway-software/gateway $ nrfjprog -f NRF51 --program ./firm.hex --chiperase
Parsing image file.
Verified OK.

However when I try to upload an hex with the pynrjprog pip module I get the following error:

  File "/home/pi/Desktop/repo/gateway-software/gateway/OTA.py", line 116, in updateBin
    api.open()
  File "/home/pi/Desktop/repo/gateway-software/productionVenv/lib/python3.7/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.

This is the zone of the code at which it fails:

api = LowLevel.API(LowLevel.DeviceFamily.UNKNOWN)
api.open()

I'm runing pynrfjprog version 10.15.1

Parents
  • Hi,

    I tested with a Pi4 here, and both nrfjprog and pynrfjprog worked. Maybe the python installation didn't pull in the correct libraries in your case?

    This is what I did:

    1. Downloaded the zip

    2. Installed the jlink package first with sudo dpkg -i <jlink package>.deb

    3. Then the command line tools package using the same command as in step 2.

    4. Extracted the nrf-command-line-tools tarball then cd'ed to /nrf-command-line-tools-10.15.1_linux-armhf/nrf-command-line-tools/python and ran the setup script with this command: python3 -m pip setup.py install --user

    I suggest you try to uninstall the current pynrfjprog package and then try to install it like I did in step 4. Hope this helps.

    Best regards,

    Vidar

  • So, I did:

    pi@raspberrypi:~/Downloads/nrf-command-line-tools-10.15.1_linux-armhf $ sudo dpkg -i JLink_Linux_V758b_arm.deb
    (Reading database ... 114985 files and directories currently installed.)
    Preparing to unpack JLink_Linux_V758b_arm.deb ...
    Removing /opt/SEGGER/JLink ...
    Unpacking jlink (7.582) over (7.582) ...
    Setting up jlink (7.582) ...
    

    Then:

    pi@raspberrypi:~/Downloads/nrf-command-line-tools-10.15.1_linux-armhf $ sudo dpkg -i nrf-command-line-tools_10.15.1_armhf.deb 
    (Reading database ... 114985 files and directories currently installed.)
    Preparing to unpack nrf-command-line-tools_10.15.1_armhf.deb ...
    Unpacking nrf-command-line-tools (10.15.1) over (10.15.1) ...
    Setting up nrf-command-line-tools (10.15.1) ...

    I switched into the venv, uninstalled pynrfjprog.

    Then I cd  (productionVenv) pi@raspberrypi:~/Downloads/nrf-command-line-tools-10.15.1_linux-armhf/nrf-command-line-tools/python $

    And ran:

    python3 -m pip setup.py install --user

    And got:

    (productionVenv) pi@raspberrypi:~/Downloads/nrf-command-line-tools-10.15.1_linux-armhf/nrf-command-line-tools/python $ python3 -m pip setup.py install --user
    ERROR: unknown command "setup.py"
    And just so that it's clear:

    (productionVenv) pi@raspberrypi:~/Downloads/nrf-command-line-tools-10.15.1_linux-armhf/nrf-command-line-tools/python $ ls
    build  cmake_install.cmake  __init__.py  MANIFEST.in  pynrfjprog  pynrfjprog.egg-info  README.md  setup.cfg  setup.py

Reply
  • So, I did:

    pi@raspberrypi:~/Downloads/nrf-command-line-tools-10.15.1_linux-armhf $ sudo dpkg -i JLink_Linux_V758b_arm.deb
    (Reading database ... 114985 files and directories currently installed.)
    Preparing to unpack JLink_Linux_V758b_arm.deb ...
    Removing /opt/SEGGER/JLink ...
    Unpacking jlink (7.582) over (7.582) ...
    Setting up jlink (7.582) ...
    

    Then:

    pi@raspberrypi:~/Downloads/nrf-command-line-tools-10.15.1_linux-armhf $ sudo dpkg -i nrf-command-line-tools_10.15.1_armhf.deb 
    (Reading database ... 114985 files and directories currently installed.)
    Preparing to unpack nrf-command-line-tools_10.15.1_armhf.deb ...
    Unpacking nrf-command-line-tools (10.15.1) over (10.15.1) ...
    Setting up nrf-command-line-tools (10.15.1) ...

    I switched into the venv, uninstalled pynrfjprog.

    Then I cd  (productionVenv) pi@raspberrypi:~/Downloads/nrf-command-line-tools-10.15.1_linux-armhf/nrf-command-line-tools/python $

    And ran:

    python3 -m pip setup.py install --user

    And got:

    (productionVenv) pi@raspberrypi:~/Downloads/nrf-command-line-tools-10.15.1_linux-armhf/nrf-command-line-tools/python $ python3 -m pip setup.py install --user
    ERROR: unknown command "setup.py"
    And just so that it's clear:

    (productionVenv) pi@raspberrypi:~/Downloads/nrf-command-line-tools-10.15.1_linux-armhf/nrf-command-line-tools/python $ ls
    build  cmake_install.cmake  __init__.py  MANIFEST.in  pynrfjprog  pynrfjprog.egg-info  README.md  setup.cfg  setup.py

Children
  • Sorry, I didn't mean to include pip in the command. Should have been python3 setup.py install --user. And the '--user' argument should be reduntant as you run it in venv.

    Try:

    $ python3 setup.py install

  • That makes more sense Slight smile

    It still throws an error:

    Traceback (most recent call last):
      File "/home/pi/Desktop/repo/gateway-software/__init__.py", line 4, in <module>
        main()
      File "/home/pi/Desktop/repo/gateway-software/gateway/mgateway.py", line 32, in main
        OTA.updateBin('','')
      File "/home/pi/Desktop/repo/gateway-software/gateway/OTA.py", line 115, in updateBin
        with HighLevel.API() as api:
      File "/home/pi/Desktop/repo/gateway-software/productionVenv/lib/python3.7/site-packages/pynrfjprog-10.15.1-py3.7.egg/pynrfjprog/HighLevel.py", line 70, in __init__
        raise APIError(NrfjprogdllErr.NRFJPROG_SUB_DLL_NOT_FOUND, highlevel_nrfjprog_dll_path, log=self._logger.error)
    pynrfjprog.APIError.APIError: An error was reported by NRFJPROG DLL: -150 NRFJPROG_SUB_DLL_NOT_FOUND. /home/pi/Desktop/repo/gateway-software/productionVenv/lib/python3.7/site-packages/pynrfjprog-10.15.1-py3.7.egg/pynrfjprog/lib_armhf/libhighlevelnrfjprog.so

    But I think I'm going to try to repeat your steps on a fresh installation.

  • Hi,

    Looks like there may be a problem with the installation script. I noticed now that my /lib/python3.7/site-packages/pynrfjprog-10.15.1-py3.7.egg/pynrfjprog/lib_armhf/ directory is empty after the installation.

    Can you try to manually copy the libraries from /opt/nrf-command-line-tools/python/pynrfjprog/lib_armhf?

    E.g.

    $ cp -R /opt/nrf-command-line-tools/python/pynrfjprog/lib_armhf /home/pi/Desktop/repo/gateway-software/productionVenv/lib/python3.7/site-packages/pynrfjprog-10.15.1-py3.7.egg/pynrfjprog/lib_armhf

Related