mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
nvs: initialize using layout from partition table
This commit is contained in:
parent
8ab4e11840
commit
51021b06f8
@ -18,25 +18,21 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Initialise NVS flash storage with default flash sector layout
|
||||
|
||||
Temporarily, this region is hardcoded as a 12KB (0x3000 byte)
|
||||
region starting at 36KB (0x9000 byte) offset in flash.
|
||||
|
||||
@return ESP_OK if flash was successfully initialised.
|
||||
*/
|
||||
/**
|
||||
* @brief Initialize NVS flash storage with layout given in the partition table.
|
||||
*
|
||||
* @return ESP_OK if storage was successfully initialized.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
/**
|
||||
* @brief Initialize NVS flash storage with custom flash sector layout
|
||||
* @note Make sure specified sectors don't fall within ranges occupied
|
||||
* by other partitions.
|
||||
* @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 initialized
|
||||
*/
|
||||
esp_err_t nvs_flash_init_custom(uint32_t baseSector, uint32_t sectorCount);
|
||||
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "nvs_storage.hpp"
|
||||
#include "intrusive_list.h"
|
||||
#include "nvs_platform.hpp"
|
||||
#include "esp_partition.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
@ -61,10 +62,19 @@ extern "C" void nvs_dump()
|
||||
s_nvs_storage.debugDump();
|
||||
}
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
extern "C" esp_err_t nvs_flash_init(void)
|
||||
{
|
||||
return nvs_flash_init_custom(9, 3);
|
||||
const esp_partition_t* partition = esp_partition_find_first(
|
||||
ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_NVS, NULL);
|
||||
if (partition == NULL) {
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
return nvs_flash_init_custom(partition->address / SPI_FLASH_SEC_SIZE,
|
||||
partition->size / SPI_FLASH_SEC_SIZE);
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C" esp_err_t nvs_flash_init_custom(uint32_t baseSector, uint32_t sectorCount)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user