kopia lustrzana https://github.com/espressif/esp-idf
nvs_partition_gen: Allow up to 4000 byte strings with NVS V2
As documented, the limit for NVS format v2 is 4000 bytes for a string.pull/9730/head
rodzic
47b6a8c85a
commit
b765963c7c
|
@ -51,13 +51,6 @@ def reverse_hexbytes(addr_tmp):
|
||||||
|
|
||||||
|
|
||||||
class Page(object):
|
class Page(object):
|
||||||
PAGE_PARAMS = {
|
|
||||||
'max_size': 4096,
|
|
||||||
'max_old_blob_size': 1984,
|
|
||||||
'max_new_blob_size': 4000,
|
|
||||||
'max_entries': 126
|
|
||||||
}
|
|
||||||
|
|
||||||
# Item type codes
|
# Item type codes
|
||||||
U8 = 0x01
|
U8 = 0x01
|
||||||
I8 = 0x11
|
I8 = 0x11
|
||||||
|
@ -84,6 +77,12 @@ class Page(object):
|
||||||
VERSION1 = 0xFF
|
VERSION1 = 0xFF
|
||||||
VERSION2 = 0xFE
|
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):
|
def __init__(self, page_num, version, is_rsrv_page=False):
|
||||||
self.entry_num = 0
|
self.entry_num = 0
|
||||||
self.bitmap_array = array.array('B')
|
self.bitmap_array = array.array('B')
|
||||||
|
@ -348,14 +347,13 @@ class Page(object):
|
||||||
# Set size of data
|
# Set size of data
|
||||||
datalen = len(data)
|
datalen = len(data)
|
||||||
|
|
||||||
if datalen > Page.PAGE_PARAMS['max_old_blob_size']:
|
max_blob_size = Page.PAGE_PARAMS['max_blob_size'][self.version]
|
||||||
if self.version == Page.VERSION1:
|
# V2 blob size limit only applies to strings
|
||||||
raise InputError(' Input File: Size (%d) exceeds max allowed length `%s` bytes for key `%s`.'
|
blob_limit_applies = self.version == Page.VERSION1 or encoding == 'string'
|
||||||
% (datalen, Page.PAGE_PARAMS['max_old_blob_size'], key))
|
|
||||||
else:
|
if blob_limit_applies and datalen > max_blob_size:
|
||||||
if encoding == 'string':
|
raise InputError(' Input File: Size (%d) exceeds max allowed length `%s` bytes for key `%s`.'
|
||||||
raise InputError(' Input File: Size (%d) exceeds max allowed length `%s` bytes for key `%s`.'
|
% (datalen, max_blob_size, key))
|
||||||
% (datalen, Page.PAGE_PARAMS['max_old_blob_size'], key))
|
|
||||||
|
|
||||||
# Calculate no. of entries data will require
|
# Calculate no. of entries data will require
|
||||||
rounded_size = (datalen + 31) & ~31
|
rounded_size = (datalen + 31) & ~31
|
||||||
|
|
Ładowanie…
Reference in New Issue