nrf-rs / nrf-hal

A Rust HAL for the nRF family of devices
Apache License 2.0
499 stars 139 forks source link

Add support for partial flash erase #385

Open arturkow2000 opened 2 years ago

arturkow2000 commented 2 years ago

Partial erase is a feature that allows to reduce time CPU is halted when using NVMC. It works by dividing page erase operation into multiple operations, in-between each operation CPU is resumed allowing interrupt handling.

Erasing a single page takes 85 ms on nRF52840, during write CPU can't handle interrupts, this may result, e.g. in broken USB, especially if erase happens during enumeration.

This code has been tested on nRF52840 by zeroing page, erasing it and checking whether all bits are back to 1.

qwandor commented 3 months ago

This seems like a good idea! Can you rebase it on top of the latest master? Is there any difference between different chips that we need to handle before merging this?