示例#1
0
def main(argv):
    parser = get_parser()
    opts = parser.parse_args(argv)

    result = True

    # Let's make sure there's a tigertail
    # If nothing found in 5 seconds, fail.
    c.wait_for_usb(STM_VIDPID, 5.)

    pty = c.setup_tinyservod(STM_VIDPID, 0, serialno=opts.serialno)

    if opts.setserialno:
        try:
            c.do_serialno(opts.setserialno, pty)
        except Exception:
            result = False

    elif opts.mux:
        result &= do_mux(opts.mux, pty)

    elif opts.sysjump:
        result &= do_sysjump(opts.sysjump, pty)

    elif opts.reboot:
        result &= do_reboot(pty)

    if result:
        c.log('PASS')
    else:
        c.log('FAIL')
        exit(-1)
示例#2
0
def main(argv):
    parser = get_parser()
    opts = parser.parse_args(argv)

    result = True

    # Let's make sure there's a tigertail
    # If nothing found in 5 seconds, fail.
    c.wait_for_usb(STM_VIDPID, timeout=5., serialname=opts.serialno)

    pty = c.setup_tinyservod(STM_VIDPID, 0, serialname=opts.serialno)

    if opts.bus not in ('vbus', 'cc1', 'cc2'):
        c.log('Try --bus [vbus|cc1|cc2]')
        result = False

    elif opts.setserialno:
        try:
            c.do_serialno(opts.setserialno, pty)
        except Exception:
            result = False

    elif opts.mux:
        result &= do_mux(opts.mux, pty)

    elif opts.sysjump:
        result &= do_sysjump(opts.sysjump, pty)

    elif opts.reboot:
        result &= do_reboot(pty)

    elif opts.check_version:
        result &= do_version(pty)

    elif opts.check_serial:
        result &= do_check_serial(pty)

    elif opts.power:
        result &= do_power(1, opts.bus, pty)

    elif opts.powerlog:
        result &= do_power(opts.powerlog, opts.bus, pty)

    if result:
        c.log('PASS')
    else:
        c.log('FAIL')
        exit(-1)
示例#3
0
def connect(vidpid, iface, serialno, debuglog=False):
  """Connect to console.

  Args:
    vidpid: vidpid of desired device.
    iface: interface to connect.
    serialno: serial number, to differentiate multiple devices.
    debuglog: do chatty log.

  Returns:
    a connected pty object.
  """
  # Make sure device is up.
  c.wait_for_usb(vidpid, serialname=serialno)

  # make a console.
  pty = c.setup_tinyservod(vidpid, iface,
            serialname=serialno, debuglog=debuglog)

  return pty
示例#4
0
def main():
    parser = argparse.ArgumentParser(description="Image a servo micro device")
    parser.add_argument('-s',
                        '--serialno',
                        type=str,
                        help="serial number to program",
                        default=None)
    parser.add_argument('-b',
                        '--board',
                        type=str,
                        help="Board configuration json file",
                        default=DEFAULT_BOARD)
    parser.add_argument('-f',
                        '--file',
                        type=str,
                        help="Complete ec.bin file",
                        default=None)
    parser.add_argument('--force',
                        action="store_true",
                        help="Update even if version match",
                        default=False)
    parser.add_argument('-v',
                        '--verbose',
                        action="store_true",
                        help="Chatty output")
    parser.add_argument('-r',
                        '--reboot',
                        action="store_true",
                        help="Always reboot, even after probe.")

    args = parser.parse_args()

    brdfile, binfile = findfiles(args.board, args.file)

    serialno = args.serialno

    with open(brdfile) as data_file:
        data = json.load(data_file)
    vid, pid = int(data['vid'], 0), int(data['pid'], 0)
    vidpid = "%04x:%04x" % (vid, pid)
    iface = int(data['console'], 0)
    boardname = data['board']

    # Make sure device is up.
    c.wait_for_usb(vidpid, serialname=serialno)
    # We need a tiny_servod to query some information. Set it up first.
    tinys = tiny_servod.TinyServod(vid, pid, iface, serialno, args.verbose)

    if not args.force:
        vers = do_version(tinys)
        print("Current %s version is   %s" % (boardname, vers))

        newvers = find_available_version(boardname, binfile)
        print("Available %s version is %s" % (boardname, newvers))

        if newvers == vers:
            print("No version update needed")
            if args.reboot:
                select(tinys, 'ro')
            return
        else:
            print("Updating to recommended version.")

    # Make sure the servo MCU is in RO
    select(tinys, 'ro')

    vers = do_updater_version(tinys)
    # To make sure that the tiny_servod here does not interfere with other
    # processes, close it out.
    tinys.close()
    if vers == 2:
        flash(brdfile, serialno, binfile)
    elif vers == 6:
        flash2(vidpid, serialno, binfile)
    else:
        raise ServoUpdaterException("Can't detect updater version")

    # Make sure device is up.
    c.wait_for_usb(vidpid, serialname=serialno)
    # After we have made sure that it's back/available, reconnect the tiny servod.
    tinys.reinitialize()

    # Make sure the servo MCU is in RW
    select(tinys, 'rw')

    vers = do_updater_version(tinys)
    if vers == 2:
        flash(brdfile, serialno, binfile)
    elif vers == 6:
        flash2(vidpid, serialno, binfile)
    else:
        raise ServoUpdaterException("Can't detect updater version")

    # Make sure the servo MCU is in RO
    select(tinys, 'ro')