Example #1
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)
Example #2
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)
Example #3
0
    def test_render_to_simg(self):
        """ Test image creation and upload """
        imglen = 1024
        priority = 1
        daddr = 12345

        # Create image
        filename = random_file(imglen)
        contents = open(filename).read()
        image = TestImage(filename, "RAW")

        # Render and examine image
        filename = image.render_to_simg(priority, daddr)
        simg = open(filename).read()
        header = get_simg_header(simg)
        self.assertEqual(header.priority, priority)
        self.assertEqual(header.imglen, imglen)
        self.assertEqual(header.daddr, daddr)
        self.assertEqual(simg[header.imgoff:], contents)
Example #4
0
    def test_render_to_simg(self):
        """ Test image creation and upload """
        imglen = 1024
        priority = 1
        daddr = 12345

        # Create image
        filename = random_file(imglen)
        contents = open(filename).read()
        image = TestImage(filename, "RAW")

        # Render and examine image
        filename = image.render_to_simg(priority, daddr)
        simg = open(filename).read()
        header = get_simg_header(simg)
        self.assertEqual(header.priority, priority)
        self.assertEqual(header.imglen, imglen)
        self.assertEqual(header.daddr, daddr)
        self.assertEqual(simg[header.imgoff:], contents)