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

  • I have solved CRC check of app failed issue by regenerating bootloader_setting.hex by nrfutil and reprogramming bootloader_setting.hex, bootloader.hex, softdevice_s132.hex, and nrf52832_xxaa.hex.

    But I encounter another problem. nRF Connect can't connect nRF52832 with "Faield to secure connection with handle 00".

    log messages of nRF52832 device.
    10> <info> app: Version 1.2.1
    10>
    10>
    10> <info> app: ========| flash info |========
    10>
    10> <info> app: erase unit:   4096 bytes
    10>
    10> <info> app: program unit: 4 bytes
    10>
    10> <info> app: end address: 0x72000
    10>
    10> <info> app: ==============================
    10>
    10> <info> app_timer: RTC: initialized.
    10>
    10> <info> app: Setting vector table to bootloader: 0x00072000
    10>
    10> <info> app: Setting vector table to main app: 0x00026000
    10>
    10> <debug> app: NOR_DATA_PERIOD=819
    10>
    10>
    10> <debug> app: NOR_RECORD_PERIOD=8192
    10>
    10>
    10> <info> app: bsp_button_longkey_handler 0.
    10>
    10> <debug> nrf_ble_gatt: Requesting to update ATT MTU to 185 bytes on connection 0x0.
    10>
    10> <info> app: BLE_GAP_EVT_CONNECTED
    10>
    10>
    10> <debug> app: state=1
    10>
    10>
    10> <info> app: PM_EVT_CONN_SEC_FAILED
    10>
    10> <info> app: Faield to secure connection with handle 00
    10>
    10>
    10> <info> app: BLE_GAP_EVT_DISCONNECTED
    10>
    10>
    10> <debug> app: state=0
    10>
    10>
    10> <debug> app: _securityRequestHandler
    10>

    log messages of nRF Connect.

    nRF5x
    DA:73:F1:2C:90:6A
    Generic Access
    Generic Attribute
    17:32:10.097    Using nrf-device-lib-js version: 0.4.11
    17:32:10.097    Using nrf-device-lib version: 0.11.8
    17:32:10.097    Using nrfjprog DLL version: 10.15.4
    17:32:10.097    Using JLink version: JLink_V7.66a
    17:32:10.120    Installed JLink version does not match the provided version (V7.58b)
    17:32:10.601    Updated list of uuids with data from github.com/.../v1
    17:32:12.762    Selected device with s/n DA73F12C906A
    17:32:12.770    Device setup completed
    17:32:12.770    Connectivity firmware version: ble-connectivity 4.1.4+Mar-11-2021-08-36-04. SoftDevice API version: 5. Baud rate: 1000000.
    17:32:12.771    Opening adapter connected to COM10
    17:32:13.719    Successfully opened COM10. Baud rate: 1000000. Flow control: none. Parity: none.
    17:32:13.722    Reset performed on adapter COM10
    17:32:14.805    Adapter connected to COM10 opened
    17:32:18.734    Scan started
    17:33:18.739    Scanning timed out on adapter COM10
    17:33:23.212    Connecting to device
    17:33:29.327    Connected to device E8:20:9F:75:90:08: interval: 7.5ms, timeout: 4000ms, latency: 0
    17:33:29.347    ATT MTU updated for device E8:20:9F:75:90:08, new value is 185
    17:33:29.592    Attribute value read, handle: 0x03, value (0x): 41-4E-43-53-32
    17:33:34.381    Connection parameters updated for device E8:20:9F:75:90:08: interval 15ms, timeout 3000ms, latency: 0
    17:33:37.026    Security updated, mode:1, level:3
    17:33:37.079    Storing bond info for device E8:20:9F:75:90:08
    17:33:56.976    Attribute value changed, handle: 0x0E, value (0x): 02-00
    17:33:56.981    Attribute value written, handle: 0x0E, value (0x): 02-00
    17:34:13.688    Disconnected from device E8:20:9F:75:90:08, reason: BLE_HCI_CONNECTION_TIMEOUT
    17:34:38.597    Scan started
    17:34:40.480    Connecting to device
    17:35:00.489    Connection to device timed out
    17:36:02.463    Scan started
    17:36:29.017    Connecting to device
    17:36:29.529    Connected to device E8:20:9F:75:90:08: interval: 7.5ms, timeout: 4000ms, latency: 0
    17:36:29.541    ATT MTU updated for device E8:20:9F:75:90:08, new value is 185
    17:36:29.580    Security updated, mode:1, level:3
    17:36:29.844    Attribute value read, handle: 0x03, value (0x): 41-4E-43-53-32
    17:36:34.587    Connection parameters updated for device E8:20:9F:75:90:08: interval 15ms, timeout 3000ms, latency: 0
    17:36:37.127    Security updated, mode:1, level:3
    17:36:37.179    Storing bond info for device E8:20:9F:75:90:08
    17:37:43.881    Disconnected from device E8:20:9F:75:90:08, reason: BLE_HCI_CONNECTION_TIMEOUT
    17:37:51.202    Connecting to device
    17:38:11.212    Connection to device timed out
    17:40:41.743    Connecting to device
    17:41:01.750    Connection to device timed out
    17:56:41.236    Scan started
    17:56:47.402    Connecting to device
    17:56:47.557    Connected to device E8:20:9F:75:90:08: interval: 7.5ms, timeout: 4000ms, latency: 0
    17:56:47.576    ATT MTU updated for device E8:20:9F:75:90:08, new value is 185
    17:56:47.600    Disconnected from device E8:20:9F:75:90:08, reason: BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION

  • After I restart nRF Connect, it can connect to nRF52832 device. How can I trigger nRF52832 device to enter DFU mode from nRF Connect?

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

    10>

  • Hi, 

    It has the buttonless DFU service, so it doesn't need to trigger to get into DFU again. 

    -Amanda

  • Which event will be received in nRF52832 device when I press "Button DFU without bonds" soft key? I can't see any BLE_DFU_EVT_BOOTLOADER_xxx events in log messages. But ble_dfu_buttonless_init() return 0.:

    log messages:

    00> <info> app_timer: RTC: initialized.
    00>
    00> <info> app: Setting vector table to bootloader: 0x00072000
    00>
    00> <info> app: Setting vector table to main app: 0x00026000
    00> <debug> app:bleDfuInit() return 0
    00>
    00> <debug> app: NOR_DATA_PERIOD=819
    00>
    00>
    00> <debug> app: NOR_RECORD_PERIOD=8192
    00>
    00>
    00> <info> app: bsp_button_longkey_handler 0.
    00>
    00> <debug> nrf_ble_gatt: Requesting to update ATT MTU to 185 bytes on connection 0x0.
    00>
    00> <info> app: PM_EVT_BONDED_PEER_CONNECTED
    00>
    00>
    00> <info> app: BLE_GAP_EVT_CONNECTED
    00>
    00>
    00> <debug> app: state=1
    00>
    00>
    00> <info> app: PM_EVT_CONN_SEC_SUCCEEDED
    00>
    00>
    00> <info> app: Connection secured: role: 1, conn_handle: 0x0, procedure: 0.
    00>
    00> <debug> nrf_ble_gatt: ATT MTU updated to 185 bytes on connection 0x0 (response).
    00>
    00> <debug> app: _securityRequestHandler
    00>
    00>
    00> <info> app: PM_EVT_CONN_SEC_CONFIG_REQ
    00>
    00>
    00> <info> app: BLE_GAP_EVT_SEC_PARAMS_REQUEST
    00>
    00>
    00> <info> app: PM_EVT_CONN_SEC_SUCCEEDED
    00>
    00>
    00> <info> app: Connection secured: role: 1, conn_handle: 0x0, procedure: 1.
    00>
    00> <info> app: BLE_GAP_EVT_AUTH_STATUS
    00>

    source code related to BLE_DFU_EVT_BOOTLOADER_xxx event handling.
    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, errCode=0x%x\n", errCode);
            return ERROR_OTA_INITIALIZE_FAIL;
        }    

        NRF_LOG_DEBUG("bleDfuInit() return 0\n");
        return 0;
    }

Related