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

NRFutil failing to perform dfu over ble with code 0x8016.

Hello,

I've been trying to perform a dfu to a target Nordic device over Bluetooth using an nrf52840 dongle distributed by Laird, however whenever I attempt to run the command:

nrfutil dfu ble -ic NRF52 -pkg <package_name> -a <target_address>

I get a strange error. I will post the verbose output below, but first let me tell about the environment, packages and what firmware is on my device.

This is running on a Raspberry PI 4, with Buster 10.

I have the latest version of pc-ble-driver built on the device, pc-ble-driver-py version 0.14.2, and nrfutil version 6.1.0.

My nrf52840 dongle is flashed with connectivity_6.0.0_usb_with_s140_6.1.1.hex.

Here is the output from running the command:

Please select connectivity serial port:
        0 : /dev/ttyACM1 - D67B7A98D69A
Enter your choice: : 0
2020-10-08 09:18:03,198 Using connectivity board at serial port: /dev/ttyACM1
2020-10-08 09:18:03,207 Sending Application image.
2020-10-08 09:18:06,616 Successfully opened /dev/ttyACM1. Baud rate: 1000000. Flow control: none. Parity: none.
2020-10-08 09:18:06,617 evt> severity(20) message(Successfully opened /dev/ttyACM1. Baud rate: 1000000. Flow control: none. Parity: none.)
2020-10-08 09:18:06,617 RpcAppStatus.resetPerformed: Target Reset performed
2020-10-08 09:18:06,618 evt> status code(RpcAppStatus.resetPerformed) message(Target Reset performed)
2020-10-08 09:18:07,818 RpcAppStatus.connectionActive: Connection active
2020-10-08 09:18:07,818 evt> status code(RpcAppStatus.connectionActive) message(Connection active)
2020-10-08 09:18:07,823 BLE: Scanning for None
2020-10-08 09:18:08,243 RpcAppStatus.ioResourcesUnavailable: serial port read failed on port /dev/ttyACM1. Error: End of file [2]
2020-10-08 09:18:08,243 evt> status code(RpcAppStatus.ioResourcesUnavailable) message(serial port read failed on port /dev/ttyACM1. Error: End of file [2])
2020-10-08 09:18:09,324 Failed to receive response for command
2020-10-08 09:18:09,324 evt> severity(30) message(Failed to receive response for command)
Traceback (most recent call last):
2020-10-08 09:18:09,325 RpcAppStatus.pktSendError: Error sending packet to target. Code: 0x8016
  File "/usr/local/bin/nrfutil", line 11, in <module>
2020-10-08 09:18:09,325 evt> status code(RpcAppStatus.pktSendError) message(Error sending packet to target. Code: 0x8016)
    load_entry_point('nrfutil==6.1.0', 'console_scripts', 'nrfutil')()
  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/nrfutil-6.1.0-py3.7.egg/nordicsemi/__main__.py", line 1207, in ble
    dfu.dfu_send_images()
  File "/usr/local/lib/python3.7/dist-packages/nrfutil-6.1.0-py3.7.egg/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/nrfutil-6.1.0-py3.7.egg/nordicsemi/dfu/dfu.py", line 88, in _dfu_send_image
    self.dfu_transport.open()
  File "/usr/local/lib/python3.7/dist-packages/nrfutil-6.1.0-py3.7.egg/nordicsemi/dfu/dfu_transport_ble.py", line 476, in open
    target_device_addr = self.target_device_addr)
  File "/usr/local/lib/python3.7/dist-packages/nrfutil-6.1.0-py3.7.egg/nordicsemi/dfu/dfu_transport_ble.py", line 152, in connect
    self.adapter.driver.ble_gap_scan_start()
  File "/home/pi/.local/lib/python3.7/site-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_gap_scan_start. Error code: NRF_ERROR_SD_RPC_SEND

Update:

Some information I forgot to mention was that the target device is using s140_nrf52_6.1.1_softdevice.hex. Now I've since tried different hex files. Before I knew what was really on the target device I tried connectivity_4.1.2_usb_with_s132_5.1.0.hex because it was precompiled with pc-ble-driver-py. The behavior here was that it would perform the update, but fail at 62%. The output was this:

Please select connectivity serial port:
        0 : /dev/ttyACM0 - D67B7A98D69A
