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.

  • Hello Sir,

    I have kept the break point on the app_error_handler_bare. seen below data

    uint32_t nrf_dfu_svci_vector_table_set(void)  in this function it is not satisfying the condition " if (bootloader_addr != 0xFFFFFFFF)" and taking this condition

    NRF_LOG_ERROR("No bootloader was found");
    return NRF_ERROR_NO_MEM;

    and then

    It is going to system reset file to "core_cm4.h" - void NVIC_SystemReset(void) function.

    and stuck in below stuff

    And  i thought its memory problem so just i have removed all services and just added dfu then it is showing this kind of errors and in hardware it is not advertising the name of the device.

    if we add with all service with dfu then similar issue will arise.

    And if we just exclude dfu the it will advertise the name of device.

    What is the main cause for this i am not getting.

    Please provide your input on this to solve.

    Regards,

    Rohit 

  • Hello Bjorm,

    Thanks for helping to solve above issue.

    Its ROM and RAM size issue.

    Issue is resolved successfully. 

    Thanks,

    Rohit

  • Just addition to this we have to DISABLE 

    NRF_FRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 

    in sdk_config.h file  to see the info in the debug terminal when we debug the code so you can get the issue info with specific file. So we can edit the required change as mentioned in the degbug terminal.

    plus nrf_log_logging and NRF_LOG_BACKEND_RTT_ENABLED should be enable in sdk_config.h file.

  • Hi Rohit, I'm looking at exact the same error, when adding DFU support to another example. Could you tell me how you solved this exactly? What are the correct RAM and ROM sizes and where can I set them? Thanks in advance!  kind regards, Sitan van Sluis

  • Hello Sitan,

    You can follow the procedure given by Bjørn Sir above.

    And 

    Just addition to this we have to DISABLE 

    NRF_FRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 

    in sdk_config.h file  to see the info in the debug terminal when we debug the code so you can get the issue info with specific file. So we can edit the required change as mentioned in the degbug terminal.

    plus nrf_log_logging and NRF_LOG_BACKEND_RTT_ENABLED should be enable in sdk_config.h file.

    So you can get actual size in debug console.

    Regards,

    Rohit

Reply
  • Hello Sitan,

    You can follow the procedure given by Bjørn Sir above.

    And 

    Just addition to this we have to DISABLE 

    NRF_FRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 

    in sdk_config.h file  to see the info in the debug terminal when we debug the code so you can get the issue info with specific file. So we can edit the required change as mentioned in the degbug terminal.

    plus nrf_log_logging and NRF_LOG_BACKEND_RTT_ENABLED should be enable in sdk_config.h file.

    So you can get actual size in debug console.

    Regards,

    Rohit

Children
No Data
Related