|
|
@@ -14,13 +14,12 @@
|
|
|
#ifndef nvs_flash_h
|
|
|
#define nvs_flash_h
|
|
|
|
|
|
-#ifdef __cplusplus
|
|
|
-extern "C" {
|
|
|
-#endif
|
|
|
-
|
|
|
#include "nvs.h"
|
|
|
#include "esp_partition.h"
|
|
|
|
|
|
+#ifdef __cplusplus
|
|
|
+extern "C" {
|
|
|
+#endif
|
|
|
|
|
|
#define NVS_KEY_SIZE 32 // AES-256
|
|
|
|
|
|
@@ -57,6 +56,7 @@ esp_err_t nvs_flash_init(void);
|
|
|
* - ESP_ERR_NVS_NO_FREE_PAGES if the NVS storage contains no empty pages
|
|
|
* (which may happen if NVS partition was truncated)
|
|
|
* - ESP_ERR_NOT_FOUND if specified partition is not found in the partition table
|
|
|
+ * - ESP_ERR_NOT_SUPPORTED if the partition with name partition_label is not in internal flash
|
|
|
* - one of the error codes from the underlying flash storage driver
|
|
|
*/
|
|
|
esp_err_t nvs_flash_init_partition(const char *partition_label);
|
|
|
@@ -71,6 +71,7 @@ esp_err_t nvs_flash_init_partition(const char *partition_label);
|
|
|
* - ESP_ERR_NVS_NO_FREE_PAGES if the NVS storage contains no empty pages
|
|
|
* (which may happen if NVS partition was truncated)
|
|
|
* - ESP_ERR_INVALID_ARG in case partition is NULL
|
|
|
+ * - ESP_ERR_NOT_SUPPORTED if the partition is not in internal flash
|
|
|
* - one of the error codes from the underlying flash storage driver
|
|
|
*/
|
|
|
esp_err_t nvs_flash_init_partition_ptr(const esp_partition_t *partition);
|
|
|
@@ -128,6 +129,7 @@ esp_err_t nvs_flash_erase(void);
|
|
|
* - ESP_OK on success
|
|
|
* - ESP_ERR_NOT_FOUND if there is no NVS partition with the specified name
|
|
|
* in the partition table
|
|
|
+ * - ESP_ERR_NOT_SUPPORTED if the partition with part_name is not in internal flash
|
|
|
* - different error in case de-initialization fails (shouldn't happen)
|
|
|
*/
|
|
|
esp_err_t nvs_flash_erase_partition(const char *part_name);
|
|
|
@@ -148,6 +150,7 @@ esp_err_t nvs_flash_erase_partition(const char *part_name);
|
|
|
* - ESP_ERR_NOT_FOUND if there is no partition with the specified
|
|
|
* parameters in the partition table
|
|
|
* - ESP_ERR_INVALID_ARG in case partition is NULL
|
|
|
+ * - ESP_ERR_NOT_SUPPORTED if the partition is not in internal flash
|
|
|
* - one of the error codes from the underlying flash storage driver
|
|
|
*/
|
|
|
esp_err_t nvs_flash_erase_partition_ptr(const esp_partition_t *partition);
|
|
|
@@ -183,6 +186,7 @@ esp_err_t nvs_flash_secure_init(nvs_sec_cfg_t* cfg);
|
|
|
* - ESP_ERR_NVS_NO_FREE_PAGES if the NVS storage contains no empty pages
|
|
|
* (which may happen if NVS partition was truncated)
|
|
|
* - ESP_ERR_NOT_FOUND if specified partition is not found in the partition table
|
|
|
+ * - ESP_ERR_NOT_SUPPORTED if the partition is not in internal flash
|
|
|
* - one of the error codes from the underlying flash storage driver
|
|
|
*/
|
|
|
esp_err_t nvs_flash_secure_init_partition(const char *partition_label, nvs_sec_cfg_t* cfg);
|
|
|
@@ -199,8 +203,9 @@ esp_err_t nvs_flash_secure_init_partition(const char *partition_label, nvs_sec_c
|
|
|
*
|
|
|
*
|
|
|
* @return
|
|
|
- * -ESP_OK, if cfg was read successfully;
|
|
|
- * -or error codes from esp_partition_write/erase APIs.
|
|
|
+ * - ESP_OK, if cfg was read successfully;
|
|
|
+ * - ESP_ERR_NOT_SUPPORTED if the partition is not in internal flash
|
|
|
+ * - or error codes from esp_partition_write/erase APIs.
|
|
|
*/
|
|
|
|
|
|
esp_err_t nvs_flash_generate_keys(const esp_partition_t* partition, nvs_sec_cfg_t* cfg);
|
|
|
@@ -218,10 +223,11 @@ esp_err_t nvs_flash_generate_keys(const esp_partition_t* partition, nvs_sec_cfg_
|
|
|
* @note Provided parition is assumed to be marked 'encrypted'.
|
|
|
*
|
|
|
* @return
|
|
|
- * -ESP_OK, if cfg was read successfully;
|
|
|
- * -ESP_ERR_NVS_KEYS_NOT_INITIALIZED, if the partition is not yet written with keys.
|
|
|
- * -ESP_ERR_NVS_CORRUPT_KEY_PART, if the partition containing keys is found to be corrupt
|
|
|
- * -or error codes from esp_partition_read API.
|
|
|
+ * - ESP_OK, if cfg was read successfully;
|
|
|
+ * - ESP_ERR_NVS_KEYS_NOT_INITIALIZED, if the partition is not yet written with keys.
|
|
|
+ * - ESP_ERR_NVS_CORRUPT_KEY_PART, if the partition containing keys is found to be corrupt
|
|
|
+ * - ESP_ERR_NOT_SUPPORTED if the partition is not in internal flash
|
|
|
+ * - or error codes from esp_partition_read API.
|
|
|
*/
|
|
|
|
|
|
esp_err_t nvs_flash_read_security_cfg(const esp_partition_t* partition, nvs_sec_cfg_t* cfg);
|