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

pstorage bug causes flash operations to hang

Hello, There is a bug in pstorage.c from SDK which can cause that module to fail to complete a flash operation. The problem is that the pstorage_sys_evt_handler function unconditionally sets the m_cmd_queue.flash_access flag to false when it is called. A SoC event that is unrelated to flash occurs during a flash operation and causes this flag to be cleared, and then the SoC event for the flash operation occurs and is ignored by pstorage.

The fix is for pstorage_sys_evt_handler to ignore SoC events that are not flash related:

void pstorage_sys_event_handler(uint32_t sys_evt)
{
    if ((sys_evt != NRF_EVT_FLASH_OPERATION_SUCCESS) &&
            (sys_evt != NRF_EVT_FLASH_OPERATION_ERROR)) {
        return;
    }

In my application, the battery is checked periodically. Every time the battery is checked, the HFCLK is started for the ADC, which results in the NRF_EVT_HFCLKSTARTED event. When this occurred during a flash operation, the flash operation would never complete.

Related