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
Angus Gratton 2022-07-22 15:15:53 +10:00 zatwierdzone przez Mahavir Jain
rodzic 47b6a8c85a
commit b765963c7c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 99324EF4A00734E0
1 zmienionych plików z 13 dodań i 15 usunięć

Wyświetl plik

@ -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:
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, 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))
% (datalen, max_blob_size, key))
# Calculate no. of entries data will require
rounded_size = (datalen + 31) & ~31