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

DFU with bonds issue

Hello!

I'm trying to add bonding to my DFU. The DFU without bonds works perfectly but when I set  #define NRF_DFU_BLE_REQUIRES_BONDS  and NRF_SDH_BLE_SERVICE_CHANGED to 1 the code crashes.

Any idea how to fix this?

Thanks for the help!

SDK5 15.2, SES, nRF52832

  • Hi Gerardo, 

    The 0x03 error code is NRF_ERROR_INTERNAL.

    Can you set a breakpoint in app_error_handler_bare() in main.c and then look at the call stack when this breakpoint is hit? Which function is generating the error code?

    I believe its the following snippet that is called after  ble_stack_init() in ble_dfu_transport_init() in nrf_dfu_ble.c that is causing the error, i.e. that nrf_dfu_settings_peer_data_is_valid() returns false, 

    #if (NRF_DFU_BLE_REQUIRES_BONDS)
        /* Copy out the peer data if bonds are required */
        if (nrf_dfu_settings_peer_data_is_valid())
        {
            NRF_LOG_DEBUG("Copying peer data");
    
            err_code = nrf_dfu_settings_peer_data_copy(&m_peer_data);
            UNUSED_RETURN_VALUE(err_code);
        }
        else
        {
            APP_ERROR_HANDLER(NRF_ERROR_INTERNAL);
        }
    #else

    It this is the case, then could you try to flash nRF52832 with  the Buttonless DFU example with NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS set to 1 in addition to the bootloader and SD. And then also generate a bootloader settings page using nrfutil with the compiled application hex as input and flash that as well. 

    This should ensure that the device jumps to the application first, which sets the peer data. You can then try to perform DFU, which should now work. 

    Best regards

    Bjørn

  • Thanks for the fast answer.

    Yeah, that is what is causing an error.

    I tried to do what you suggested but it's not working. Since it's the first time I am using nrfutil for the bootloader settings page i will explain step by step what i did.

    1.  NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS to 1 in ble_app_buttonless_dfu_pca10040_s132.hex

    2. nrfutil settings generate --family NRF52 --application ble_app_buttonless_dfu_pca10040_s132.hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 settings.hex

    3. then merged the SD, bootloader and the settings.hex i just created using  mergehex -m settings.hex secure_bootloader_ble_s132_pca10040_debug.hex s132_nrf52_6.1.0_softdevice.hex -o output_file.hex

    4. nrfjprog -f NRF52 --program output_file.hex --chiperase

    Could you explain me what I am doingwrong?

    As a possible solution, I was wondering if there was possible to do something like this

    #if (NRF_DFU_BLE_REQUIRES_BONDS)
        /* Copy out the peer data if bonds are required */
        if (nrf_dfu_settings_peer_data_is_valid())
        {
            NRF_LOG_DEBUG("Copying peer data");
    
            err_code = nrf_dfu_settings_peer_data_copy(&m_peer_data);
            UNUSED_RETURN_VALUE(err_code);
        }
        else
        {
            restart_application_hex();
        }
    #else

  • Still no success, any idea of what I am doing wrong?

  • Hi Gerardo, 

    I sincerly appologize for the late reply. I did a quick test with the secure bootloader and buttonless DFU example from SDK v15.2.0 and I did not see any issues when doing this in this order:

    1. Set NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS to 1 in the sdk_config.h file of the ble_app_buttonless_dfu project.
    2. Set NRF_DFU_BLE_REQUIRES_BONDS to 1 and NRF_SDH_BLE_SERVICE_CHANGED to 1 in the sdk_config.h file of the secure_bootloader project.
    3. Replace the 
    4. Compile both projects
    5. Download nrfutil v4.0.0 or newer from https://github.com/NordicSemiconductor/pc-nrfutil/releases
    6. Generate the settings page using the following nrfutil command
      nrfutil.exe settings generate --family NRF52 --application ble_app_buttonless_dfu_pca10040_s132.hex --application-version 1 --bl-settings-version 1 --bootloader-version 1 settings.hex
      

    7. Use mergehex to merge the SD, BL and APP using the following command:
      mergehex -m ble_app_buttonless_dfu_pca10040_s132.hex s132_nrf52_6.1.0_softdevice.hex secure_bootloader_ble_s132_pca10040_debug.hex -o sd_ble_app.hex
    8. Use mergehex to merge the sd_ble_app.hex with the settings.hex:
      mergehex -m sd_ble_app.hex settings.hex -o sd_ble_app_settings.hex
    9. Flash the combined SD, BL and APP + Settings hex file to the nRF5X device:
      nrfjprog --program sd_ble_app_settings.hex --chiperase --reset
    10. nRF5x device should start advertising as "Nordic_Buttonless"

    Best regards
    Bjørn

Related