def update_firmware(self, filename, partition, image_type, tftp_addr): """ Download a file from a TFTP server to a given partition. Make sure the image type matches. """ self.partitions[partition].updates += 1 localfile = temp_file() self.tftp.get_file(filename, localfile) contents = open(localfile).read() simg = get_simg_header(contents) self.partitions[partition].fwinfo.offset = "%8x" % simg.imgoff self.partitions[partition].fwinfo.size = "%8x" % simg.imglen self.partitions[partition].fwinfo.priority = "%8x" % simg.priority self.partitions[partition].fwinfo.daddr = "%8x" % simg.daddr return Result(tftp_handle_id = 0)
def update_firmware(self, filename, partition, image_type, tftp_addr): """ Download a file from a TFTP server to a given partition. Make sure the image type matches. """ self.partitions[partition].updates += 1 localfile = temp_file() self.tftp.get_file(filename, localfile) contents = open(localfile).read() simg = get_simg_header(contents) self.partitions[partition].fwinfo.offset = "%8x" % simg.imgoff self.partitions[partition].fwinfo.size = "%8x" % simg.imglen self.partitions[partition].fwinfo.priority = "%8x" % simg.priority self.partitions[partition].fwinfo.daddr = "%8x" % simg.daddr return Result(tftp_handle_id=0)
def render_to_simg(self, priority, daddr): """Creates a SIMG file. >>> img.render_to_simg(priority=1, daddr=0) >>> 'spi_highbank.bin' :param priority: SIMG header priority value. :type priority: integer :param daddr: SIMG daddr field value. :type daddr: integer :returns: The file name of the image. :rtype: string :raises InvalidImageError: If the SIMG image is not valid. """ filename = self.filename # Create new image if necessary if (not self.simg): contents = open(filename).read() # Figure out daddr if (self.daddr != None): daddr = self.daddr # Create simg align = (self.type in ["CDB", "BOOT_LOG"]) simg = create_simg(contents, priority=priority, daddr=daddr, skip_crc32=self.skip_crc32, align=align, version=self.version) filename = temp_file() with open(filename, "w") as file_: file_.write(simg) # Make sure the simg was built correctly if (not valid_simg(open(filename).read())): raise InvalidImageError("%s is not a valid SIMG" % os.path.basename(self.filename)) return filename