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

Buttonless DFU not starting bootloader

Hi,

I am having trouble with buttonless DFU on my application. I am working on custom hardware on the nRF51822, SDK10.0.0, S130.

When I enter DFU from my application the application goes through the reset_prepare sequence I created but then does not proceed to the bootloader. I know that I am definitely reaching the end of my custom reset_prepare sequence so it appears to be after that.

Any advice as to why I am not getting to bootloader mode would be much appreciated.

My reset_prepare function is as follows:

static void ble_peripheral_reset_prepare(void)
{
    uint32_t err_code;
    err_code = ble_conn_params_stop();
    APP_ERROR_CHECK(err_code);

    dfu_reset_prepare();
}

And the main in my bootloader application is:

int main(void)
{
    uint32_t err_code;
    bool     dfu_start = false;
    bool     app_reset = (NRF_POWER->GPREGRET == BOOTLOADER_DFU_START);

	bool pin_wakeup = ((NRF_POWER->RESETREAS & POWER_RESETREAS_OFF_Msk) == POWER_RESETREAS_OFF_Msk);
	
	if (app_reset)
    {
        NRF_POWER->GPREGRET = 0;
    }
    
    leds_init();

    // This check ensures that the defined fields in the bootloader corresponds with actual
    // setting in the nRF51 chip.
    APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
    APP_ERROR_CHECK_BOOL(NRF_FICR->CODEPAGESIZE == CODE_PAGE_SIZE);

    // Initialize.
    timers_init();
    buttons_init();

    (void)bootloader_init();

    if (bootloader_dfu_sd_in_progress())
    {
        nrf_gpio_pin_clear(UPDATE_IN_PROGRESS_LED);
        nrf_gpio_pin_clear(UPDATE_IN_PROGRESS_LED_2);

        err_code = bootloader_dfu_sd_update_continue();
        APP_ERROR_CHECK(err_code);

        ble_stack_init(!app_reset);
        scheduler_init();

        err_code = bootloader_dfu_sd_update_finalize();
        APP_ERROR_CHECK(err_code);

        nrf_gpio_pin_set(UPDATE_IN_PROGRESS_LED);			
        nrf_gpio_pin_set(UPDATE_IN_PROGRESS_LED_2);
    }
    else
    {
        // If stack is present then continue initialization of bootloader.
        ble_stack_init(!app_reset);
        scheduler_init();
    }

	dfu_start  = app_reset;
	dfu_start |= ((nrf_gpio_pin_read(BOOTLOADER_BUTTON) == 0) ? true: false);
	dfu_start &= ((!pin_wakeup) ? true: false);
    
    if (dfu_start || (!bootloader_app_is_valid(DFU_BANK_0_REGION_START)))
    {
        nrf_gpio_pin_clear(UPDATE_IN_PROGRESS_LED);
        nrf_gpio_pin_clear(UPDATE_IN_PROGRESS_LED_2);

        // Initiate an update of the firmware.
        err_code = bootloader_dfu_start();
        APP_ERROR_CHECK(err_code);

        nrf_gpio_pin_set(UPDATE_IN_PROGRESS_LED);
	    nrf_gpio_pin_set(UPDATE_IN_PROGRESS_LED_2);
    }

    if (bootloader_app_is_valid(DFU_BANK_0_REGION_START) && !bootloader_dfu_sd_in_progress())
    {
        // Select a bank region to use as application region.
        // @note: Only applications running from DFU_BANK_0_REGION_START is supported.
        bootloader_app_start(DFU_BANK_0_REGION_START);
    }
    
    NVIC_SystemReset();
}
Related