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);
}
  • Uncomment that line which you have commented out, otherwise bootloader will nerver get flashed. You just have to erase whole nrf chip, or just write, nrfjprog --eraseall --program filename.hex --reset --verify. It will definitely work. and always use given above command for flashing. It is because you can't overwrite UICR registers without erasing them, and those can only be erased by eerasing whole chip.

  • Yeah, I noted that it does not work if I comment the line away. Then I erased the whole chip nRFGo studio. But it did not help, when I try to flash my application having that line uncommented, the errors:

    No Algorithm found for: 10001014H - 10001017H

    Partial Erase Done (areas with no algorithms skipped!)

    No Algorithm found for: 10001014H - 10001017H

    Partial Programming Done (areas with no algorithms skipped!)

    are still there. I am now stuck on this. What the heck happened, this problem didn't exist two days ago :-o

  • Make sure "uint32_t m_uicr_bootloader_start_address..." is only in bootloader, and also UICR registers should only be used in bootloader and not in application. using nrfgo studio, use eraseall.

    1. burn softdevice, burn application, burn bootloader. if this doesn't work try eraseall, program softdevice, burn botloader, burn application.
  • Well, I had it in my application.I have two quire different bootloader_util_arm.c -files and the another one used by dual-bank bootloader doesn't have the UICR line there, at all. What is the exact version of your bootloader, i.e. from what folder in sdk you found it?

  • My chip is nrf51822, and sdk is 8. bootloader_settings_arm.c is only required in bootloader, and why do you use it in your application?? UICR line must be in bootloader_settings_arm.c, which must be present in bootloader, and not in application.

« 2 3 4 5 6 »