mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
refactor(nvs_flash): NVS constants were consolidated
- Constant definitions depending on spi_flash were added to nvs_constants
This commit is contained in:
@@ -29,7 +29,7 @@ public:
|
||||
esp_partition.erase_size = ESP_PARTITION_EMULATED_SECTOR_SIZE;
|
||||
esp_partition.type = ESP_PARTITION_TYPE_DATA;
|
||||
esp_partition.subtype = ESP_PARTITION_SUBTYPE_DATA_NVS;
|
||||
strncpy(esp_partition.label, partition_name, PART_NAME_MAX_SIZE);
|
||||
strncpy(esp_partition.label, partition_name, NVS_PART_NAME_MAX_SIZE);
|
||||
p_part = new (std::nothrow) nvs::NVSPartition(&esp_partition);
|
||||
REQUIRE(p_part != nullptr);
|
||||
}
|
||||
@@ -186,7 +186,7 @@ public:
|
||||
esp_partition2.erase_size = ESP_PARTITION_EMULATED_SECTOR_SIZE;
|
||||
esp_partition2.type = ESP_PARTITION_TYPE_DATA;
|
||||
esp_partition2.subtype = ESP_PARTITION_SUBTYPE_DATA_NVS;
|
||||
strncpy(esp_partition2.label, partition_name2, PART_NAME_MAX_SIZE);
|
||||
strncpy(esp_partition2.label, partition_name2, NVS_PART_NAME_MAX_SIZE);
|
||||
p_part2 = new (std::nothrow) nvs::NVSPartition(&esp_partition2);
|
||||
REQUIRE(p_part2 != nullptr);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "spi_flash_mmap.h" // for SPI_FLASH_SEC_SIZE
|
||||
#pragma once
|
||||
|
||||
// constants for the NVS to be used in the regular as well as bootloader implementations
|
||||
@@ -16,7 +15,7 @@
|
||||
#define NVS_CONST_ESB_WRITTEN 0x1
|
||||
#define NVS_CONST_ESB_ERASED 0x2
|
||||
|
||||
#define NVS_CONST_PAGE_SIZE SPI_FLASH_SEC_SIZE
|
||||
#define NVS_CONST_PAGE_SIZE 4096 // Page size is by design assumed to be 4096 bytes
|
||||
|
||||
#define NVS_CONST_ENTRY_SIZE 32
|
||||
#define NVS_CONST_ENTRY_COUNT 126
|
||||
@@ -30,6 +29,8 @@
|
||||
|
||||
#define NVS_CONST_NVS_VERSION 0xfe // Decrement to upgrade
|
||||
|
||||
#define NVS_ENCRYPT_BLOCK_SIZE 16 // Size of the encryption block in bytes
|
||||
|
||||
// Page States
|
||||
// All bits set, default state after flash erase. Page has not been initialized yet.
|
||||
#define NVS_CONST_PAGE_STATE_UNINITIALIZED 0xffffffff
|
||||
|
||||
@@ -9,14 +9,12 @@
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include "nvs_internal.h"
|
||||
#include "esp_partition.h"
|
||||
#include "nvs_memory_management.hpp"
|
||||
|
||||
namespace nvs {
|
||||
|
||||
Page::Page() : mPartition(nullptr) { }
|
||||
|
||||
const uint32_t nvs::Page::SEC_SIZE = 4096;
|
||||
|
||||
uint32_t Page::Header::calculateCrc32()
|
||||
{
|
||||
return esp_rom_crc32_le(0xffffffff,
|
||||
|
||||
@@ -7,16 +7,9 @@
|
||||
|
||||
#include "nvs.h"
|
||||
#include "nvs_types.hpp"
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include "compressed_enum_table.hpp"
|
||||
#include "intrusive_list.h"
|
||||
#include "nvs_item_hash_list.hpp"
|
||||
#include "nvs_memory_management.hpp"
|
||||
#include "partition.hpp"
|
||||
#include "nvs_constants.h"
|
||||
|
||||
namespace nvs
|
||||
{
|
||||
@@ -33,7 +26,7 @@ public:
|
||||
static const uint32_t ESB_WRITTEN = NVS_CONST_ESB_WRITTEN;
|
||||
static const uint32_t ESB_ERASED = NVS_CONST_ESB_ERASED;
|
||||
|
||||
static const uint32_t SEC_SIZE;
|
||||
static const uint32_t SEC_SIZE = NVS_CONST_PAGE_SIZE;
|
||||
|
||||
static const size_t ENTRY_SIZE = NVS_CONST_ENTRY_SIZE;
|
||||
static const size_t ENTRY_COUNT = NVS_CONST_ENTRY_COUNT;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "nvs_handle.hpp"
|
||||
#include "compressed_enum_table.hpp"
|
||||
#include "string.h"
|
||||
#include "nvs_constants.h"
|
||||
|
||||
namespace nvs
|
||||
{
|
||||
@@ -115,5 +116,7 @@ public:
|
||||
bool checkHeaderConsistency(const uint8_t entryIndex) const;
|
||||
};
|
||||
|
||||
// Safeguard for Item size
|
||||
static_assert(sizeof(Item) == NVS_CONST_ENTRY_SIZE, "Item size must be 32 bytes");
|
||||
|
||||
} // namespace nvs
|
||||
|
||||
Reference in New Issue
Block a user