mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
nvs_partition_generator: Strip trailing whitespace in "hex2bin" input files
This commit is contained in:
parent
60ba7e4ae2
commit
a7ae0ee1fa
@ -360,10 +360,12 @@ class Page(object):
|
|||||||
|
|
||||||
if datalen > Page.PAGE_PARAMS["max_old_blob_size"]:
|
if datalen > Page.PAGE_PARAMS["max_old_blob_size"]:
|
||||||
if self.version == Page.VERSION1:
|
if self.version == Page.VERSION1:
|
||||||
raise InputError(" Input File: Size exceeds max allowed length `%s` bytes for key `%s`." % (Page.PAGE_PARAMS["max_old_blob_size"], key))
|
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:
|
else:
|
||||||
if encoding == "string":
|
if encoding == "string":
|
||||||
raise InputError(" Input File: Size exceeds max allowed length `%s` bytes for key `%s`." % (Page.PAGE_PARAMS["max_old_blob_size"], key))
|
raise InputError(" Input File: Size (%d) exceeds max allowed length `%s` bytes for key `%s`."
|
||||||
|
% (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
|
||||||
@ -544,6 +546,7 @@ class NVS(object):
|
|||||||
"""
|
"""
|
||||||
def write_entry(self, key, value, encoding):
|
def write_entry(self, key, value, encoding):
|
||||||
if encoding == "hex2bin":
|
if encoding == "hex2bin":
|
||||||
|
value = value.strip()
|
||||||
if len(value) % 2 != 0:
|
if len(value) % 2 != 0:
|
||||||
raise InputError("%s: Invalid data length. Should be multiple of 2." % key)
|
raise InputError("%s: Invalid data length. Should be multiple of 2." % key)
|
||||||
value = binascii.a2b_hex(value)
|
value = binascii.a2b_hex(value)
|
||||||
|
Loading…
Reference in New Issue
Block a user