Merge branch 'contrib/github_pr_9408' into 'master'

nvs_partition_gen: Allow up to 4000 byte strings with NVS V2 (GitHub PR)

Closes IDFGH-7884

See merge request espressif/esp-idf!19195
This commit is contained in:
Mahavir Jain 2022-07-26 15:48:43 +08:00
commit c917219c04

View File

@ -51,13 +51,6 @@ def reverse_hexbytes(addr_tmp):
class Page(object):
PAGE_PARAMS = {
'max_size': 4096,
'max_old_blob_size': 1984,
'max_new_blob_size': 4000,
'max_entries': 126
}
# Item type codes
U8 = 0x01
I8 = 0x11
@ -84,6 +77,12 @@ class Page(object):
VERSION1 = 0xFF
VERSION2 = 0xFE
PAGE_PARAMS = {
'max_size': 4096,
'max_blob_size': {VERSION1: 1984, VERSION2: 4000},
'max_entries': 126
}
def __init__(self, page_num, version, is_rsrv_page=False):
self.entry_num = 0
self.bitmap_array = array.array('B')
@ -348,14 +347,13 @@ class Page(object):
# Set size of data
datalen = len(data)
if datalen > Page.PAGE_PARAMS['max_old_blob_size']:
if self.version == Page.VERSION1:
raise InputError(' Input File: Size (%d) exceeds max allowed length `%s` bytes for key `%s`.'
% (datalen, Page.PAGE_PARAMS['max_old_blob_size'], key))
else:
if encoding == 'string':
raise InputError(' Input File: Size (%d) exceeds max allowed length `%s` bytes for key `%s`.'
% (datalen, Page.PAGE_PARAMS['max_old_blob_size'], key))
max_blob_size = Page.PAGE_PARAMS['max_blob_size'][self.version]
# V2 blob size limit only applies to strings
blob_limit_applies = self.version == Page.VERSION1 or encoding == 'string'
if blob_limit_applies and datalen > max_blob_size:
raise InputError(' Input File: Size (%d) exceeds max allowed length `%s` bytes for key `%s`.'
% (datalen, max_blob_size, key))
# Calculate no. of entries data will require
rounded_size = (datalen + 31) & ~31