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

How to start DFU bootloader from application without using BLE DFU Service.

I have make over your bootloader example to create my own without BLE support in bootloader (new programs are send in application instead of in dfu bootloader). Bootloader works fine the only problem that I still can't handle is how to start bootloader from application, CPU still gets into fault. Device is not in connection and all flash operations are finished. My code starting bootloader looks like that:

void boot_start()
{
	uint32_t err_code;

#include "ble_conn_params.h"
	ble_conn_params_stop();

	advertising_stop();

	err_code = sd_power_gpregret_set(10);
  	APP_ERROR_CHECK(err_code);

	err_code = sd_softdevice_disable();
	APP_ERROR_CHECK(err_code);

	err_code = sd_softdevice_vector_table_base_set(NRF_UICR->BOOTLOADERADDR);
	APP_ERROR_CHECK(err_code);


	NVIC_ClearPendingIRQ(SWI2_IRQn);
	interrupts_disable();
	bootloader_util_app_start(NRF_UICR->BOOTLOADERADDR);
}
  • When are you getting a hardfault in this case? Note that for the serial bootloader you only need to call:

    err_code = sd_power_gpregret_set(10);  
    nvic reset
    

    Then you are done. Note that when you enter the bootloader you need to remove this check:
    if (init_softdevice).

  • That works, thanks. By the way what is the length of GPREGRET ? In documentation it is said that it is 8 bit long but in your bootloader example you use uint32_t.

  • 32bit cpu architecture (e.g. each register is 32bit), but only 8 bits are used (as is shown in the reference manual).