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 0f641d612..a1cc81a65 100755 --- a/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py +++ b/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py @@ -28,6 +28,7 @@ import os import array import csv import zlib +import codecs from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes from cryptography.hazmat.backends import default_backend @@ -81,9 +82,9 @@ class Page(object): # set page state to active page_header= bytearray(b'\xff')*32 page_state_active_seq = Page.ACTIVE - page_header[0:4] = struct.pack('= Page.PAGE_PARAMS["max_entries"]: raise PageFullError() - entry_struct = bytearray('\xff')*32 + entry_struct = bytearray(b'\xff')*32 entry_struct[0] = ns_index # namespace index entry_struct[2] = 0x01 # Span chunk_index = Page.CHUNK_ANY entry_struct[3] = chunk_index # write key - key_array = bytearray('\x00')*16 + key_array = bytearray(b'\x00')*16 entry_struct[8:24] = key_array - entry_struct[8:8 + len(key)] = key + + if sys.version_info[0] < 3: + entry_struct[8:8 + len(key)] = key + else: + entry_struct[8:8 + len(key)] = key.encode('utf8') + if encoding == "u8": entry_struct[1] = Page.U8 - entry_struct[24] = struct.pack('