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

Questions regarding DFU, Bonding and iOS (caching)

Hi,

I have some questions regarding DFU, Bonding and iOS (caching). In my current project I have a DFU bootloader which does not use bonds, however the application uses bonds.

The current setup is that the DFU bootloader uses a different MAC-address than the application, this way iOS will treat the DFU bootloader and the application as two different devices and caching is not an issue. Is this an okay solution or would it be preferable to use bonds in the DFU FW since the application uses it?

If using bonds with the DFU and adding the Services Changed characteristic and the application is it possible to share the bonding information between Application and DFU FWs? Is there any example that uses bonds for both DFU and application? From what I've read the DFU FW does not know where the App stores the bonding information and vice versa.

I've have tried changing the DFU FW to also use bonds, however I run into issues when I try to mergehex the settings file for the application with the hex for SD + APP + Bootloader, I'm assuming this is because there are overlapping memory addresses.

HW: nRF52832

SDK: 15.0

Softdevice: 6.0

Br,
Anton

  • Hi again Björn,

    I've started working on calling nrf_dfu_set_peer_data.

    From nrf_dfu_set_peer_data_on_call() I can see that it takes two parameters, a struct (nrf_dfu_peer_data_t) and an enum (nrf_dfu_peer_data_state_t).

    Currently I'm trying to fill the nrf_dfu_peer_data_t struct with the correct information:

    uint32_t            crc;                                    
    ble_gap_id_key_t    ble_id;
    ble_gap_enc_key_t   enc_key;
    uint8_t             sys_serv_attr[SYSTEM_SERVICE_ATT_SIZE];
    

    I'm using pm_peer_data_load() to retrieve the system attributes, ble id (IRK) and encryption key for all bonded peers.

    To calculate crc the plan is to use crc32_compute() to calculate the CRC for each bonded peer.

    Does this sound correct?

    Edit: Im also slightly unsure which file to include from my application to make the function nrf_dfu_set_peer_data available. NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS is set to 1 in the application sdk_config.h.

    / Anton

  • Hi Anton, 

    I recommend taking a look at the Buttonless DFU Template Application and the ble_dfu_bonded.c file. It shows how we use pm_peer_data_bonding_load() to retreive the bonding data and then pass it on to the bootloader using nrf_dfu_set_peer_data().

    Note that we do not support bond sharing for more than one peer, i.e. the central that will initiate the DFU process.

    Best regards

    Bjørn

  • Thanks for the tips.

    I think I understand how to pass the information now.

    However I'm struggling to call the bootloader SVC interface. All I'm getting is implicit declaration when I try to call nrf_dfu_set_peer_data. NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS is set to 1, and I've tried to include various dfu files without any success.

    Edit: I'm doing it wrong I think. If I understand the source code correctly If I just enable NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS the Buttonless DFU service will call nrf_dfu_set_peer_data() when a bonded device writes to the characteristic?

  • Yes, enabling NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS in sdk_config.h in both the application and bootloader is all that is needed for bond sharing. 

    The application will then call nrf_dfu_set_peer_data() prior to resetting to the bootloader. 

    Bjørn

  • I've got the build working now.

    However when I try to initialize the async SVC interface it fails with error code 8 (NRF_INVALID_STATE).

    <info> app: Initialized GATT
    <info> app: Initialized services.
    <info> app: Setting vector table to bootloader: 0x00072000
    <info> app: Setting vector table to main app: 0x00026000
    *Reboot*

    Edit: With DEBUG enabled:

    <info> app: Initialized GATT
    <info> app: Setting vector table to bootloader: 0x00072000
    <debug> app: nrf_dfu_svci_vector_table_set() -> success
    <debug> app: nrf_dfu_set_peer_data_init() -> success
    <info> app: Setting vector table to main app: 0x00026000
    <debug> app: nrf_dfu_svci_vector_table_unset() -> success
    

Related