nRF52832 buttonless DFU without bonds failed

I use nRF Connect to test  buttonless DFU without bonds failed. But nRF52832 receives BLE_GATTS_EVT_SYS_ATTR_MISSING event.

->static void ble_evt_handler(ble_evt_t const* pBleEvt, void* pContext)
->{
->    ret_code_t errCode = NRF_SUCCESS;
->   
->   switch (pBleEvt->header.evt_id)
->   {
->       case BLE_GAP_EVT_CONNECTED:
->       {
->           NRF_LOG_INFO("BLE_GAP_EVT_CONNECTED\n");
->           BLE_UART_SetState(BLE_NUS_STATE_CONNECT);
->           errCode = bsp_indication_set(BSP_INDICATE_CONNECTED);
->           if (errCode != NRF_SUCCESS) {
->               NRF_LOG_WARNING("bsp_indication_set() failed, errCode=0x%x\n", errCode);
->               return;
->           }    
->
->           m_cur_conn_handle = pBleEvt->evt.gap_evt.conn_handle;
->
->           errCode = nrf_ble_qwr_conn_handle_assign(&m_qwr, m_cur_conn_handle);
->           if (errCode != NRF_SUCCESS) {
->               NRF_LOG_WARNING("nrf_ble_qwr_conn_handle_assign() failed, errCode=0x%x\n", errCode);
->               return;
->           }
->       }    
->       break;
->
->       case BLE_GATTS_EVT_SYS_ATTR_MISSING:
->       {
->           NRF_LOG_INFO("BLE_GATTS_EVT_SYS_ATTR_MISSING\n");
->           // No system attributes have been stored.
->           errCode = sd_ble_gatts_sys_attr_set(pBleEvt->evt.gap_evt.conn_handle, NULL, 0, 0);
->           APP_ERROR_CHECK(errCode);
->       }
->...
->}

-> Code0> <debug> nrf_ble_gatt: Requesting to update ATT MTU to 185 bytes on connection 0x0.
 0> <info> app: BLE_GAP_EVT_CONNECTED
 0>
 0> <debug> app: state=1
 0>
 0> <debug> nrf_ble_gatt: ATT MTU updated to 185 bytes on connection 0x0 (response).
 0> <info> app: BLE_GATTS_EVT_SYS_ATTR_MISSING

  • #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) {
        ble_dfu_buttonless_init_t init = {0};
        init.evt_handler = _bleDfuEvtHandler;
        const ret_code_t 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
    
    ota.h

  • Hi, 

    What SDK version are you using?

    I use nRF Connect to test  buttonless DFU without bonds failed.

    Can you provide the log from the nRF Connect? 

    Please try to erase the kit before programming. 

    Regards,
    Amanda

  • 17:18:47.101    Using nrf-device-lib-js version: 0.4.11
    17:18:47.102    Using nrf-device-lib version: 0.11.8
    17:18:47.102    Using nrfjprog DLL version: 10.15.4
    17:18:47.102    Using JLink version: JLink_V7.66a
    17:18:47.125    Installed JLink version does not match the provided version (V7.58b)
    17:18:47.283    Updated list of uuids with data from github.com/.../v1
    17:25:24.417    Selected device with s/n F092AF29DAF8
    17:25:24.426    Device setup completed
    17:25:24.427    Connectivity firmware version: ble-connectivity 4.1.4+Mar-11-2021-08-36-04. SoftDevice API version: 5. Baud rate: 1000000.
    17:25:24.428    Opening adapter connected to COM5
    17:25:25.374    Successfully opened COM5. Baud rate: 1000000. Flow control: none. Parity: none.
    17:25:25.376    Reset performed on adapter COM5
    17:25:26.443    Adapter connected to COM5 opened
    17:25:31.554    Scan started
    17:25:33.110    Connecting to device
    17:25:38.231    Connected to device E8:20:9F:75:90:08: interval: 7.5ms, timeout: 4000ms, latency: 0
    17:25:38.258    ATT MTU updated for device E8:20:9F:75:90:08, new value is 185
    17:25:38.512    Attribute value read, handle: 0x03, value (0x): 41-4E-43-53-32
    17:25:43.285    Connection parameters updated for device E8:20:9F:75:90:08: interval 15ms, timeout 3000ms, latency: 0
    17:25:46.516    Security updated, mode:1, level:3
    17:25:46.566    Storing bond info for device E8:20:9F:75:90:08
    17:25:55.708    Attribute value changed, handle: 0x0E, value (0x): 02-00
    17:25:55.713    Attribute value written, handle: 0x0E, value (0x): 02-00
  • I can't erase the kit through nrfjprog or SEGGER Embedded Studio.

    nrfjprog --log --family nRF52 --eraseall
    WARNING: Logging is unavailable. nrfjprog.exe does not have write
    WARNING: permission for the log file
    ERROR: Unable to connect to a debugger.
    ERROR: JLinkARM DLL reported an error. Try again. If error condition
    ERROR: persists, run the same command again with argument --log, contact Nordic
    ERROR: Semiconductor and provide the generated log.log file to them.
    NOTE: For additional output, try running again with logging enabled (--log).
    NOTE: Any generated log error messages will be displayed.

Related