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

Calls to nrf_sdh_disable_request() interfere with Buttonless DFU

I have just integrated the Buttonless DFU example code into my project and I am able to successfully update my device using nRFConnect.  I'm using the NRF52840, S140, and SDK 15.3.

However, I am running into an issue in one area of my code where I found that I need to make a call to nrf_sdh_disable_request() before doing a write to flash to ensure that the flash write takes place successfully (bc it uses the sd backend).  But this causes a problem with the template Buttonless DFU code because that feature relies on an SDH state observer, and will set GPREGRET and go into the bootloader whenever the SDH is disabled.

static void buttonless_dfu_sdh_state_observer(nrf_sdh_state_evt_t state, void * p_context)
{
    if (state == NRF_SDH_EVT_STATE_DISABLED)
    {
        nrf_power_gpregret2_set(BOOTLOADER_DFU_SKIP_CRC);
        nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF);
    }
}

NRF_SDH_STATE_OBSERVER(m_buttonless_dfu_state_obs, 0) =
{
    .handler = buttonless_dfu_sdh_state_observer,
};

So I'm wondering how I can still guard my flash writes by temporarily disabling the SD without triggering the Buttonless DFU observer?  I've tried using nrf_sdh_suspend() as well as directly calling sd_softdevice_disable() and both of those seem to prevent the Buttonless DFU from triggering, but the flash write does not successfully finish.  So far only the nrf_sdh_disable_request() call will get the flash operations to complete successfully, but also triggers the DFU....

Any suggestions would be greatly appreciated!

Parents Reply Children
No Data
Related