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.

  • Hi,

    We have seen the NRF_ERROR_SD_RPC_NO_RESPONSE issue in the past on the nRF5x DKs as well. There the on-board Segger Jlink chip is used as an USB-UART bridge, and on some systems data corruption can happen when large USB packets are sent. The root cause is a bug in the Segger’s J-Link firmware. The usual way to solve it there has been to disable the Mass Storage Device functionality.

    Start JLinkExe
    Enter “MSDDisable”
    Exit JLinkExe
    Powercycle the DK

    It's the first time I have seen the issue on a Raspberry PI. Maybe there are some similar Raspberry PI USB options to disable MSD functionality that can be tested.

     

    KRichardson846 said:
    Do you know what could be causing the NRF_ERROR_INVALID_PARAM error from the log output I provided in my other reply to this post?
    KRichardson846 said:
    It seems to have something to do with setting the MTU.

     It could be that a too large MTU value is being requested.

    Are you able to print the MTU value ?

  • I've noticed that the NRF_ERROR_INVALID_PARAM argument happens more whenever I do not specify an mtu amout when calling nrfutil dfu ble. It happens the least when I use 257 (the max) as the size, but if I use the minimum value (23) then 100% of the time I get an error that says "Unable to successfully call ble_gattc_write". 

    I actually do not even have the seggar jlink drivers installed on either the PI or the Linux box. I figured I didn't need them.

  • So I've found that on Linux that setting the connection delay when running nrfutil to 5 seems to get rid of the NRF_ERROR_SD_RPC_NO_RESPONSE error all together. I've since given up on the PI since there seems to be far too many issues there.

    The only thing I am still getting is the NRF_ERROR_INVALID_PARAM error. I am setting the mtu to 247 when running the command, and 247 should be a valid number since it is the maximum. Why would it say that 247 is invalid? I'll post the output here.

    Traceback (most recent call last):
      File "/home/mtd/.local/lib/python3.6/site-packages/pc_ble_driver_py/ble_adapter.py", line 216, in att_mtu_exchange
        self.driver.ble_gattc_exchange_mtu_req(conn_handle, mtu)
      File "/home/mtd/.local/lib/python3.6/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_exchange_mtu_req. Error code: NRF_ERROR_INVALID_PARAM
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/home/mtd/.local/bin/nrfutil", line 8, in <module>
        sys.exit(cli())
      File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 829, in __call__
        return self.main(*args, **kwargs)
      File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 782, in main
        rv = self.invoke(ctx)
      File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1259, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1259, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1066, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 610, in invoke
        return callback(*args, **kwargs)
      File "/home/mtd/.local/lib/python3.6/site-packages/nordicsemi/__main__.py", line 1197, in ble
        dfu.dfu_send_images()
      File "/home/mtd/.local/lib/python3.6/site-packages/nordicsemi/dfu/dfu.py", line 127, in dfu_send_images
        self._dfu_send_image(self.manifest.application)
      File "/home/mtd/.local/lib/python3.6/site-packages/nordicsemi/dfu/dfu.py", line 88, in _dfu_send_image
        self.dfu_transport.open()
      File "/home/mtd/.local/lib/python3.6/site-packages/nordicsemi/dfu/dfu_transport_ble.py", line 476, in open
        target_device_addr = self.target_device_addr)
      File "/home/mtd/.local/lib/python3.6/site-packages/nordicsemi/dfu/dfu_transport_ble.py", line 173, in connect
        self.att_mtu = self.adapter.att_mtu_exchange(self.conn_handle, DFUAdapter.LOCAL_ATT_MTU)
      File "/home/mtd/.local/lib/python3.6/site-packages/pc_ble_driver_py/ble_adapter.py", line 221, in att_mtu_exchange
        "different config tags used in ble_cfg_set and connect.") from ex
    pc_ble_driver_py.exceptions.NordicSemiException: MTU exchange request failed. Common causes are: missing att_mtu setting in ble_cfg_set, different config tags used in ble_cfg_set and connect.
    

  • Hi,

    It looks like there are some other users with this issue, ref. this github issue.

    So there could potentially be some bugs with pc-ble-driver-py code, or the connectivity FW in this case.

    You are using connectivity_4.1.2_usb_with_s132_5.1.0.hex, correct ?

    I can try to reproduce the issue here, but if you have a nRF52 development kit, it would be helpful if you could do a nRF Sniffer trace when this happens, and upload the sniffer log here.

  • Hi Sigurd,

    Right now I am actually using connectivity_6.1.1_usb_with_s132_5.1.0.hex.

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

Related