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 (1024 bytes) erase takes approximately 22 ms and a 4 byte flash write takes approximately 48 µ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 ≥ 85 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 > 107 ms)

8 high bandwidth connections as a central

All active connections fulfill the following criteria:
  • Supervision time-out > 6 x connection interval
  • Connection interval ≥ 80 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 ≥ 40 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

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 | Updated 2016-04-08