Bare Metal Storage

The Bare Metal Storage sample demonstrates how to configure and use storage instances with event callbacks. Depending on the configuration selected, the sample uses either the SoftDevice storage backend or the RRAM storage backend.

Refer to the Kconfig fragments section for more information on configuration.

Requirements

The sample supports the following development kits:

The following board variants do not have DFU capabilities:

S115:

Hardware platform

PCA

Board target

nRF54L15 DK

PCA10156

bm_nrf54l15dk/nrf54l15/cpuapp/s115_softdevice

nRF54L15 DK (emulating nRF54L10)

PCA10156

bm_nrf54l15dk/nrf54l10/cpuapp/s115_softdevice

nRF54L15 DK (emulating nRF54L05)

PCA10156

bm_nrf54l15dk/nrf54l05/cpuapp/s115_softdevice

nRF54LM20 DK

PCA10184

bm_nrf54lm20dk/nrf54lm20a/cpuapp/s115_softdevice

nRF54LS05 DK

PCA10214

bm_nrf54ls05dk/nrf54ls05b/cpuapp/s115_softdevice

nRF54LV10 DK

PCA10188

bm_nrf54lv10dk/nrf54lv10a/cpuapp/s115_softdevice

S145:

Hardware platform

PCA

Board target

nRF54L15 DK

PCA10156

bm_nrf54l15dk/nrf54l15/cpuapp/s145_softdevice

nRF54L15 DK (emulating nRF54L10)

PCA10156

bm_nrf54l15dk/nrf54l10/cpuapp/s145_softdevice

nRF54L15 DK (emulating nRF54L05)

PCA10156

bm_nrf54l15dk/nrf54l05/cpuapp/s145_softdevice

nRF54LM20 DK

PCA10184

bm_nrf54lm20dk/nrf54lm20a/cpuapp/s145_softdevice

nRF54LS05 DK

PCA10214

bm_nrf54ls05dk/nrf54ls05b/cpuapp/s145_softdevice

nRF54LV10 DK

PCA10188

bm_nrf54lv10dk/nrf54lv10a/cpuapp/s145_softdevice

Kconfig fragments

By default, the sample uses the SoftDevice storage backend. To configure it for this sample, follow the steps outlined in Configuring and building a sample.

User interface

LED 0:

Lit when the device storage has been successfully initialized.

Building and running

This sample can be found under samples/subsys/storage/bm_storage/ in the Bare Metal folder structure.

For details on how to create, configure, and program a sample, see Getting Started with the samples.

Testing

You can test this sample by performing the following steps:

  1. Compile and program the application.

  2. Observe that the following output is printed:

[00:00:00.005,789] <inf> app: Storage sample started
[00:00:00.005,810] <inf> nrf_sdh: State change request: enable
[00:00:00.011,214] <inf> app: Reading persisted data
[00:00:00.011,232] <inf> app: output A:
                              48 65 6c 6c 6f 00 00 00  00 00 00 00 00 00 00 00 |Hello... ........
[00:00:00.011,244] <inf> app: output B:
                              57 6f 72 6c 64 21 00 00  00 00 00 00 00 00 00 00 |World!.. ........
[00:00:00.011,250] <inf> app: Erasing in Partition A, addr: 0x0015B000, size: 16
[00:00:00.011,297] <inf> app: Erasing in Partition B, addr: 0x0015C000, size: 16
[00:00:00.011,304] <inf> app: Waiting for writes to complete...
[00:00:00.012,370] <inf> app: Handler A: bm_storage_evt: WRITE_RESULT 0, DISPATCH_TYPE 1
[00:00:00.013,444] <inf> app: Handler B: bm_storage_evt: WRITE_RESULT 0, DISPATCH_TYPE 1
[00:00:00.013,468] <inf> app: output A:
                              00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |........ ........
[00:00:00.013,481] <inf> app: output B:
                              00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |........ ........
[00:00:00.013,496] <inf> nrf_sdh: State change request: disable
[00:00:00.013,531] <inf> app: Writing in Partition A, addr: 0x0015B000, size: 16
[00:00:00.013,659] <inf> app: Handler A: bm_storage_evt: WRITE_RESULT 0, DISPATCH_TYPE 0
[00:00:00.013,664] <inf> app: Writing in Partition B, addr: 0x0015C000, size: 16
[00:00:00.013,769] <inf> app: Handler B: bm_storage_evt: WRITE_RESULT 0, DISPATCH_TYPE 0
[00:00:00.013,775] <inf> app: Waiting for writes to complete...
[00:00:00.013,789] <inf> app: output A:
                              48 65 6c 6c 6f 00 00 00  00 00 00 00 00 00 00 00 |Hello... ........
[00:00:00.013,801] <inf> app: output B:
                              57 6f 72 6c 64 21 00 00  00 00 00 00 00 00 00 00 |World!.. ........
[00:00:00.013,807] <inf> app: Storage sample finished.

Note

The addresses may vary depending on the board target selected.