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

Parents
  • 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?

Reply Children
No Data
Related