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

nRF52840 how to goto DFU when the softdevice has been disabled?

I have a system based on nRF52840 (SDK 15.0.0) where while running the application I can call the below code, and it will then restart in DFU secure mode to do a firmware upate. This all works great.

However I have a use-case where once running the app, the system will switch to Enhanced Shockburst mode so the softdevice is disabled. The code below no longer works probably because those 'sd_' functions won't work with the softdevice disabled.

Is there a way to modify the GPREGRET register and then call a system reset?

Basically I would like to goto the bootloader, but my normal do_dfu function below won't work because the softdevice is disabled. I tried starting ble / sd, but it crashes the device at that point.

Thanks

void do_dfu(void)
{
    uint32_t err_code;

    //NRF_LOG_DEBUG("In ble_dfu_buttonless_bootloader_start_finalize\r\n");

    err_code = sd_power_gpregret_clr(0, 0xffffffff);
    VERIFY_SUCCESS(err_code);

    err_code = sd_power_gpregret_set(0, BOOTLOADER_DFU_START);
    VERIFY_SUCCESS(err_code);

    // Signal that DFU mode is to be enter to the power management module
    nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_DFU);

    //return NRF_SUCCESS;
}

Parents Reply
  • Thanks, updated to the following which works;

    void do_dfu(void)
    {
        uint32_t err_code;
    
        #if LEGACY == true
            NRF_POWER->GPREGRET = 0xB1;
            NVIC_SystemReset();
        #else
            err_code = sd_power_gpregret_clr(0, 0xffffffff);
            VERIFY_SUCCESS(err_code);
    
            err_code = sd_power_gpregret_set(0, BOOTLOADER_DFU_START);
            VERIFY_SUCCESS(err_code);
    
            // Signal that DFU mode is to be enter to the power management module
            nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_DFU);
        #endif
    }

Children
No Data
Related