import common import struct # The target does not support OTA-flashing # the partition table, so blacklist it. DEFAULT_BOOTLOADER_OTA_BLACKLIST = [ 'partition' ] class BadMagicError(Exception): __str__ = "bad magic value" # # Motoboot packed image format # # #define BOOTLDR_MAGIC "MBOOTV1" # #define HEADER_SIZE 1024 # #define SECTOR_SIZE 512 # struct packed_images_header { # unsigned int num_images; # struct { # char name[24]; # unsigned int start; // start offset = HEADER_SIZE + start * SECTOR_SIZE # unsigned int end; // end offset = HEADER_SIZE + (end + 1) * SECTOR_SIZE - 1 # } img_info[20]; # char magic[8]; // set to BOOTLDR_MAGIC # }; HEADER_SIZE = 1024 SECTOR_SIZE = 512 NUM_MAX_IMAGES = 20 MAGIC = "MBOOTV1\0" class MotobootImage(object): def __init__(self, data, name = None): self.name = name self._unpack(data) def _unpack(self, data): """ Unpack the data blob as a motoboot image and return the list of contained image objects""" num_imgs_fmt = "