This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrfutil 6.1.0 on raspberry pi 4 -- what SD API version to use?

Hi

I want to use nrfutil as a command line tool on a Raspberry Pi 4 box.

Out of the box, I could not install nrfutil (missing drivers?) compatible with Python3 so I tried Python 2.
I was able to install nrfutil but could not run it -- kept getting run time errors that pc-ble-driver libraries could not be loaded (or something similar to that sort of error).

Then I downloaded and build the pc-ble-driver from sources, as documented here. After a lot of struggles, I was finally able to get a build for Python3.

*** BUT ***

The build generated multiple shared libraries with filenames ending in _v2.so, _v3.so, _v4.so, _v4.so, _v6.so.

The nrfutil error message was saying that it could not find the shared library 'libpc_ble_driver_shared_sd_api_v3.so' but none of the files generated by the build match this name.
On a whim, I created a soft link from the generated file 'libnrf-ble-driver-sd_api_v3.so' to a file named 'libpc_ble_driver_shared_sd_api_v3.so' and added this folder to the environment variable LD_LIBRARY_PATH.

Now, the nrfutil loads this shared object but I get the error trace:

  File "/usr/local/lib/python3.7/dist-packages/nordicsemi/__main__.py", line 67, in ble_driver_init
    from pc_ble_driver_py.ble_driver    import BLEDriver, Flasher
  File "/usr/local/lib/python3.7/dist-packages/pc_ble_driver_py/ble_driver.py", line 112, in <module>
    driver = importlib.import_module(SWIG_MODULE_NAME)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'pc_ble_driver_sd_api_v3'

My question(s) are:

1. What is the actual/correct version of the generated shared objects that should be pulled into the nrfutil?

2. Why is the error referring to version 3 of the API while all of the documentation I see for the nRF52 DK (with nRF52832) state that the BLE Driver API to use is v5.0?

3. How do I 'install' the compiled pc-ble-driver so that the nrfutil python installation can correctly and properly find my build from sources?

Cheers

RMV

Parents Reply Children
  • Thanks Vidar. This package seems to progress further upstream and does show that it is using the API version 5 as required for the NRF52 DK (with nRF52832).
    Would it be possible to 'release' this out in Nordic's GitHub playground or somewhere similar?

    Cheers

    RMV

  • Have a follow up question.
    I am now able to get my Raspberry Pi to talk to the nRF52 DK board and have it discover a remote device that I want to update using the Nordic DFU protocol.

    I have been able to make this happen on a windows platform i.e. the DK has the appropriate 'connectivity firmware'. With the Pi, however, the DK board is not able to sustain the connection and execute the DFU. Initially it had an issue with the MTU (which I then overrode and set to 123). Then, it went past the point where it negotiates the MTU etc. but failed to transfer the 'init packet' with this stack trace....

    Traceback (most recent call last):
      File "/usr/local/bin/nrfutil", line 10, in <module>
        sys.exit(cli())
      File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
        return self.main(*args, **kwargs)
      File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
        rv = self.invoke(ctx)
      File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
        return callback(*args, **kwargs)
      File "/usr/local/lib/python3.7/dist-packages/nordicsemi/__main__.py", line 1199, in ble
        dfu.dfu_send_images()
      File "/usr/local/lib/python3.7/dist-packages/nordicsemi/dfu/dfu.py", line 127, in dfu_send_images
        self._dfu_send_image(self.manifest.application)
      File "/usr/local/lib/python3.7/dist-packages/nordicsemi/dfu/dfu.py", line 95, in _dfu_send_image
        self.dfu_transport.send_init_packet(data)
      File "/usr/local/lib/python3.7/dist-packages/nordicsemi/dfu/dfu_transport_ble.py", line 524, in send_init_packet
        self.__stream_data(data=init_packet)
      File "/usr/local/lib/python3.7/dist-packages/nordicsemi/dfu/dfu_transport_ble.py", line 642, in __stream_data
        self.dfu_adapter.write_data_point(list(to_transmit))
      File "/usr/local/lib/python3.7/dist-packages/nordicsemi/dfu/dfu_transport_ble.py", line 350, in write_data_point
        self.adapter.write_cmd(self.conn_handle, DFUAdapter.DP_UUID, data)
      File "/usr/local/lib/python3.7/dist-packages/pc_ble_driver_py/ble_adapter.py", line 568, in write_cmd
        raise e
      File "/usr/local/lib/python3.7/dist-packages/pc_ble_driver_py/ble_adapter.py", line 554, in write_cmd
        response = self.driver.ble_gattc_write(conn_handle, write_params)
      File "/usr/local/lib/python3.7/dist-packages/pc_ble_driver_py/ble_driver.py", line 107, in wrapper
        error_code=err_code,
    pc_ble_driver_py.exceptions.NordicSemiException: Failed to ble_gattc_write. Error code: NRF_ERROR_SD_RPC_NO_RESPONSE

  • I was doing DFU with nrfutil v.6.1.0 and everything appeared to be stable. However, I was using the nRF52840 Dongle with the built-in nRF USB and not a dev kit with the J-link USB. Have you disabled the Mass Storage class on your  J-link: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/tools/nordic_segger.html#nordic-segger-msd?

  • Disabling the Mass Storage Device seems to work. Just one note though that the JLink for ARM is different from JLink for Linux-32 bit (which is what I tried initially but got an architecture mismatch).

    Thanks for all your help, Vidar.

  • Good to hear. Thanks for confirming that it worked.

Related