1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

python/firmware: support bootloader headers

This commit is contained in:
matejcik 2019-12-18 13:14:44 +01:00 committed by Pavol Rusnak
parent 7e6b39cd8e
commit 6cd976fdee
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -86,6 +86,11 @@ class ToifMode(Enum):
grayscale = b"g"
class HeaderType(Enum):
FIRMWARE = b"TRZF"
BOOTLOADER = b"TRZB"
class EnumAdapter(c.Adapter):
def __init__(self, subcon, enum):
self.enum = enum
@ -160,7 +165,7 @@ VersionLong = c.Struct(
FirmwareHeader = c.Struct(
"_start_offset" / c.Tell,
"magic" / c.Const(b"TRZF"),
"magic" / EnumAdapter(c.Bytes(4), HeaderType),
"header_len" / c.Int32ul,
"expiry" / c.Int32ul,
"code_length" / c.Rebuild(