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

DFU buttonless with Bond not working.

Hello there,

First of all, I had searched similar issue internally but didn't find any solution.

My problem is for my application with DFU buttonless without bond everything is okay. So I just followed the instruction (https://devzone.nordicsemi.com/nordic/short-range-guides/b/software-development-kit/posts/getting-started-with-nordics-secure-dfu-bootloader#h61sjziauupw1j397q9s9ldr01q4j6d5) to add bond. It seemed pretty straightforward. The program stuck at   

err_code = ble_dfu_buttonless_init(&dfus_init);
    APP_ERROR_CHECK(err_code);

Here is the debug info

"<00> info> app: Setting vector table to bootloader: 0x00078000


<00> debug> app: nrf_dfu_svci_vector_table_set() -> success


<00> debug> app: nrf_dfu_set_peer_data_init() -> success


<00> info> app: Setting vector table to main app: 0x00026000


<00> debug> app: nrf_dfu_svci_vector_table_unset() -> success


<00> error> app: ERROR 8 [NRF_ERROR_INVALID_STATE] at ..\..\..\main.c:777
00> PC at: 0x00031A4B


<00> error> app: End of error report

"

here is where ble_dfu_buttonless_init located in my code

static void services_init(void)
{
    ret_code_t         err_code;
    ble_lbs_init_t     init;
    ble_nus_init_t nus_init;
    nrf_ble_qwr_init_t qwr_init = {0};
        ble_dfu_buttonless_init_t dfus_init = {0};

    // Initialize Queued Write Module instances.
    qwr_init.error_handler = nrf_qwr_error_handler;

    for (uint32_t i = 0; i < LINK_TOTAL; i++)
    {
        err_code = nrf_ble_qwr_init(&m_qwr[i], &qwr_init);
        APP_ERROR_CHECK(err_code);
    }
        //Initialize DFU
        
            // Initialize the async SVCI interface to bootloader.
    err_code = ble_dfu_buttonless_async_svci_init();
    APP_ERROR_CHECK(err_code);

    dfus_init.evt_handler = ble_dfu_evt_handler;

    err_code = ble_dfu_buttonless_init(&dfus_init);
    APP_ERROR_CHECK(err_code);
        
    // Initialize LBS.
    init.led_write_handler = led_write_handler;

    err_code = ble_lbs_init(&m_lbs, &init);
    APP_ERROR_CHECK(err_code);
        


    // Initialize NUS.
    memset(&nus_init, 0, sizeof(nus_init));

    nus_init.data_handler = nus_data_handler;

    err_code = ble_nus_init(&m_nus, &nus_init);
    APP_ERROR_CHECK(err_code);

    ble_conn_state_init();
}

Here is main function

int main(void)
{
    
        bool erase_bonds;
     ret_code_t err_code;
    // Initialize.
    
        err_code = clock_config();
    APP_ERROR_CHECK(err_code);
  
    
    uart_init();
    log_init();
    timers_init();
    leds_init();
    buttons_init();
    power_management_init();

    ble_stack_init();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();
        peer_manager_init(erase_bonds);

        start_app_timer();

    advertising_start(erase_bonds);

    // Enter main loop.
    for (;;)
    {
        idle_state_handle();
    }
}

Then I used ble_app_buttonless_dfu example and changed sdk_config.h to bond. It also worked fine.

So it must be something wrong with my services_init(). But I just cannot figure it out.

Thank you.

Related