def process_image(self, config, imagenum, images, cur_image): # ASpeed seems to place global footer right after the last image # The size contains also part of the footer, so we extract it # But if the image is re-packed, that part is lost # so we need to check and add it, if needed if imagenum == images[-1]: if cur_image[-10:-2] != 'ATENs_FW': footer = FirmwareFooter() footer.rev1 = int(config.get('global','major_version'),0) footer.rev2 = int(config.get('global','minor_version'),0) footer.footerver = int(config.get('global','footer_version'),0) footer.rootfs_nfo = "00000000" footer.webfs_nfo = "00000000" return cur_image + footer.getRawString()[:10] return cur_image
def process_image(self, config, imagenum, images, cur_image): # ASpeed seems to place global footer right after the last image # The size contains also part of the footer, so we extract it # But if the image is re-packed, that part is lost # so we need to check and add it, if needed if imagenum == images[-1]: if cur_image[-10:-2] != 'ATENs_FW': footer = FirmwareFooter() footer.rev1 = int(config.get('global', 'major_version'), 0) footer.rev2 = int(config.get('global', 'minor_version'), 0) footer.footerver = int(config.get('global', 'footer_version'), 0) footer.rootfs_nfo = "00000000" footer.webfs_nfo = "00000000" return cur_image + footer.getRawString()[:10] return cur_image
last_image_end = new_image.tell() # If we don't have space to write the footer at the end of the current block, move to the next block if curblockend - 61 < last_image_end: curblock += 1 footerpos = (curblock * 65536) - 61 new_image.seek(footerpos) # And write the footer to the output file new_image.write(fi.getRawString()) footer = FirmwareFooter() footer.rev1 = int(config.get('global', 'major_version'), 0) footer.rev2 = int(config.get('global', 'minor_version'), 0) footer.footerver = int(config.get('global', 'footer_version'), 0) footer.checksum = footer.computeFooterChecksum(imagecrc) # Hmm... no documentation on where this should be, but in the firmware I have it's been palced right before the last image footer # Unsure if that's where it goes, or if it doesn't matter # 16 includes 8 padding \xFF's between the global footer and the last image footer global_start = footerpos - 16 if global_start < curblockend: print "ERROR: Would have written global footer over last image" print "Aborting" sys.exit(1) # Write the global footer new_image.seek(global_start)
last_image_end = new_image.tell() # If we don't have space to write the footer at the end of the current block, move to the next block if curblockend - 61 < last_image_end: curblock += 1 footerpos = (curblock * 65536) - 61 new_image.seek(footerpos) # And write the footer to the output file new_image.write(fi.getRawString()) footer = FirmwareFooter() footer.rev1 = int(config.get('global','major_version'),0) footer.rev2 = int(config.get('global','minor_version'),0) footer.footerver = int(config.get('global','footer_version'),0) footer.checksum = footer.computeFooterChecksum(imagecrc) # Hmm... no documentation on where this should be, but in the firmware I have it's been palced right before the last image footer # Unsure if that's where it goes, or if it doesn't matter # 16 includes 8 padding \xFF's between the global footer and the last image footer global_start = footerpos-16 if global_start < curblockend: print "ERROR: Would have written global footer over last image" print "Aborting" sys.exit(1) # Write the global footer new_image.seek(global_start)