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

  • 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

  • I will give it a try.

    Maybe the problem is that I'm running everything under a Python Virtual Enviorment?

  • It shouldn't be a problem to run in it a virtual environment. Though I have not verified it here.

    Here is the code I used to program my hex file to the board:

    from pynrfjprog import HighLevel 
    
    with HighLevel.API() as api:
        snrs = api.get_connected_probes()
        print(snrs)
    
        # To program J-Link probe at snr <snr>:
        with HighLevel.DebugProbe(api,683800344) as probe:
            probe.program("ble_app_uart_pca10056_s140.hex")
    

  • 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

  • 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

Related