'Calculate checksum of loaded image, based on segments in
segment array.'

def calculate_checksum(self):

    checksum = ESPLoader.ESP_CHECKSUM_MAGIC
    for seg in self.segments:
        if seg.include_in_checksum:
            checksum = ESPLoader.checksum(seg.data, checksum)
    return checksum
