refactor: remove dependency on spi_flash include for sector size

This commit is contained in:
Sonika Rathi
2024-09-26 13:01:24 +08:00
parent f18eb5a4c6
commit d5da858cd9
42 changed files with 198 additions and 136 deletions
+5 -2
View File
@@ -9,11 +9,14 @@
#include <cstdio>
#include <cstring>
#include "nvs_internal.h"
#include "esp_partition.h"
namespace nvs {
Page::Page() : mPartition(nullptr) { }
const uint32_t nvs::Page::SEC_SIZE = esp_partition_get_main_flash_sector_size();
uint32_t Page::Header::calculateCrc32()
{
return esp_rom_crc32_le(0xffffffff,
@@ -49,7 +52,7 @@ esp_err_t Page::load(Partition *partition, uint32_t sectorNumber)
return ESP_ERR_NO_MEM;
}
for (uint32_t i = 0; i < SPI_FLASH_SEC_SIZE; i += 4 * BLOCK_SIZE) {
for (uint32_t i = 0; i < SEC_SIZE; i += 4 * BLOCK_SIZE) {
rc = mPartition->read_raw(mBaseAddress + i, block, 4 * BLOCK_SIZE);
if (rc != ESP_OK) {
mState = PageState::INVALID;
@@ -1020,7 +1023,7 @@ esp_err_t Page::setVersion(uint8_t ver)
esp_err_t Page::erase()
{
auto rc = mPartition->erase_range(mBaseAddress, SPI_FLASH_SEC_SIZE);
auto rc = mPartition->erase_range(mBaseAddress, SEC_SIZE);
if (rc != ESP_OK) {
mState = PageState::INVALID;
return rc;