Beispiel #1
0
    def do_erase(self, start, length, do_it, wp, verify, high_prot):
        """Perform a flash erase operation by calling the servlet on the DTV
       Returns True if all ok
    """
        if not app.require_dtvtrans_10_in_ram():
            return False

        # check range
        if not self.check_range(start, length, wp, high_prot):
            return False

        # load servlet
        if not self.load_servlet():
            return False

        # setup pointers: @0x2000
        status = self.download_range_pointers(start, length)
        if status != STATUS_OK:
            return False

        print "  erasing flash range: (%s)" % (("fake", "REAL")[do_it])
        app.iotools.print_range(start, length, verbose=True)

        ok = self.call_erase(do_it)
        if not ok:
            return False

        if verify:
            print "  verifying flash range:"
            ok, empty = self.call_check_empty()
            return (ok and empty) or not do_it
        else:
            return True
Beispiel #2
0
    def do_program(self,
                   start,
                   data,
                   do_it,
                   wp,
                   verify,
                   high_prot,
                   verbose=True):
        """Perform a flash program operation by calling the servlet on the DTV
       Returns True if all ok
    """
        if not app.require_dtvtrans_10_in_ram():
            return False

        # check range
        length = len(data)
        if not self.check_range(start, length, wp, high_prot):
            return False

        # load servlet
        if not self.load_servlet():
            return False

        # setup pointers: @0x2000
        status = self.download_range_pointers(start, length)
        if status != STATUS_OK:
            return False

        # downloading data
        if app.verbose:
            print "  downloading data @0x%06x size 0x%06x" % (
                self.servlet_rambuf, len(data))
        result, stat = app.dtvcmd.write_memory(0,
                                               self.servlet_rambuf,
                                               data,
                                               callback=app.iotools.print_size,
                                               block_size=app.block_size)
        app.iotools.print_result(result)
        if result != STATUS_OK:
            return False

        # do program
        self.message(
            "  programming flash range: (%s)" % (("fake", "REAL")[do_it]),
            verbose)
        app.iotools.print_range(start, length, verbose=verbose)

        ok = self.call_program(do_it, verbose=verbose)
        if not ok:
            return False

        # do verify
        if verify:
            self.message("  verifying flash range:", verbose)
            ok = self.call_verify(verbose=verbose)
            return ok or not do_it
        else:
            return True
Beispiel #3
0
    def do_check(self, start, length):
        """Check if given ROM range is empty"""
        if not app.require_dtvtrans_10_in_ram():
            return False

        # load servlet
        if not self.load_servlet():
            return False

        # setup pointers: @0x2000
        status = self.download_range_pointers(start, length)
        if status != STATUS_OK:
            return False

        print "  checking flash range:"
        app.iotools.print_range(start, length, verbose=True)
        ok, empty = self.call_check_empty()
        return ok
Beispiel #4
0
    def do_verify(self, start, data, wp, high_prot):
        """Compare a data with flash contents by using the servlet verify
       Returns True if all ok
    """
        if not app.require_dtvtrans_10_in_ram():
            return False

        # check range
        length = len(data)
        if not self.check_range(start, length, wp, high_prot):
            return False

        # load servlet
        if not self.load_servlet():
            return False

        # setup pointers: @0x2000
        status = self.download_range_pointers(start, length)
        if status != STATUS_OK:
            return False

        # downloading data
        if app.verbose:
            print "  downloading data @0x%06x size 0x%06x" % (
                self.servlet_rambuf, len(data))
        result, stat = app.dtvcmd.write_memory(0,
                                               self.servlet_rambuf,
                                               data,
                                               callback=app.iotools.print_size,
                                               block_size=app.block_size)
        app.iotools.print_result(result)
        if result != STATUS_OK:
            return False

        # do program
        print "  verifying flash range:"
        app.iotools.print_range(start, length, verbose=True)

        return self.call_verify()
Beispiel #5
0
    def do_sync(self, file_data, do_it, wp, verify, high_prot, start_addr,
                end_addr_opt, sync_all):
        """Perform a flash sync operation by calling the servlet on the DTV
       Returns True if all ok
    """
        if not app.require_dtvtrans_10_in_ram():
            return False

        # make sure its a ROM file
        if len(file_data) != self.flash_size:
            print "ERROR: no ROM file! (size is 0x%06x but 0x%06x expected)" % (
                len(file_data), self.flash_size)
            return False

        # sync main loop
        print "  syncing flash ROM"
        self.print_dump_header("'*'=flash '#'=erase+flash")

        if start_addr != -1:
            addr = start_addr
        elif wp:
            addr = self.sector_size
        else:
            addr = 0

        if end_addr_opt != -1:
            end_addr = end_addr_opt
        if high_prot:
            end_addr = self.flash_size - self.high_area_size
        else:
            end_addr = self.flash_size

        while (addr < end_addr):
            segment_size = end_addr - addr
            if segment_size > self.sector_size:
                segment_size = self.sector_size

            # read sector data
            result, rom_sector, stat = app.dtvcmd.read_memory(
                1,
                addr,
                segment_size,
                callback=app.iotools.print_size,
                block_size=app.block_size)
            if result != STATUS_OK:
                app.iotools.print_result(result)
                return False

            # analyze blocks
            file_sector = file_data[addr:addr + segment_size]
            begin, end, line = self.compare_blocks(rom_sector, file_sector)
            self.print_dump_line(addr, line)

            # sync all overwrite
            if sync_all:
                begin = 0
                end = self.sector_size

            # have something to flash here
            if begin != -1:
                rom_begin = addr + begin
                length = end - begin

                # download data to RAM buffer
                file_burn_data = file_sector[begin:end]

                # flash range
                if not self.do_program(rom_begin,
                                       file_burn_data,
                                       do_it,
                                       wp,
                                       verify,
                                       high_prot,
                                       verbose=False):
                    return False

            addr += self.sector_size

        return True