feat(nvs): Allow read-only NVS partitions smaller than 0x3000
E.g. for factory settings data Closes https://github.com/espressif/esp-idf/issues/15317
This commit is contained in:
@@ -110,7 +110,7 @@ public:
|
||||
size_t columns = size / column_size;
|
||||
size_t column;
|
||||
|
||||
for(column = 0; column < columns; column = column + 1)
|
||||
for(column = 0; column < columns; ++column)
|
||||
{
|
||||
// read column
|
||||
if((err = esp_partition_read_raw(&esp_partition, dst_offset + (column * column_size), buff, column_size)) != ESP_OK) return err;
|
||||
|
||||
@@ -124,8 +124,8 @@ esp_err_t PageManager::load(Partition *partition, uint32_t baseSector, uint32_t
|
||||
}
|
||||
}
|
||||
|
||||
// partition should have at least one free page
|
||||
if (mFreePageList.empty()) {
|
||||
// partition should have at least one free page if it is not read-only
|
||||
if (!partition->get_readonly() && mFreePageList.empty()) {
|
||||
return ESP_ERR_NVS_NO_FREE_PAGES;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# See https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/partition-tables.html
|
||||
# for explanation of partition table structure and uses.
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-FileCopyrightText: 2016-2025 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
import argparse
|
||||
import binascii
|
||||
@@ -31,7 +31,7 @@ SECURE_NONE = None
|
||||
SECURE_V1 = 'v1'
|
||||
SECURE_V2 = 'v2'
|
||||
|
||||
__version__ = '1.4'
|
||||
__version__ = '1.5'
|
||||
|
||||
APP_TYPE = 0x00
|
||||
DATA_TYPE = 0x01
|
||||
@@ -45,6 +45,8 @@ TYPES = {
|
||||
'data': DATA_TYPE,
|
||||
}
|
||||
|
||||
NVS_RW_MIN_PARTITION_SIZE = 0x3000
|
||||
|
||||
|
||||
def get_ptype_as_int(ptype):
|
||||
""" Convert a string which might be numeric or the name of a partition type to an integer """
|
||||
@@ -533,6 +535,11 @@ class PartitionDefinition(object):
|
||||
raise ValidationError(self, "'%s' partition of type %s and subtype %s is always read-write and cannot be read-only" %
|
||||
(self.name, self.type, self.subtype))
|
||||
|
||||
if self.type == TYPES['data'] and self.subtype == SUBTYPES[DATA_TYPE]['nvs']:
|
||||
if self.size < NVS_RW_MIN_PARTITION_SIZE and self.readonly is False:
|
||||
raise ValidationError(self, """'%s' partition of type %s and subtype %s of this size (0x%x) must be flagged as 'readonly' \
|
||||
(the size of read/write NVS has to be at least 0x%x)""" % (self.name, self.type, self.subtype, self.size, NVS_RW_MIN_PARTITION_SIZE))
|
||||
|
||||
STRUCT_FORMAT = b'<2sBBLL16sL'
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user