bl2/ext/mcuboot/scripts/imgtool_lib/image.py
def add_header(self, key, protected_tlv_size, ramLoadAddress):
        """Install the image header.

        The key is needed to know the type of signature, and
        approximate the size of the signature."""

        flags = 0
        if ramLoadAddress is not None:
            # add the load address flag to the header to indicate that an SRAM
            # load address macro has been defined
            flags |= IMAGE_F["RAM_LOAD"]

        fmt = ('<' +
            # type ImageHdr struct {
            'I' +    # Magic    uint32
            'I' +    # LoadAddr uint32
            'H' +    # HdrSz    uint16
            'H' +    # PTLVSz   uint16
            'I' +    # ImgSz    uint32
            'I' +    # Flags    uint32
            'BBHI' + # Vers     ImageVersion
            'I'      # Pad1     uint32
            ) # }
        assert struct.calcsize(fmt) == IMAGE_HEADER_SIZE
        header = struct.pack(fmt,
                IMAGE_MAGIC,
                0 if (ramLoadAddress is None) else ramLoadAddress, # LoadAddr
                self.header_size,
                protected_tlv_size,  # TLV info header + SC TLV (+ DEP. TLVs)
                len(self.payload) - self.header_size, # ImageSz
                flags, # Flags
                self.version.major,
                self.version.minor or 0,
                self.version.revision or 0,
                self.version.build or 0,
                0)  # Pad1
        self.payload = bytearray(self.payload)
        self.payload[:len(header)] = header
Install the image header.

        The key is needed to know the type of signature, and
        approximate the size of the signature.
Install the image header.
The key is needed to know the type of signature, and
approximate the size of the signature.
Install the image header . The key is needed to know the type of signature and approximate the size of the signature .
def add_header(self, key, protected_tlv_size, ramLoadAddress):
        flags = 0
        if ramLoadAddress is not None:
            flags |= IMAGE_F["RAM_LOAD"]
        fmt = ('<' +
            'I' +    
            'I' +    
            'H' +    
            'H' +    
            'I' +    
            'I' +    
            'BBHI' + 
            'I'      
            ) 
        assert struct.calcsize(fmt) == IMAGE_HEADER_SIZE
        header = struct.pack(fmt,
                IMAGE_MAGIC,
                0 if (ramLoadAddress is None) else ramLoadAddress, 
                self.header_size,
                protected_tlv_size,  
                len(self.payload) - self.header_size, 
                flags, 
                self.version.major,
                self.version.minor or 0,
                self.version.revision or 0,
                self.version.build or 0,
                0)  
        self.payload = bytearray(self.payload)
        self.payload[:len(header)] = header
def add_header ( self , key , protected_tlv_size , ramLoadAddress ) : flags = 0 if ramLoadAddress is not None : flags |= IMAGE_F [ "RAM_LOAD" ] fmt = ( '<' + 'I' + 'I' + 'H' + 'H' + 'I' + 'I' + 'BBHI' + 'I' ) assert struct . calcsize ( fmt ) == IMAGE_HEADER_SIZE header = struct . pack ( fmt , IMAGE_MAGIC , 0 if ( ramLoadAddress is None ) else ramLoadAddress , self . header_size , protected_tlv_size , len ( self . payload ) - self . header_size , flags , self . version . major , self . version . minor or 0 , self . version . revision or 0 , self . version . build or 0 , 0 ) self . payload = bytearray ( self . payload ) self . payload [ : len ( header ) ] = header
Install the image header.
Install the image header .
"""Install the image header.

        The key is needed to know the type of signature, and
        approximate the size of the signature.""" # add the load address flag to the header to indicate that an SRAM # load address macro has been defined # type ImageHdr struct { # Magic    uint32 # LoadAddr uint32 # HdrSz    uint16 # PTLVSz   uint16 # ImgSz    uint32 # Flags    uint32 # Vers     ImageVersion # Pad1     uint32 # } # LoadAddr # TLV info header + SC TLV (+ DEP. TLVs) # ImageSz # Flags # Pad1
self
key
protected_tlv_size
ramLoadAddress