From a98ab8d80186f61abc2c79c185f2f6b3d7255baa Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 27 Sep 2016 12:45:06 +1000 Subject: [PATCH] nvs: Remove flash layout arguments from nvs_init() Add notes that current NVS layout defaults are a Work In Progress and not yet integrated with the partition table. --- components/nvs_flash/include/nvs_flash.h | 19 ++++++++++++++++++- components/nvs_flash/src/nvs_api.cpp | 8 +++++++- components/nvs_flash/test/test_nvs.cpp | 14 +++++++------- docs/partition-tables.rst | 10 ++++++++++ .../01_hello_world/main/hello_world_main.c | 2 +- examples/02_blink/main/blink.c | 2 +- .../03_http_request/main/http_request_main.c | 2 +- .../main/https_request_main.c | 2 +- 8 files changed, 46 insertions(+), 13 deletions(-) diff --git a/components/nvs_flash/include/nvs_flash.h b/components/nvs_flash/include/nvs_flash.h index 5d9dc7359b..ce98f39407 100644 --- a/components/nvs_flash/include/nvs_flash.h +++ b/components/nvs_flash/include/nvs_flash.h @@ -18,7 +18,24 @@ extern "C" { #endif -esp_err_t nvs_flash_init(uint32_t baseSector, uint32_t sectorCount); +/** Initialise NVS flash storage with default flash sector layout + + Temporarily, this region is hardcoded as a 12KB (0x3000 byte) + region starting at 24KB (0x6000 byte) offset in flash. +*/ +esp_err_t nvs_flash_init(void); + +/** Initialise NVS flash storage with custom flash sector layout + + @param baseSector Flash sector (units of 4096 bytes) offset to start NVS. + @param sectorCount Length (in flash sectors) of NVS region. + + @return ESP_OK if flash was successfully initialised. + + @note Use this parameter if you're not using the options in menuconfig for + configuring flash layout & partition table. +*/ +esp_err_t nvs_flash_init_custom(uint32_t baseSector, uint32_t sectorCount); #ifdef __cplusplus diff --git a/components/nvs_flash/src/nvs_api.cpp b/components/nvs_flash/src/nvs_api.cpp index 00a279d2b5..0a56925c0c 100644 --- a/components/nvs_flash/src/nvs_api.cpp +++ b/components/nvs_flash/src/nvs_api.cpp @@ -16,6 +16,7 @@ #include "nvs_storage.hpp" #include "intrusive_list.h" #include "nvs_platform.hpp" +#include "sdkconfig.h" #ifdef ESP_PLATFORM // Uncomment this line to force output from this module @@ -60,7 +61,12 @@ extern "C" void nvs_dump() s_nvs_storage.debugDump(); } -extern "C" esp_err_t nvs_flash_init(uint32_t baseSector, uint32_t sectorCount) +extern "C" esp_err_t nvs_flash_init(void) +{ + return nvs_flash_init_custom(6, 3); +} + +extern "C" esp_err_t nvs_flash_init_custom(uint32_t baseSector, uint32_t sectorCount) { Lock::init(); Lock lock; diff --git a/components/nvs_flash/test/test_nvs.cpp b/components/nvs_flash/test/test_nvs.cpp index 540d977b4c..3db9b45aeb 100644 --- a/components/nvs_flash/test/test_nvs.cpp +++ b/components/nvs_flash/test/test_nvs.cpp @@ -425,7 +425,7 @@ TEST_CASE("nvs api tests", "[nvs]") for (uint16_t i = NVS_FLASH_SECTOR; i