mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
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.
This commit is contained in:
parent
12b09344c8
commit
a98ab8d801
@ -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
|
||||
|
@ -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;
|
||||
|
@ -425,7 +425,7 @@ TEST_CASE("nvs api tests", "[nvs]")
|
||||
for (uint16_t i = NVS_FLASH_SECTOR; i <NVS_FLASH_SECTOR + NVS_FLASH_SECTOR_COUNT_MIN; ++i) {
|
||||
spi_flash_erase_sector(i);
|
||||
}
|
||||
TEST_ESP_OK(nvs_flash_init(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
|
||||
TEST_ESP_OK(nvs_flash_init_custom(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
|
||||
|
||||
TEST_ESP_ERR(nvs_open("namespace1", NVS_READONLY, &handle_1), ESP_ERR_NVS_NOT_FOUND);
|
||||
|
||||
@ -468,7 +468,7 @@ TEST_CASE("wifi test", "[nvs]")
|
||||
const uint32_t NVS_FLASH_SECTOR = 5;
|
||||
const uint32_t NVS_FLASH_SECTOR_COUNT_MIN = 3;
|
||||
emu.setBounds(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR + NVS_FLASH_SECTOR_COUNT_MIN);
|
||||
TEST_ESP_OK(nvs_flash_init(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
|
||||
TEST_ESP_OK(nvs_flash_init_custom(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
|
||||
|
||||
nvs_handle misc_handle;
|
||||
TEST_ESP_OK(nvs_open("nvs.net80211", NVS_READWRITE, &misc_handle));
|
||||
@ -610,7 +610,7 @@ TEST_CASE("can init storage from flash with random contents", "[nvs]")
|
||||
const uint32_t NVS_FLASH_SECTOR = 5;
|
||||
const uint32_t NVS_FLASH_SECTOR_COUNT_MIN = 3;
|
||||
emu.setBounds(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR + NVS_FLASH_SECTOR_COUNT_MIN);
|
||||
TEST_ESP_OK(nvs_flash_init(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
|
||||
TEST_ESP_OK(nvs_flash_init_custom(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
|
||||
|
||||
TEST_ESP_OK(nvs_open("nvs.net80211", NVS_READWRITE, &handle));
|
||||
|
||||
@ -631,7 +631,7 @@ TEST_CASE("nvs api tests, starting with random data in flash", "[nvs][.][long]")
|
||||
const uint32_t NVS_FLASH_SECTOR_COUNT_MIN = 3;
|
||||
emu.setBounds(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR + NVS_FLASH_SECTOR_COUNT_MIN);
|
||||
|
||||
TEST_ESP_OK(nvs_flash_init(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
|
||||
TEST_ESP_OK(nvs_flash_init_custom(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
|
||||
|
||||
nvs_handle handle_1;
|
||||
TEST_ESP_ERR(nvs_open("namespace1", NVS_READONLY, &handle_1), ESP_ERR_NVS_NOT_FOUND);
|
||||
@ -867,7 +867,7 @@ TEST_CASE("monkey test", "[nvs][monkey]")
|
||||
const uint32_t NVS_FLASH_SECTOR_COUNT_MIN = 3;
|
||||
emu.setBounds(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR + NVS_FLASH_SECTOR_COUNT_MIN);
|
||||
|
||||
TEST_ESP_OK(nvs_flash_init(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
|
||||
TEST_ESP_OK(nvs_flash_init_custom(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
|
||||
|
||||
nvs_handle handle;
|
||||
TEST_ESP_OK(nvs_open("namespace1", NVS_READWRITE, &handle));
|
||||
@ -909,7 +909,7 @@ TEST_CASE("test recovery from sudden poweroff", "[.][long][nvs][recovery][monkey
|
||||
}
|
||||
}
|
||||
|
||||
TEST_ESP_OK(nvs_flash_init(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
|
||||
TEST_ESP_OK(nvs_flash_init_custom(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
|
||||
|
||||
nvs_handle handle;
|
||||
TEST_ESP_OK(nvs_open("namespace1", NVS_READWRITE, &handle));
|
||||
@ -921,7 +921,7 @@ TEST_CASE("test recovery from sudden poweroff", "[.][long][nvs][recovery][monkey
|
||||
}
|
||||
nvs_close(handle);
|
||||
|
||||
TEST_ESP_OK(nvs_flash_init(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
|
||||
TEST_ESP_OK(nvs_flash_init_custom(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
|
||||
TEST_ESP_OK(nvs_open("namespace1", NVS_READWRITE, &handle));
|
||||
auto res = test.doRandomThings(handle, gen, count);
|
||||
if (res != ESP_OK) {
|
||||
|
@ -12,6 +12,16 @@ The simplest way to use the partition table is to `make menuconfig` and choose o
|
||||
|
||||
In both cases the factory app is flashed at offset 0x10000. If you `make partition_table` then it will print a summary of the partition table.
|
||||
|
||||
Known Issues
|
||||
------------
|
||||
|
||||
The below design document outlines the goals for the partition table system. At the moment, only some features are used:
|
||||
|
||||
- data partition types "rf" & "wifi" are unused and can be entirely omitted to save space.
|
||||
- NVS (non-volatile-storage) uses a hardcoded 12KB (0x3000 byte) region at offset 0x6000.
|
||||
|
||||
Once a full user API is in place for partition access, these limitations will be resolved and you'll be able to use the partition mechanism fully for storing data in flash.
|
||||
|
||||
Built-in Partition Tables
|
||||
-------------------------
|
||||
|
||||
|
@ -26,7 +26,7 @@ void hello_task(void *pvParameter)
|
||||
|
||||
void app_main()
|
||||
{
|
||||
nvs_flash_init(6, 3);
|
||||
nvs_flash_init();
|
||||
system_init();
|
||||
xTaskCreate(&hello_task, "hello_task", 2048, NULL, 5, NULL);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ void blink_task(void *pvParameter)
|
||||
|
||||
void app_main()
|
||||
{
|
||||
nvs_flash_init(6, 3);
|
||||
nvs_flash_init();
|
||||
system_init();
|
||||
xTaskCreate(&blink_task, "blink_task", 512, NULL, 5, NULL);
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ static void http_get_task(void *pvParameters)
|
||||
|
||||
void app_main()
|
||||
{
|
||||
nvs_flash_init(6, 3);
|
||||
nvs_flash_init();
|
||||
system_init();
|
||||
initialise_wifi();
|
||||
xTaskCreate(&http_get_task, "http_get_task", 2048, NULL, 5, NULL);
|
||||
|
@ -356,7 +356,7 @@ static void https_get_task(void *pvParameters)
|
||||
|
||||
void app_main()
|
||||
{
|
||||
nvs_flash_init(6, 3);
|
||||
nvs_flash_init();
|
||||
system_init();
|
||||
initialise_wifi();
|
||||
xTaskCreate(&https_get_task, "https_get_task", 8192, NULL, 5, NULL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user