コード例 #1
0
    def write_image_footer(self, new_image, cur_image, config, configkey,
                           imagenum, base_addr, name):
        load_addr = int(config.get(configkey, 'load_addr'), 0)
        exec_addr = int(config.get(configkey, 'exec_addr'), 0)
        type = int(config.get(configkey, 'type'), 0)

        # Prepare the image footer based on the data
        # we've stored previously
        fi = FirmwareImage()
        fi.imagenum = imagenum
        fi.base_address = base_addr
        fi.load_address = load_addr
        fi.exec_address = exec_addr
        fi.type = type
        fi.name = name
        fi.image_checksum = FirmwareImage.computeChecksum(cur_image)
        fi.length = len(cur_image)

        # Calculate the new checksum..
        fi.footer_checksum = fi.computeFooterChecksum()

        # flash chip breaks data down into 64KB blocks.
        # Footer should be at the end of one of these
        curblock = int(math.floor(new_image.tell() / 65536))

        curblockend = curblock * 65536

        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())

        return (footerpos, curblockend)
コード例 #2
0
	def write_image_footer(self, new_image, cur_image, config, configkey, imagenum, base_addr, name):
                load_addr = int(config.get(configkey, 'load_addr'),0)
                exec_addr = int(config.get(configkey, 'exec_addr'),0)
                type = int(config.get(configkey, 'type'),0)

		# Prepare the image footer based on the data
		# we've stored previously
		fi = FirmwareImage()
		fi.imagenum = imagenum
		fi.base_address = base_addr
		fi.load_address = load_addr
		fi.exec_address = exec_addr
		fi.type = type
		fi.name = name
		fi.image_checksum = FirmwareImage.computeChecksum(cur_image)
		fi.length = len(cur_image)

		# Calculate the new checksum..
		fi.footer_checksum = fi.computeFooterChecksum()

		# flash chip breaks data down into 64KB blocks.
		# Footer should be at the end of one of these 
		curblock = int(math.floor(new_image.tell() / 65536))

		curblockend = curblock * 65536

		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())

		return (footerpos, curblockend)
コード例 #3
0
    curblock = int(math.floor(new_image.tell() / 65536))

    curblockend = curblock * 65536

    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)
コード例 #4
0
	curblock = int(math.floor(new_image.tell() / 65536))

	curblockend = curblock * 65536

	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"