partition_table: Pad generated table to 0xC00 length, for easier signing

This commit is contained in:
Angus Gratton
2016-11-07 15:32:21 +11:00
parent 7402a1b973
commit ff1b2c6039
3 changed files with 22 additions and 6 deletions

View File

@@ -9,6 +9,8 @@ import struct
import argparse
import sys
MAX_PARTITION_LENGTH = 0xC00 # 3K for partition data (96 entries) leaves 1K in a 4K sector for signature
__version__ = '1.0'
quiet = False
@@ -92,7 +94,11 @@ class PartitionTable(list):
return result
def to_binary(self):
return "".join(e.to_binary() for e in self)
result = "".join(e.to_binary() for e in self)
if len(result )>= MAX_PARTITION_LENGTH:
raise InputError("Binary partition table length (%d) longer than max" % len(result))
result += "\xFF" * (MAX_PARTITION_LENGTH - len(result)) # pad the sector, for signing
return result
def to_csv(self, simple_formatting=False):
rows = [ "# Espressif ESP32 Partition Table",