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.

Parents Reply
  • It's not interrupt context. As I mentioned, it was working well before I did some work on the cmake architecture. Likely, the issue should be related to compilation or linking. 

    I'll also put some details of my latest debugging session: 

    1. If I do not wait in loop endlessly calling nrf_sdh_evts_poll it puts 4 operations in the queue and then starts returning NO_MEM return code which is expected since the queue length is 4. 

    2. There are no events in SDH_SOC_OBSERVER's handler in nrf_fstorage_sd too.

    Unfortunately, I stuck here because there is no way to move forward. 

Children
No Data
Related