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

DFU: nRF51822 OTA bootloader jams after reset_prepare()

I managed to upload my application OTA DFU when there was only the bootloader running. After my application is there, I can start DFU and my application runs thru reset_prepare() function as expected. However, it seems that it never enters the bootloader although DfuTarg seems to appear as an available BLE device. So I cannot upload my application another time :(

Any ideas what could be wrong? Why my application does not start bootloader (correctly) after reset_prepare()?

EDIT: The bootloader enters event loop and jams there, see the code below (from bootloader.c/nRF51_SDK_8.0.0_5fc2c3a). The DFU loader at phone side says "disconnected" (mostly, sometimes it jams). I cannot reconnect although DfuTarg is visible.

for (;;)
{
    // Wait in low power state for any events.
    uint32_t err_code = sd_app_evt_wait();
    APP_ERROR_CHECK(err_code);

	myLedIndication(); // This shows me bootloader is running here very busy

    // Event received. Process it from the scheduler.
    app_sched_execute();

    if ((m_update_status == BOOTLOADER_COMPLETE) ||
        (m_update_status == BOOTLOADER_TIMEOUT)  ||
        (m_update_status == BOOTLOADER_RESET))
    {
        // When update has completed or a timeout/reset occured we will return.
        return;
    }
}

And the reset_prepare() looks like:

static void reset_prepare(void)
{
	uint32_t err_code;
	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 = bsp_indication_set(BSP_INDICATE_IDLE);
		//APP_ERROR_CHECK(err_code);
	}
	else
	{
		// If not connected, the device will be advertising. Hence stop the advertising.
		advertising_stop();
	}
	err_code = ble_conn_params_stop();
	APP_ERROR_CHECK(err_code);
}
Parents
  • Yes, the procedure is as follows:

    1. I flash the bootloader only
    2. I connect from a phone using nRFTools, via DFU selection
    3. I upload my brand-new DFU enabled application as a .zip file (success)
    4. Now my application is running in the target (I am sure because of indication led)
    5. I try another DFU from the nRFTools, trying to upload the same application.zip another time
    6. My application enters reset_prepare() (I am sure because I put led indication there)
    7. This time DFU fails after a while
    8. I do reconnect with nRFTools DFU, finding now DfuTarg as if the bootloader would be running there
    9. However, bootloader doesn't blink led as it did during the first time, and now the upload fails

    This happens every time I have tried. For me, it looks like bootloader might be started after my application's reset_prepare(), but it doesn't accept DFU request. Any ideas?

Reply
  • Yes, the procedure is as follows:

    1. I flash the bootloader only
    2. I connect from a phone using nRFTools, via DFU selection
    3. I upload my brand-new DFU enabled application as a .zip file (success)
    4. Now my application is running in the target (I am sure because of indication led)
    5. I try another DFU from the nRFTools, trying to upload the same application.zip another time
    6. My application enters reset_prepare() (I am sure because I put led indication there)
    7. This time DFU fails after a while
    8. I do reconnect with nRFTools DFU, finding now DfuTarg as if the bootloader would be running there
    9. However, bootloader doesn't blink led as it did during the first time, and now the upload fails

    This happens every time I have tried. For me, it looks like bootloader might be started after my application's reset_prepare(), but it doesn't accept DFU request. Any ideas?

Children
No Data
Related