Enter your choice: : 0
  [######################--------------]   62%  00:00:30
Traceback (most recent call last):
  File "/usr/local/bin/nrfutil", line 11, in <module>
    load_entry_point('nrfutil==6.1.0', 'console_scripts', 'nrfutil')()
  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/nrfutil-6.1.0-py3.7.egg/nordicsemi/__main__.py", line 1205, in ble
    dfu.dfu_send_images()
  File "/usr/local/lib/python3.7/dist-packages/nrfutil-6.1.0-py3.7.egg/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/nrfutil-6.1.0-py3.7.egg/nordicsemi/dfu/dfu.py", line 100, in _dfu_send_image
    self.dfu_transport.send_firmware(data)
  File "/usr/local/lib/python3.7/dist-packages/nrfutil-6.1.0-py3.7.egg/nordicsemi/dfu/dfu_transport_ble.py", line 572, in send_firmware
    response['crc'] = self.__stream_data(data=data, crc=response['crc'], offset=i)
  File "/usr/local/lib/python3.7/dist-packages/nrfutil-6.1.0-py3.7.egg/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/nrfutil-6.1.0-py3.7.egg/nordicsemi/dfu/dfu_transport_ble.py", line 350, in write_data_point
    self.adapter.write_cmd(self.conn_handle, DFUAdapter.DP_UUID, data)
  File "/home/pi/.local/lib/python3.7/site-packages/pc_ble_driver_py/ble_adapter.py", line 568, in write_cmd
    raise e
  File "/home/pi/.local/lib/python3.7/site-packages/pc_ble_driver_py/ble_adapter.py", line 554, in write_cmd
    response = self.driver.ble_gattc_write(conn_handle, write_params)
  File "/home/pi/.local/lib/python3.7/site-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

After figuring out what was on the target device I've tried the following hex files:

connectivity_4.1.2_usb_with_s140_6.1.1.hex

connectivity_6.1.0_usb_with_s140_6.1.1.hex

connectivity_6.1.1_usb_with_s140_6.1.1.hex

But all of these have exhibited the exact same behavior as in the original post.

  • KRichardson846 said:
    Do you know which version of the sniffer I should be using? I don't see an option for nRF52 Dongle.

    I recommend using the latest version, v3.x.x. As of today, the nRF Sniffer don't support the nRF52840 dongle.

  • Unfortunately I am only using nRF52840 dongles for this project, the target device I believe is using nRF52840 as well but it is not a DK or a dongle.

    If you are trying to recreate the issue, then I will tell you I am using the Laird nRF52480 dongle with connectivity_6.1.1_usb_with_s132_5.1.0.hex firmware on it, I am using the nrfutil command line command "nrfutil dfu ble -ic NRF52 -pkg <my_package> -a <target_address> -mtu 247 -cd 5". This on Ubuntu 18.04 with nrfutil 6.1.0. 

    If you need anymore information let me know!

  • Just one small update. I've tried this same command on Windows 10, using the same firmware on the dongle, and the same versions of nrfutil and pc-ble-driver-py. There is another error that appears often for windows. This error appears to be stemming from the dongle trying to stop a ble scan while there is no scan taking place. Not sure how to deal with this.

    The output is below.

    Traceback (most recent call last):
      File "C:\Users\krichardson\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts\nrfutil-script.py", line 33, in <module>
        sys.exit(load_entry_point('nrfutil==6.1.0', 'console_scripts', 'nrfutil')())
      File "C:\Users\krichardson\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\click\core.py", line 829, in __call__
        return self.main(*args, **kwargs)
      File "C:\Users\krichardson\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\click\core.py", line 782, in main
        rv = self.invoke(ctx)
      File "C:\Users\krichardson\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\click\core.py", line 1259, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "C:\Users\krichardson\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\click\core.py", line 1259, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "C:\Users\krichardson\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\click\core.py", line 1066, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "C:\Users\krichardson\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\click\core.py", line 610, in invoke
        return callback(*args, **kwargs)
      File "C:\Users\krichardson\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\nordicsemi\__main__.py", line 1197, in ble
        dfu.dfu_send_images()
      File "C:\Users\krichardson\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\nordicsemi\dfu\dfu.py", line 127, in dfu_send_images
        self._dfu_send_image(self.manifest.application)
      File "C:\Users\krichardson\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\nordicsemi\dfu\dfu.py", line 88, in _dfu_send_image
        self.dfu_transport.open()
      File "C:\Users\krichardson\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\nordicsemi\dfu\dfu_transport_ble.py", line 474, in open
        self.target_device_name, self.target_device_addr = self.dfu_adapter.connect(
      File "C:\Users\krichardson\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\nordicsemi\dfu\dfu_transport_ble.py", line 153, in connect
        self.verify_stable_connection()
      File "C:\Users\krichardson\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\nordicsemi\dfu\dfu_transport_ble.py", line 262, in verify_stable_connection
        self.adapter.driver.ble_gap_scan_stop()
      File "C:\Users\krichardson\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\wrapt\wrappers.py", line 605, in __call__
        return self._self_wrapper(self.__wrapped__, self._self_instance,
      File "C:\Users\krichardson\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pc_ble_driver_py\ble_driver.py", line 103, in wrapper
        raise NordicSemiException(
    pc_ble_driver_py.exceptions.NordicSemiException: Failed to ble_gap_scan_stop. Error code: NRF_ERROR_INVALID_STATE

  • Hello Sigurd,

    Have you been able to recreate the issue? I have been trying to debug on my end but I still have no answers.

  • Hi,

    I know there was some communication outside of Devzone on this issue, and my impression was that you were able to resolve this issue together with the Nordic FAEs, but in case there are still issues, then note that we a couple of days ago released a new version of pc-ble-driver, v4.1.3, that improves stability when a high amount of notifications are received: https://github.com/NordicSemiconductor/pc-ble-driver/releases/tag/v4.1.3

    I also found this ticket, that might be relevant as well: https://devzone.nordicsemi.com/f/nordic-q-a/68234/unable-to-change-mtu-size-pc-ble-driver-py

Related