Partial flash erase - timing requirements

What are the implications of calling nrfx_nvmc_page_partial_erase_continue() faster than the period I specify in my call to nrfx_nvmc_page_partial_erase_init()?

I'm erasing a 228kB block of flash on an nrf52833 using partial flash erase.  If I hammer the calls to *_continue() as quickly as I can until it returns true, the full erase takes ~6 seconds total.  If I ensure that each call to *_continue() occurs at the period specified during *_init(), the erase takes approximately 12 seconds.  In both cases, I've verified that the flash does indeed get fully erased. 

Digging into the nrfx source code, I see that the *_continue() function does a call to nrf_nvmc_ready_check(NRF_NVMC). Is this sufficient?  What are otherwise the implications of using the faster method?

  • Hi,

    I suppose you got two minimal samples: One for erasing fast and one for waiting.
    If so, could you send these here so I can test this out on my side as well.

    Then I will try it -> look into our code and docs and see if I can find something -> Ask our NVMC devs if I cannot find sufficient information myself.

    Regards,
    Sigurd Hellesvik

  • In what way do you ensure that each call to *_continue() occurs at the specified period? Do you measure the time from the beginning of a call to that function to the beginning of the next call to that function, or do you insert a delay between the calls? If you use a delay between the calls, you will definitiely see half speed compared to what's estimated.

    In any case, the *_continue() function already busy-waits until the flash partial erase is complete. If you measure the time the *_continue() function takes to run, you will see that it should match your configured duration. So you can immediately call the *_continue() function again once it returns, or at some later point. If you set duration to 1 ms, you will need to perform 87 partial erases on nRF52833.

    The whole point of the partial erase feature is to not block the CPU for extended periods of time, which is important in for example BLE scheduling of connection events, where the connection interval is less than 87 ms. While an erase or partial erase is ongoing, the CPU will be stalled if it executes code from flash, even in interrupts. It's easier to schedule 87 one-millisecond erase periods than a single 87 millisecond erase period.

Related