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

Bonbed OTA DFU with nrfutil

Hello,

I'm using the buttonless DFU bootloader examples with bonding and the PC nrfutil with a nRF52840 PDK for the firmware upload.

If I try to start the DFU process a second time with the same targed device, the connection will be refused with an error.

The problem is that the pairing/bonding keys (IRK, LTK, ...) are stored in the Flash of the targed device by the peer manager. But on the PC side the nrfutil tool doesn't save the pairing/bonding keys (IRK, LTK, ...) and tries to perform a new pairing/bonding at each connect to the same targed device. This will be refused by the targed device, because there are already pairing/bonding keys (IRK, LTK, ...) stored from the previous pairing/bonding with this PC.

Is there a solution to store pairing/bonding informations on the PC using nrfutil? Or is there a possibility to solve this problem in another way?

Best regards

Roland

Parents
  • Hi,

    Unfortunately, it is not possible to store bond information across sessions in nrfutil or nrfconnect. You could use nrfconnect as that will keep the bond information for the current sessions.

    An alternative is to modify the peer manager so it allows bond refresh in the application. (But please not that this is also a security issue as other device could use the same address as a previously bonded peer to get a new bond). Change the below code to true, instead of false to enable this feature (will only work in the application, not the bootloader).

            case PM_EVT_CONN_SEC_CONFIG_REQ:
            {
                // Reject pairing request from an already bonded peer.
                pm_conn_sec_config_t conn_sec_config = {.allow_repairing = false};

     

Reply
  • Hi,

    Unfortunately, it is not possible to store bond information across sessions in nrfutil or nrfconnect. You could use nrfconnect as that will keep the bond information for the current sessions.

    An alternative is to modify the peer manager so it allows bond refresh in the application. (But please not that this is also a security issue as other device could use the same address as a previously bonded peer to get a new bond). Change the below code to true, instead of false to enable this feature (will only work in the application, not the bootloader).

            case PM_EVT_CONN_SEC_CONFIG_REQ:
            {
                // Reject pairing request from an already bonded peer.
                pm_conn_sec_config_t conn_sec_config = {.allow_repairing = false};

     

Children
  • Hi,

    I tried pm_conn_sec_config_t conn_sec_config = {.allow_repairing = true};

    With nRF Connect this is working fine, but with nrfutil it doesn't work. At the 2nd upload to the same bonded target device I get the following error output (It looks to be the same as with allow_repairing = false):

    nrfutil -v dfu ble -ic NRF52 -pkg .\_build\nrf52840_xxaa.zip -n "SP_1257304283" -f
    Please select connectivity serial port:
            0 : COM4 - 680825448
            1 : COM5 - 683703628
            2 : COM7 - 683757419
    Enter your choice: : 2
    Board already flashed with connectivity firmware.
      [------------------------------------]    0%2018-08-29 13:27:20,512 Exception: UUID not found
    2018-08-29 13:27:20,516 ('c:\\python27\\lib\\site-packages\\pc_ble_driver_py\\ble_driver.py', 1483, 'sync_ble_evt_handler', 'data           = util.uint8_array_t
    o_list(hvx_evt.data, hvx_evt.len))')
    2018-08-29 13:27:20,516 ('c:\\python27\\lib\\site-packages\\wrapt\\wrappers.py', 562, '__call__', 'args, kwargs)')
    2018-08-29 13:27:20,517 ('c:\\python27\\lib\\site-packages\\wrapt\\decorators.py', 440, '_synchronized', 'return wrapped(*args, **kwargs)')
    2018-08-29 13:27:20,517 ('c:\\python27\\lib\\site-packages\\pc_ble_driver_py\\ble_adapter.py', 486, 'on_gattc_evt_hvx', "raise NordicSemiException('UUID not fou
    nd')")
    2018-08-29 13:27:20,519

    Traceback (most recent call last):
      File "C:\Python27\Scripts\nrfutil-script.py", line 11, in <module>
        load_entry_point('nrfutil==3.5.1', 'console_scripts', 'nrfutil')()
      File "c:\python27\lib\site-packages\click\core.py", line 722, in __call__
        return self.main(*args, **kwargs)
      File "c:\python27\lib\site-packages\click\core.py", line 697, in main
        rv = self.invoke(ctx)
      File "c:\python27\lib\site-packages\click\core.py", line 1066, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "c:\python27\lib\site-packages\click\core.py", line 1066, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "c:\python27\lib\site-packages\click\core.py", line 895, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "c:\python27\lib\site-packages\click\core.py", line 535, in invoke
        return callback(*args, **kwargs)
      File "c:\python27\lib\site-packages\nordicsemi\__main__.py", line 838, in ble
        dfu.dfu_send_images()
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu.py", line 129, in dfu_send_images
        self._dfu_send_image(self.manifest.application)
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu.py", line 90, in _dfu_send_image
        self.dfu_transport.open()
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu_transport_ble.py", line 453, in open
        target_device_addr = self.target_device_addr)
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu_transport_ble.py", line 153, in connect
        self.jump_from_buttonless_mode_to_bootloader(DFUAdapter.BLE_DFU_BUTTONLESS_BONDED_CHAR_UUID)
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu_transport_ble.py", line 196, in jump_from_buttonless_mode_to_bootloader
        response = self.indication_q.get(timeout=DfuTransportBle.DEFAULT_TIMEOUT)
      File "c:\python27\lib\Queue.py", line 176, in get
        raise Empty
    Queue.Empty

    What could be the reason that it doesn't work with nrfutil?

    Best regards

    Roland

  • Hi,

    The error output form nrfutil with allow_repairing = false is different:

    nrfutil -v dfu ble -ic NRF52 -pkg .\_build\nrf52840_xxaa.zip -n "SP_1257304283" -f
    Please select connectivity serial port:
            0 : COM4 - 680825448
            1 : COM5 - 683703628
            2 : COM7 - 683757419
    Enter your choice: : 2
    Board already flashed with connectivity firmware.
      [------------------------------------]    0%2018-08-29 14:01:17,878 Exception: UUID not found
    2018-08-29 14:01:17,884 ('c:\\python27\\lib\\site-packages\\pc_ble_driver_py\\ble_driver.py', 1483, 'sync_ble_evt_handler', 'data           = util.uint8_array_t
    o_list(hvx_evt.data, hvx_evt.len))')
    2018-08-29 14:01:17,884 ('c:\\python27\\lib\\site-packages\\wrapt\\wrappers.py', 562, '__call__', 'args, kwargs)')
    2018-08-29 14:01:17,884 ('c:\\python27\\lib\\site-packages\\wrapt\\decorators.py', 440, '_synchronized', 'return wrapped(*args, **kwargs)')
    2018-08-29 14:01:17,884 ('c:\\python27\\lib\\site-packages\\pc_ble_driver_py\\ble_adapter.py', 486, 'on_gattc_evt_hvx', "raise NordicSemiException('UUID not fou
    nd')")
    2018-08-29 14:01:17,885

    Traceback (most recent call last):
      File "C:\Python27\Scripts\nrfutil-script.py", line 11, in <module>
        load_entry_point('nrfutil==3.5.1', 'console_scripts', 'nrfutil')()
      File "c:\python27\lib\site-packages\click\core.py", line 722, in __call__
        return self.main(*args, **kwargs)
      File "c:\python27\lib\site-packages\click\core.py", line 697, in main
        rv = self.invoke(ctx)
      File "c:\python27\lib\site-packages\click\core.py", line 1066, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "c:\python27\lib\site-packages\click\core.py", line 1066, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "c:\python27\lib\site-packages\click\core.py", line 895, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "c:\python27\lib\site-packages\click\core.py", line 535, in invoke
        return callback(*args, **kwargs)
      File "c:\python27\lib\site-packages\nordicsemi\__main__.py", line 838, in ble
        dfu.dfu_send_images()
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu.py", line 129, in dfu_send_images
        self._dfu_send_image(self.manifest.application)
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu.py", line 90, in _dfu_send_image
        self.dfu_transport.open()
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu_transport_ble.py", line 453, in open
        target_device_addr = self.target_device_addr)
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu_transport_ble.py", line 153, in connect
        self.jump_from_buttonless_mode_to_bootloader(DFUAdapter.BLE_DFU_BUTTONLESS_BONDED_CHAR_UUID)
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu_transport_ble.py", line 181, in jump_from_buttonless_mode_to_bootloader
        self.bond()
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu_transport_ble.py", line 312, in bond
        None)
      File "c:\python27\lib\site-packages\wrapt\wrappers.py", line 562, in __call__
        args, kwargs)
      File "c:\python27\lib\site-packages\pc_ble_driver_py\ble_driver.py", line 126, in wrapper
        raise NordicSemiException('Failed to {}. Error code: {}'.format(wrapped.__name__, err_code))
    pc_ble_driver_py.exceptions.NordicSemiException: Failed to ble_gap_sec_params_reply. Error code: 8

  • Hi,

    I have still the problem, that nrfutil chrashes with pm_conn_sec_config_t conn_sec_config = {.allow_repairing = true}; in the application.

    nrfutil -v dfu ble -ic NRF52 -pkg .\_build\nrf52840_xxaa.zip -n "SP_1257304283" -f
    Please select connectivity serial port:
            0 : COM4 - 680825448
            1 : COM5 - 683703628
            2 : COM7 - 683757419
    Enter your choice: : 2
    Board already flashed with connectivity firmware.
      [------------------------------------]    0%2018-08-29 13:27:20,512 Exception: UUID not found
    2018-08-29 13:27:20,516 ('c:\\python27\\lib\\site-packages\\pc_ble_driver_py\\ble_driver.py', 1483, 'sync_ble_evt_handler', 'data           = util.uint8_array_t
    o_list(hvx_evt.data, hvx_evt.len))')
    2018-08-29 13:27:20,516 ('c:\\python27\\lib\\site-packages\\wrapt\\wrappers.py', 562, '__call__', 'args, kwargs)')
    2018-08-29 13:27:20,517 ('c:\\python27\\lib\\site-packages\\wrapt\\decorators.py', 440, '_synchronized', 'return wrapped(*args, **kwargs)')
    2018-08-29 13:27:20,517 ('c:\\python27\\lib\\site-packages\\pc_ble_driver_py\\ble_adapter.py', 486, 'on_gattc_evt_hvx', "raise NordicSemiException('UUID not fou
    nd')")
    2018-08-29 13:27:20,519

    Traceback (most recent call last):
      File "C:\Python27\Scripts\nrfutil-script.py", line 11, in <module>
        load_entry_point('nrfutil==3.5.1', 'console_scripts', 'nrfutil')()
      File "c:\python27\lib\site-packages\click\core.py", line 722, in __call__
        return self.main(*args, **kwargs)
      File "c:\python27\lib\site-packages\click\core.py", line 697, in main
        rv = self.invoke(ctx)
      File "c:\python27\lib\site-packages\click\core.py", line 1066, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "c:\python27\lib\site-packages\click\core.py", line 1066, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "c:\python27\lib\site-packages\click\core.py", line 895, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "c:\python27\lib\site-packages\click\core.py", line 535, in invoke
        return callback(*args, **kwargs)
      File "c:\python27\lib\site-packages\nordicsemi\__main__.py", line 838, in ble
        dfu.dfu_send_images()
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu.py", line 129, in dfu_send_images
        self._dfu_send_image(self.manifest.application)
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu.py", line 90, in _dfu_send_image
        self.dfu_transport.open()
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu_transport_ble.py", line 453, in open
        target_device_addr = self.target_device_addr)
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu_transport_ble.py", line 153, in connect
        self.jump_from_buttonless_mode_to_bootloader(DFUAdapter.BLE_DFU_BUTTONLESS_BONDED_CHAR_UUID)
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu_transport_ble.py", line 196, in jump_from_buttonless_mode_to_bootloader
        response = self.indication_q.get(timeout=DfuTransportBle.DEFAULT_TIMEOUT)
      File "c:\python27\lib\Queue.py", line 176, in get
        raise Empty
    Queue.Empty

    Is there a solution solving this problem?

    Best regards

    Roland

  • Hi,

    I am really sorry for the late reply, this seems to have fallen out of my radar. Are you still having issues with this or where you able to resolve it?

  • Hi,
    This problem is still existing.
    Best Regards
    Roland

Related