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

softdevice not forwarding ble events in bootloader

Hi all, I have a situation in which softdevice (s310 v2) seems not to forward events to my nrf app (bootloader running dfu) in spite of the fact that my iOS app sees the device as connected and finds the DFU service and its characteristics. The setup is as such:

  • nRF app exposing a UART command service; command service also on BLE
  • nRF bootloader exposing DFU service through BLE and UART
  • iOS app connects to nRF app through UART service and peeks/pokes around; 1 command can trigger entry to bootloader mode; iOS app closes the connection and starts looking for advertising packets of DFU service
  • sd_ble_gap_address_set() is used in both app/bootloader init code to toggle a bit in the address of the device such as the device appears either as "bootloader" or "device_app" to iOS

This is the code in nRF app that makes the jump to the bootloader code:



void IndirectJumpBLEBootloader(void) { uint32_t err_code; ble_gap_conn_sec_mode_t sec_mode;

sd_power_gpregret_clr(0xFF);
sd_power_gpregret_set(g_ulUSBdat&0xFF);  // set HCI bootloader flag

if (m_conn_handle != BLE_CONN_HANDLE_INVALID)
{
    // Disconnect from peer.
    err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    APP_ERROR_CHECK(err_code);
}
err_code = ble_conn_params_stop();
sd_softdevice_disable();
err_code = sd_softdevice_vector_table_base_set(BOOTLOADER_REGION_START);
interrupts_disable();
jump_bootloader(0);

}

static void jump_bootloader(uint32_t start_addr)
{
asm(" LDR R2, [R0] \n" // ; Get App MSP.
" MSR MSP, R2 \n" // ; Set the main stack pointer to the applications MSP.
" LDR R3, [R0, #0x00000004] \n" // ; Get bootloader reset vector address.
" BX R3"); // ; No return - stack code is now activated only through SVC and plain interrupts.
}

This is the init code in the bootloader portion does dfu_transport_update_start_ble() with NRF_SUCCESS and I checked sd_softdevice_is_enabled() and it is enabled. Also softdevice_ble_evt_handler_set() is set to the right handler ble_evt_dispatch.

Now the problem is that even though the iOS app discovers the DFU service and characteristic, soft device does not trigger ble_evt_dispatch. I cant seem to figure out why. Looking for some expertise here please. Thanks.

Related