Beispiel #1
0
    def do_gen_map(self):
        """Generate a map of the flash"""
        if not app.require_dtvtrans_10():
            return False, None

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

        # run servlet
        print "  generating flash map on DTV"
        (result, sr, acc, xr, yr,
         duration) = app.dtvcmd.sys_call(self.servlet_gen_map, timeout=30)
        app.iotools.print_result(result)
        app.iotools.print_duration(duration)
        if result != STATUS_OK:
            return False, None

        # read result
        if app.verbose:
            print "  downloading flash map"
        result, data, stat = app.dtvcmd.read_memory(
            0,
            self.servlet_iobuf,
            0x800,
            callback=app.iotools.print_size,
            block_size=app.block_size)
        app.iotools.print_result(result)
        if result != STATUS_OK:
            return False, None

        # ok!
        return True, data
Beispiel #2
0
def flash_sync(cmd,args,opts):
  if not app.require_dtvtrans_10():
    return False

  # parse optional start and end address
  start_addr = -1
  end_addr = -1
  sync_all = False
  for o in opts:
    if o[0] == '-s':
      start_addr,valid = app.iotools.parse_number(o[1])
      if not valid:
        print "ERROR: parsing start address: ",o[1]
        return False
    elif o[0] == '-e':
      end_addr,valid = app.iotools.parse_number(o[1])
      if not valid:
        print "ERROR: parsing end address: ",o[1]
        return False
    elif o[0] == '-a':
      sync_all = True

  # read file
  file_name = args[-1]
  (result,file_data,start,is_prg) = app.iotools.read_file(file_name)
  app.iotools.print_result(result)
  if result != STATUS_OK:
    return False

  # parse opts
  do_it,wp,verify,hp = flash_parse_opts(opts)

  f=Flash()
  return f.do_sync(file_data,do_it,wp,verify,hp,start_addr,end_addr,sync_all)
Beispiel #3
0
def run(cmd, args, opts):
    if not app.require_dtvtrans_10():
        return False

    print "  executing BASIC RUN"
    result = app.dtvcmd.do_print(string_run)
    app.iotools.print_result(result)
    if result != STATUS_OK:
        return False
    result = app.dtvcmd.run()
    app.iotools.print_result(result)
    return result == STATUS_OK
Beispiel #4
0
def exit(cmd, args, opts):
    if not app.require_dtvtrans_10():
        return False

    exit_mode = EXIT_NORMAL
    for o, a in opts:
        if o == '-n':
            exit_mode = EXIT_ONLY_EXIT
    print "  exiting to BASIC"
    result = app.dtvcmd.do_print(string_no_cursor)
    app.iotools.print_result(result)
    if result != STATUS_OK:
        return False
    result = app.dtvcmd.exit(exit_mode)
    app.iotools.print_result(result)
    return result == STATUS_OK
Beispiel #5
0
def sys(cmd, args, opts):
    if not app.require_dtvtrans_10():
        return False

    timeout = 10.0
    acc = 0
    xr = 0
    yr = 0
    sr = 0
    mem = 7
    for o, a in opts:
        if o == '-a':
            acc, v = app.iotools.parse_number(a)
        elif o == '-x':
            xr, v = app.iotools.parse_number(a)
        elif o == '-y':
            yr, v = app.iotools.parse_number(a)
        elif o == '-s':
            sr, v = app.iotools.parse_number(a)
        elif o == '-m':
            mem, v = app.iotools.parse_number(a)
        elif o == '-t':
            timeout, v = app.iotools.parse_number(a)

    addr, valid = app.iotools.parse_number(args[0])
    if not valid:
        return False

    print "  sys: calling code at 0x%04x" % addr
    print "    in:     SR=%s A=0x%02x X=0x%02x Y=0x%02x  MEM(0x01)=0x%02x" \
      % (app.iotools.status_reg_string(sr),acc,xr,yr,mem)
    (result, sr, acc, xr, yr, duration) = app.dtvcmd.sys_call(addr,
                                                              sr=sr,
                                                              acc=acc,
                                                              xr=xr,
                                                              yr=yr,
                                                              iocfg=mem,
                                                              timeout=timeout)
    app.iotools.print_result(result)
    if result != STATUS_OK:
        return False
    print "    out:    SR=%s A=0x%02x X=0x%02x Y=0x%02x" \
      % (app.iotools.status_reg_string(sr),acc,xr,yr)
    print "    time:   %s" % app.iotools.time_string(duration)
    return True
Beispiel #6
0
def flash_verify(cmd,args,opts):
  if not app.require_dtvtrans_10():
    return False

  # read file
  rom = 0
  (result,data,start,is_prg) = app.iotools.read_file(args[1])
  app.iotools.print_result(result)
  if result != STATUS_OK:
    return False

  # parse range
  rom,start = app.iotools.parse_write_start(args[0])
  if rom == -1:
    print "ERROR: invalid start address given!"
    return False

  # parse opts
  do_it,wp,verify,hp = flash_parse_opts(opts)

  f=Flash()
  return f.do_verify(start,data,wp,hp)
Beispiel #7
0
def dtvtrans_init(cmd, args, opts):
    if not app.require_dtvtrans_10():
        return False

    init_mode = INIT_FULL_BASIC
    for o, a in opts:
        if o == '-B':
            init_mode = INIT_FULL_BASIC
        elif o == '-b':
            init_mode = INIT_MINIMAL_BASIC
        elif o == '-K':
            init_mode = INIT_FULL_KERNAL
        elif o == '-k':
            init_mode = INIT_MINIMAL_KERNAL
    print "  initializing", init_mode_text[init_mode]
    result = app.dtvcmd.init(init_mode)
    app.iotools.print_result(result)
    if result == STATUS_OK and (init_mode == INIT_FULL_BASIC
                                or init_mode == INIT_MINIMAL_BASIC):
        result = app.dtvcmd.do_print(string_init_screen)
        app.iotools.print_result(result)
    return result == STATUS_OK
Beispiel #8
0
    def do_ident_flash(self):
        """Call the ident flash function"""
        if not app.require_dtvtrans_10():
            return False, ""

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

        # run servlet
        (result, sr, acc, xr, yr,
         duration) = app.dtvcmd.sys_call(self.servlet_ident_flash)
        app.iotools.print_result(result)
        if result != STATUS_OK:
            return False, ""

        # map accu
        flash_names = [
            "NOT FOUND!", "UNKNOWN", "AT4XBV16X", "AT4XBV16XT", "SST39VF1681",
            "SST39VF1682"
        ]
        if acc >= len(flash_names):
            return False, ""
        return True, flash_names[acc]