Beispiel #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)
	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)
    print "Writing 0x%x bytes at 0x%x" % (len(cur_image), new_image.tell())
    # Write the actual image contents
    new_image.write(cur_image)

    # Compute the CRC32 of this image.  This is used for the global footer, not for each individual footer
    curcrc = zlib.crc32(cur_image) & 0xffffffff
    imagecrc.append(curcrc)

    # Prepare the image footer based on the data we've stored previously
    fi = FirmwareImage()
    fi.imagenum = imagenum
    fi.base_address = base_addr
    fi.exec_address = exec_addr
    fi.load_address = load_addr
    fi.name = name
    fi.image_checksum = FirmwareImage.computeChecksum(cur_image)
    fi.type = type
    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:
	# Write the actual image contents
	new_image.write(cur_image)	

	# Compute the CRC32 of this image.  This is used for the global footer, not for each individual footer
	curcrc = zlib.crc32(cur_image) & 0xffffffff
	imagecrc.append(curcrc)

	# Prepare the image footer based on the data we've stored previously
	fi = FirmwareImage()
	fi.imagenum = imagenum
	fi.base_address = base_addr	
	fi.exec_address = exec_addr
	fi.load_address = load_addr
	fi.name = name
	fi.image_checksum = FirmwareImage.computeChecksum(cur_image)
	fi.type = type
	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: