From a7ae0ee1faa3a4acb8153603a2dd76230c534c91 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Wed, 11 Nov 2020 10:37:03 +1100 Subject: [PATCH] nvs_partition_generator: Strip trailing whitespace in "hex2bin" input files --- .../nvs_flash/nvs_partition_generator/nvs_partition_gen.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py b/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py index 90d17a7b02..f8ec9a0094 100755 --- a/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py +++ b/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py @@ -360,10 +360,12 @@ class Page(object): if datalen > Page.PAGE_PARAMS["max_old_blob_size"]: 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: 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 rounded_size = (datalen + 31) & ~31 @@ -544,6 +546,7 @@ class NVS(object): """ def write_entry(self, key, value, encoding): if encoding == "hex2bin": + value = value.strip() if len(value) % 2 != 0: raise InputError("%s: Invalid data length. Should be multiple of 2." % key) value = binascii.a2b_hex(value)