Flash memory API

The System on Chip (SoC) flash memory API provides the application with flash write, flash erase, and flash protect support through the SoftDevice. Asynchronous flash memory operations can be safely performed during active BLE connections using the Flash memory API of the SoC library.

The flash memory accesses are scheduled to not disturb radio events. See Flash API timing for details. If the protocol radio events are in a critical state, flash memory accesses may be delayed for a long period resulting in a time-out event. In this case, NRF_EVT_FLASH_OPERATION_ERROR will be returned in the application event handler. If this happens, retry the flash memory operation. Examples of typical critical phases of radio events include: connection setup, connection update, disconnection, and impending supervision time-out.

The probability of successfully accessing the flash memory decreases with increasing scheduler activity (i.e. radio activity and timeslot activity). With long connection intervals there will be a higher probability of accessing flash memory successfully. Use the guidelines in Table 1 to improve the probability of flash operation success.

Important: Flash page (4096 bytes) erase can take up to 90 ms and a 4 byte flash write can take up to 338 µs. A flash write must be made in chunks smaller or equal to the flash page size. Make flash writes in as small chunks as possible to increase probability of success, and reduce chances of affecting BLE performance.
Table 1. Behavior with BLE traffic and concurrent flash write/erase
BLE activity Flash write/erase (flash write size is assumed to be four bytes)

High Duty cycle directed advertising

Does not allow flash operation while advertising is active (maximum 1.28 seconds). In this case, retrying flash operation will only succeed after the advertising activity has finished.

All possible BLE roles running concurrently (connections as a Central, Peripheral, Advertiser, and Scanner).

Low to medium probability of flash operation success

Probability of success increases with:

  • Lower bandwidth configurations.
  • Increase in connection interval and advertiser interval.
  • Decrease in scan window.
  • Increase in scan interval.

8 high bandwidth connections as a Central

1 high bandwidth connection as a Peripheral

All active connections fulfill the following criteria:
  • Supervision time-out > 6 x connection interval
  • Connection interval ≥ 150 ms
  • All central connections have the same connection interval

High probability of flash write success.

Medium probability of flash erase success. (High probability if the connection interval is > 240 ms)

8 high bandwidth connections as a Central

All active connections fulfill the following criteria:
  • Supervision time-out > 6 x connection interval
  • Connection interval ≥ 150 ms
  • All connections have the same connection interval

High probability of flash operation success.

8 low bandwidth connections as a Central

All active connections fulfill the following criteria:
  • Supervision time-out > 6 x connection interval
  • Connection interval ≥ 110 ms
  • All connections have the same connection interval

High probability of flash operation success.

1 connection as a Peripheral

All active connections fulfill the following criteria:
  • Supervision time-out > 6 x connection interval
  • Connection interval ≥ 25 ms

High probability of flash operation success.

Connectable Undirected Advertising

Nonconnectable Advertising

Scannable Advertising

Connectable Low Duty Cycle Directed Advertising

High probability of flash operation success.

No BLE activity

Flash operation will always succeed.


Documentation feedback | Developer Zone | Subscribe | Updated 2017-03-10