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

How to merge one Application with DFU feature.

Hello All,

I am trying to merge one of the application example with DFU feature.

Development setup - OS windows 10, 64 bit

                                   IDE Segger embedded studio V_4.16 with nRF52 DK, sdk version 15 .

I have tried the this many times but i could not. Facing lot of problems from last week.

I have tried with combining secure dfu example with  ble_proximity example and wise-versa.

But facing linking problems for some of the files./ remove .o files,/.h file not defined etc..

So If some one knows the right procedure / steps how to merge/combining.

Then please let me know.

Provide your inputs.

Regards,

Rohit

Parents
  • Hi Rohit, 

    i suggest that you take a look at the Buttonless DFU Template Application in our SDK. You need to add the following .c files to the project you want to add DFU support to

    • ble_dfu.c
    • ble_dfu_unbonded.c
    • ble_dfu_bonded.c
    • nrf_dfu_svci.c

    Then you need to add the following snippet to main() after log_init()

       // Initialize the async SVCI interface to bootloader before any interrupts are enabled.
        err_code = ble_dfu_buttonless_async_svci_init();
        APP_ERROR_CHECK(err_code);
    

    add the following snippet to services_init()

      
        ble_dfu_buttonless_init_t dfus_init = {0};
    
        dfus_init.evt_handler = ble_dfu_evt_handler;
    
        err_code = ble_dfu_buttonless_init(&dfus_init);
        APP_ERROR_CHECK(err_code);

    add the following function to main.c before services_init()

    / YOUR_JOB: Update this code if you want to do anything given a DFU event (optional).
    /**@brief Function for handling dfu events from the Buttonless Secure DFU service
     *
     * @param[in]   event   Event from the Buttonless Secure DFU service.
     */
    static void ble_dfu_evt_handler(ble_dfu_buttonless_evt_type_t event)
    {
        switch (event)
        {
            case BLE_DFU_EVT_BOOTLOADER_ENTER_PREPARE:
            {
                NRF_LOG_INFO("Device is preparing to enter bootloader mode.");
    
                // Prevent device from advertising on disconnect.
                ble_adv_modes_config_t config;
                advertising_config_get(&config);
                config.ble_adv_on_disconnect_disabled = true;
                ble_advertising_modes_config_set(&m_advertising, &config);
    
                // Disconnect all other bonded devices that currently are connected.
                // This is required to receive a service changed indication
                // on bootup after a successful (or aborted) Device Firmware Update.
                uint32_t conn_count = ble_conn_state_for_each_connected(disconnect, NULL);
                NRF_LOG_INFO("Disconnected %d links.", conn_count);
                break;
            }
    
            case BLE_DFU_EVT_BOOTLOADER_ENTER:
                // YOUR_JOB: Write app-specific unwritten data to FLASH, control finalization of this
                //           by delaying reset by reporting false in app_shutdown_handler
                NRF_LOG_INFO("Device will enter bootloader mode.");
                break;
    
            case BLE_DFU_EVT_BOOTLOADER_ENTER_FAILED:
                NRF_LOG_ERROR("Request to enter bootloader mode failed asynchroneously.");
                // YOUR_JOB: Take corrective measures to resolve the issue
                //           like calling APP_ERROR_CHECK to reset the device.
                break;
    
            case BLE_DFU_EVT_RESPONSE_SEND_ERROR:
                NRF_LOG_ERROR("Request to send a response to client failed.");
                // YOUR_JOB: Take corrective measures to resolve the issue
                //           like calling APP_ERROR_CHECK to reset the device.
                APP_ERROR_CHECK(false);
                break;
    
            default:
                NRF_LOG_ERROR("Unknown event from ble_dfu_buttonless.");
                break;
        }
    }

    In sdk_config.h you will need to increase the NRF_SDH_BLE_VS_UUID_COUNT by 1 to accommodate the DFU service UUID which is a vendor-specific UUID. 

    Best regards

    Bjørn

  • Please see this attached image . If i run the program then this will occur so what steps i have to take to solve this problem..

    i have not change anything , just added the DFU file, now its not advertising .

    Please reply.

  • Error code 4 is NRF_ERROR_NO_MEM, so there is a function returning this and its is being caught by   APP_ERROR_CHECK(err_code);

    Set a breakpoint in app_error_handler_bare and look at the call stack to figure out which function it is. 

Reply Children
Related