nRF52832 ble_dfu_buttonless_async_svci_init() failed with errCode=0x4

I change nRF52832 firmware to support DFU OTA. But ble_dfu_buttonless_async_svci_init() failed with errCode=0x4.

 0> <info> app: Version 1.2.1
 0>
 0> <info> app: ========| flash info |========
 0> <info> app: erase unit:   4096 bytes
 0> <info> app: program unit: 4 bytes
 0> <info> app: end address: 0x7FFFF
 0> <info> app: ==============================
 0> <info> app_timer: RTC: initialized.
 0> <error> app: No bootloader was found
 0> <warning> app: ble_dfu_buttonless_async_svci_init() failed, errCode=0x4

  • static void services_init(void)
    {
        ret_code_t             ret;
        nrf_ble_gatts_c_init_t gatts_c_init;
        nrf_ble_qwr_init_t qwr_init = {0};

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

        ret = nrf_ble_qwr_init(&m_qwr, &qwr_init);
        if (ret != NRF_SUCCESS) {
            NRF_LOG_WARNING("services_init 1 failed err_code=0x%x", ret);
        }
        APP_ERROR_CHECK(ret);

        // Init the GATTS client module.
        memset(&gatts_c_init, 0, sizeof(gatts_c_init));

        gatts_c_init.evt_handler  = gatts_c_evt_handler;
        gatts_c_init.p_gatt_queue = &m_ble_gatt_queue;

        ret = nrf_ble_gatts_c_init(&m_gatts_c, &gatts_c_init);
        if (ret != NRF_SUCCESS) {
            NRF_LOG_WARNING("services_init 2 failed err_code=0x%x", ret);
        }
        APP_ERROR_CHECK(ret);

        qwr_init.error_handler = nrf_qwr_error_handler;
        ret = nrf_ble_qwr_init(&m_qwr, &qwr_init);    
    #if BLE_DFU_APP_SUPPORT
        bleDfuInit();
    #endif
            
        BLE_Uart_Init(UartProfile_RX_EventHandler);
        batteryBleInit();
        
    }

  • #include "ota.h"
    #include "advertising.h"
    #include "ble_conn_state.h"
    #include "ble_dfu.h"
    #include "error.h"
    #include "nrf_log.h"
    
    #if BLE_DFU_APP_SUPPORT
    static void _bleDfuDisconnect(const uint16_t connHandle, void* pContext) {
        UNUSED_PARAMETER(pContext);
        const ret_code_t errCode = sd_ble_gap_disconnect(connHandle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
        if (errCode != NRF_SUCCESS) {
            NRF_LOG_WARNING("Failed to disconnect connection. Connection handle: %d Error: 0x%x\n", connHandle, errCode);
            return;
        }
        
        NRF_LOG_INFO("Disconnected connection handle %d", connHandle);
    }
    
    // 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 _bleDfuEvtHandler(ble_dfu_buttonless_evt_type_t event) {
        switch (event) {
            case BLE_DFU_EVT_BOOTLOADER_ENTER_PREPARE:
            {
                NRF_LOG_INFO("BLE_DFU_EVT_BOOTLOADER_ENTER_PREPARE");
    
                // Prevent device from advertising on disconnect.
                advertisingModesConfigSet();
    
                // 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(_bleDfuDisconnect, 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("BLE_DFU_EVT_BOOTLOADER_ENTER\n");
            }    
            break;
    
            case BLE_DFU_EVT_BOOTLOADER_ENTER_FAILED:
            {
                NRF_LOG_ERROR("BLE_DFU_EVT_BOOTLOADER_ENTER_FAILED\n");
                // 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("BLE_DFU_EVT_RESPONSE_SEND_ERROR\n");
                // YOUR_JOB: Take corrective measures to resolve the issue
                //           like calling APP_ERROR_CHECK to reset the device.
            }    
            break;
    
            default:
            {
                NRF_LOG_ERROR("Unknown event from ble_dfu_buttonless.");
            }    
            break;
        }
    }
    
    int bleDfuInit(void) {
        ret_code_t errCode = ble_dfu_buttonless_async_svci_init();
        if (errCode != NRF_SUCCESS) {
            NRF_LOG_WARNING("ble_dfu_buttonless_async_svci_init() failed, errCode=0x%x\n", errCode);
            return ERROR_OTA_INITIALIZE_FAIL;
        }
    
        ble_dfu_buttonless_init_t init = {0};
        init.evt_handler = _bleDfuEvtHandler;
        errCode = ble_dfu_buttonless_init(&init);
        if (errCode != NRF_SUCCESS) {
            NRF_LOG_WARNING("ble_dfu_buttonless_init() failed\n");
            return ERROR_OTA_INITIALIZE_FAIL;
        }    
    
        return 0;
    }    
    #endif
    
    2626.ota.h

  • Hi, 

    What SDK version are you using?

    Do you program with the BLE Secure DFU Bootloader?

    To run your application with the buttonless DFU, you would also flash the Bootloader settings page

    Regards,
    Amanda

  • Thanks for your reply! Sdk version 16.0.0. I am building ble secure dfu booter source code. Can I program it through j-link?

Related