MCUBoot¶
Tools for inspecting MCUBoot compatible firmware images.
Specification: https://docs.mcuboot.com/design.html
IMAGE_MAGIC: Final = 2532554813
module-attribute
¶
IMAGE_HEADER_SIZE: Final = 32
module-attribute
¶
IMAGE_VERSION_STRUCT: Final = struct.Struct(f'<{_IMAGE_VERSION_FORMAT_STRING}')
module-attribute
¶
IMAGE_HEADER_STRUCT: Final = struct.Struct(f'<LLHHLL{_IMAGE_VERSION_FORMAT_STRING}4x')
module-attribute
¶
IMAGE_TLV_INFO_MAGIC: Final = 26887
module-attribute
¶
IMAGE_TLV_PROT_INFO_MAGIC: Final = 26888
module-attribute
¶
IMAGE_TLV_INFO_STRUCT: Final = struct.Struct('<HH')
module-attribute
¶
IMAGE_TLV_STRUCT: Final = struct.Struct('<BxH')
module-attribute
¶
MCUBootImageError
¶
TLVNotFound
¶
Bases: MCUBootImageError
IMAGE_F
¶
Bases: IntFlag
Image header flags.
Source code in smpclient/mcuboot.py
PIC = 1
class-attribute
instance-attribute
¶
Not supported.
ENCRYPTED_AES128 = 4
class-attribute
instance-attribute
¶
Encrypted using AES128.
ENCRYPTED_AES256 = 8
class-attribute
instance-attribute
¶
Encrypted using AES256.
NON_BOOTABLE = 16
class-attribute
instance-attribute
¶
Split image app.
RAM_LOAD = 32
class-attribute
instance-attribute
¶
IMAGE_TLV
¶
Bases: IntEnum
Image trailer TLV types.
Source code in smpclient/mcuboot.py
KEYHASH = 1
class-attribute
instance-attribute
¶
hash of the public key
SHA256 = 16
class-attribute
instance-attribute
¶
SHA256 of image hdr and body
RSA2048_PSS = 32
class-attribute
instance-attribute
¶
RSA2048 of hash output
ECDSA224 = 33
class-attribute
instance-attribute
¶
ECDSA of hash output - Not supported anymore
ECDSA_SIG = 34
class-attribute
instance-attribute
¶
ECDSA of hash output
RSA3072_PSS = 35
class-attribute
instance-attribute
¶
RSA3072 of hash output
ED25519 = 36
class-attribute
instance-attribute
¶
ED25519 of hash output
ENC_RSA2048 = 48
class-attribute
instance-attribute
¶
Key encrypted with RSA-OAEP-2048
ENC_KW = 49
class-attribute
instance-attribute
¶
Key encrypted with AES-KW-128 or 256
ENC_EC256 = 50
class-attribute
instance-attribute
¶
Key encrypted with ECIES-P256
ENC_X25519 = 51
class-attribute
instance-attribute
¶
Key encrypted with ECIES-X25519
DEPENDENCY = 64
class-attribute
instance-attribute
¶
Image depends on other image
SEC_CNT = 80
class-attribute
instance-attribute
¶
security counter
ImageVersion
¶
An MCUBoot image_version struct.
Source code in smpclient/mcuboot.py
ImageHeader
¶
An MCUBoot signed FW update header.
Source code in smpclient/mcuboot.py
magic: int
instance-attribute
¶
load_addr: int
instance-attribute
¶
hdr_size: int
instance-attribute
¶
protect_tlv_size: int
instance-attribute
¶
img_size: int
instance-attribute
¶
flags: IMAGE_F
instance-attribute
¶
ver: ImageVersion
instance-attribute
¶
loads(data: bytes) -> 'ImageHeader'
staticmethod
¶
Load an ImageHeader
from bytes
.
Source code in smpclient/mcuboot.py
__post_init__() -> None
¶
load_from(file: BytesIO | BufferedReader) -> 'ImageHeader'
staticmethod
¶
load_file(path: str) -> 'ImageHeader'
staticmethod
¶
ImageTLVInfo
¶
An image Type-Length-Value (TLV) region header.
Source code in smpclient/mcuboot.py
magic: int
instance-attribute
¶
tlv_tot: int
instance-attribute
¶
size of TLV area (including tlv_info header)
__post_init__() -> None
¶
Do initial validation of the header.
loads(data: bytes) -> 'ImageTLVInfo'
staticmethod
¶
load_from(file: BytesIO | BufferedReader) -> 'ImageTLVInfo'
staticmethod
¶
ImageTLV
¶
A TLV header - type and length.
Source code in smpclient/mcuboot.py
ImageTLVValue
¶
Source code in smpclient/mcuboot.py
ImageInfo
¶
A summary of an MCUBoot FW update image.
Source code in smpclient/mcuboot.py
header: ImageHeader
instance-attribute
¶
tlv_info: ImageTLVInfo
instance-attribute
¶
tlvs: List[ImageTLVValue]
instance-attribute
¶
file: str | None = None
class-attribute
instance-attribute
¶
get_tlv(tlv: IMAGE_TLV) -> ImageTLVValue
¶
Get a TLV from the image or raise TLVNotFound
.
load_file(path: str) -> 'ImageInfo'
staticmethod
¶
Load MCUBoot ImageInfo
from the .bin or .hex file at path
.
Source code in smpclient/mcuboot.py
__str__() -> str
¶
mcuimg() -> int
¶
A minimal CLI for getting info about an MCUBoot compatible FW image.