nrf_sdh_evts_poll hangs when trying to write/erase flash after SDH is enabled

Dear Support, 

I was working on refactoring the project and changed a majority of cmake files to improve the architecture of the project but when I finished I found out that something has been broken. After initial investigation I figured out that nrf_fstorage_write/nrf_fstorage_erase works only before SDH enable request is sent. If the function is called after that the firmware reboots by WDT with no assertions from SD or SDK's code. 

When I disabled WDT and tried to debug the project using J-Link it turned out that it hangs in nrf_sdh_evts_poll that's used to wait for completion of an operation. I also tried to put delays but operations are not getting completed. Although it returns SUCCESS on the first call, it fails on following calls.

    bool complete = false;
    if (NRF_SUCCESS != nrf_fstorage_erase(&fdb, addr, erase_pages, &complete)) {
        return 0;
    }
    while (!complete) nrf_sdh_evts_poll();

    return size;

There were no significant changes in the code that could cause such a behavior. Also, I compared compilation and linking flags before and after my changes - they look the same. 

As I mentioned, the code was working before and there are no mistakes in sdk_config file. I tried many approaches to debug the issue but they were unfruitful. 

Since I ran out idea, could you please advise possible reasons for the issue? 

I'm using: nRF5 SDK 17.1.0 with nRF52833 and S113. 

Thank you, 

Ramil.

Related