Non-volatile flash memory API.
More...
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <furi.h>
Go to the source code of this file.
|
| #define | RECORD_NVM "nvm" |
| | The string key for Nvm instance access.
|
| |
|
| bool | nvm_exists (Nvm *instance, uint32_t key, size_t *len) |
| | Check if a record exists under a given key and optionally get its length.
|
| |
| FURI_CHECK_RETURN bool | nvm_read (Nvm *instance, uint32_t key, void *data, size_t len) |
| | Read the record data under a given key.
|
| |
| FURI_CHECK_RETURN bool | nvm_read_partial (Nvm *instance, uint32_t key, void *data, size_t offset, size_t len) |
| | Read the record data under a given key partially.
|
| |
| FURI_CHECK_RETURN bool | nvm_write (Nvm *instance, uint32_t key, const void *data, size_t len) |
| | Write data to a record under a given key.
|
| |
| FURI_CHECK_RETURN bool | nvm_read_counter (Nvm *instance, uint32_t key, uint32_t *value) |
| | Read the counter value under a given key.
|
| |
| FURI_CHECK_RETURN bool | nvm_write_counter (Nvm *instance, uint32_t key, uint32_t value) |
| | Write the counter value under a given key.
|
| |
| FURI_CHECK_RETURN bool | nvm_increment_counter (Nvm *instance, uint32_t key, uint32_t *value) |
| | Increment the counter under a given key by 1 and optionally get its value.
|
| |
| FURI_CHECK_RETURN bool | nvm_delete (Nvm *instance, uint32_t key) |
| | Delete the record under a given key.
|
| |
| FURI_CHECK_RETURN bool | nvm_repack (Nvm *instance) |
| | Repack the storage to optimise space.
|
| |
| FURI_CHECK_RETURN bool | nvm_erase_all (Nvm *instance) |
| | Erase all data from the storage.
|
| |
| FURI_CHECK_RETURN bool | nvm_purge_all (Nvm *instance) |
| | Erase all data AND metadata from the storage.
|
| |
Non-volatile flash memory API.
◆ RECORD_NVM
The string key for Nvm instance access.
Get the instance pointer by calling furi_record_open(RECORD_NVM)
◆ NvmKeyRange
Enumeration of available Nvm key ranges.
- Warning
- Keys 0x0-0xFFFF are reserved, do not use
-
Keys 0x87000-0x87FFF are reserved, do not use
| Enumerator |
|---|
| NvmKeyRangeMin | Minimum key value (inclusive)
|
| NvmKeyRangeUser1Min | Free to use key range 1 start (inclusive)
|
| NvmKeyRangeUser1Max | Free to use key range 1 end (non-inclusive)
|
| NvmKeyRangeUser2Min | Free to use key range 2 start (inclusive)
|
| NvmKeyRangeMax | Maximum key value (non-inclusive)
|
◆ nvm_delete()
| FURI_CHECK_RETURN bool nvm_delete |
( |
Nvm * | instance, |
|
|
uint32_t | key ) |
Delete the record under a given key.
- Parameters
-
| [in,out] | instance | pointer to the Nvm instance |
| [in] | key | key associated with the record to be deleted |
- Returns
- true if the record could be deleted, false otherwise
◆ nvm_erase_all()
| FURI_CHECK_RETURN bool nvm_erase_all |
( |
Nvm * | instance | ) |
|
Erase all data from the storage.
- Warning
- This will ERASE ALL THE DATA on the storage, use with caution
- Parameters
-
| [in,out] | instance | pointer to the Nvm instance |
- Returns
- true if the storage could be erased, false otherwise.
◆ nvm_exists()
| bool nvm_exists |
( |
Nvm * | instance, |
|
|
uint32_t | key, |
|
|
size_t * | len ) |
Check if a record exists under a given key and optionally get its length.
- Parameters
-
| [in,out] | instance | pointer to the Nvm instance |
| [in] | key | key associated with the record to be checked |
| [out] | len | optional pointer to the variable to contain the record length (may be NULL) |
- Returns
- true if the record exists, false otherwise
◆ nvm_increment_counter()
| FURI_CHECK_RETURN bool nvm_increment_counter |
( |
Nvm * | instance, |
|
|
uint32_t | key, |
|
|
uint32_t * | value ) |
Increment the counter under a given key by 1 and optionally get its value.
- Parameters
-
| [in,out] | instance | pointer to the Nvm instance |
| [in] | key | key associated with the counter to be incremented |
| [out] | value | optional pointer to the variable to hold the new counter value (may be NULL) |
- Returns
- true if the counter could be incremented, false otherwise
◆ nvm_purge_all()
| FURI_CHECK_RETURN bool nvm_purge_all |
( |
Nvm * | instance | ) |
|
Erase all data AND metadata from the storage.
- Warning
- This will ERASE ALL THE DATA on the storage, use with caution
Unlike nvm_erase_all() which will keep the partition initialised, calling this function will completely reset it to a clean slate.
- Parameters
-
| [in,out] | instance | pointer to the Nvm instance |
- Returns
- true if the storage could be purged, false otherwise.
◆ nvm_read()
| FURI_CHECK_RETURN bool nvm_read |
( |
Nvm * | instance, |
|
|
uint32_t | key, |
|
|
void * | data, |
|
|
size_t | len ) |
Read the record data under a given key.
- Note
- Value of
len MUST match the data length given during writing, otherwise an error will occur.
- Parameters
-
| [in,out] | instance | pointer to the Nvm instance |
| [in] | key | key associated with the record to be read |
| [out] | data | pointer to the buffer to hold the data (must be large enough) |
| [in] | len | length of the data to be read (see note), in bytes |
- Returns
- true if the record could be read, false otherwise
◆ nvm_read_counter()
| FURI_CHECK_RETURN bool nvm_read_counter |
( |
Nvm * | instance, |
|
|
uint32_t | key, |
|
|
uint32_t * | value ) |
Read the counter value under a given key.
- Parameters
-
| [in,out] | instance | pointer to the Nvm instance |
| [in] | key | key associated with the counter to be read |
| [out] | value | pointer to the variable to hold the counter value |
- Returns
- true if the counter could be read, false otherwise
◆ nvm_read_partial()
| FURI_CHECK_RETURN bool nvm_read_partial |
( |
Nvm * | instance, |
|
|
uint32_t | key, |
|
|
void * | data, |
|
|
size_t | offset, |
|
|
size_t | len ) |
Read the record data under a given key partially.
- Note
- Value of
len - offset MUST match the data length given during writing, otherwise an error will occur.
- Parameters
-
| [in,out] | instance | pointer to the Nvm instance |
| [in] | key | key associated with the record to be read |
| [out] | data | pointer to the buffer to hold the data (must be large enough) |
| [in] | offset | offset from the beginning of the data, in bytes |
| [in] | len | length of the data to be read (see note), in bytes |
- Returns
- true if the record could be read, false otherwise
◆ nvm_repack()
| FURI_CHECK_RETURN bool nvm_repack |
( |
Nvm * | instance | ) |
|
Repack the storage to optimise space.
- Note
- The operation will only be performed if the driver logic decides that it is needed.
- Parameters
-
| [in,out] | instance | pointer to the Nvm instance |
- Returns
- true if the storage could be repacked, false otherwise
◆ nvm_write()
| FURI_CHECK_RETURN bool nvm_write |
( |
Nvm * | instance, |
|
|
uint32_t | key, |
|
|
const void * | data, |
|
|
size_t | len ) |
Write data to a record under a given key.
- Note
- If a record under the given key already exists, it will be overwritten with the new data.
- Parameters
-
| [in,out] | instance | pointer to the Nvm instance |
| [in] | key | key associated with the record to be written |
| [in] | data | pointer to the data to be written |
| [in] | len | length of the data to be written |
- Returns
- true if the record could be written, false otherwise
◆ nvm_write_counter()
| FURI_CHECK_RETURN bool nvm_write_counter |
( |
Nvm * | instance, |
|
|
uint32_t | key, |
|
|
uint32_t | value ) |
Write the counter value under a given key.
- Parameters
-
| [in,out] | instance | pointer to the Nvm instance |
| [in] | key | key associated with the counter to be written |
| [in] | value | counter value to be written |
- Returns
- true if the counter could be written, false otherwise