Ejemplo n.º 1
0
def update_panda():
    panda = None
    panda_dfu = None

    cloudlog.info("Connecting to panda")

    while True:
        # break on normal mode Panda
        panda_list = Panda.list()
        if len(panda_list) > 0:
            cloudlog.info("Panda found, connecting")
            panda = Panda(panda_list[0])
            break

        # flash on DFU mode Panda
        panda_dfu = PandaDFU.list()
        if len(panda_dfu) > 0:
            cloudlog.info("Panda in DFU mode found, flashing recovery")
            panda_dfu = PandaDFU(panda_dfu[0])
            panda_dfu.recover()

        time.sleep(1)

    fw_fn = get_firmware_fn()
    fw_signature = get_expected_signature(fw_fn)

    try:
        serial = panda.get_serial()[0].decode("utf-8")
    except Exception:
        serial = None

    panda_version = "bootstub" if panda.bootstub else panda.get_version()
    panda_signature = b"" if panda.bootstub else panda.get_signature()
    cloudlog.warning(
        "Panda %s connected, version: %s, signature %s, expected %s" % (
            serial,
            panda_version,
            panda_signature.hex(),
            fw_signature.hex(),
        ))

    if panda.bootstub or panda_signature != fw_signature:
        cloudlog.info("Panda firmware out of date, update required")
        panda.flash(fw_fn)
        cloudlog.info("Done flashing")

    if panda.bootstub:
        cloudlog.info(
            "Flashed firmware not booting, flashing development bootloader")
        panda.recover()
        cloudlog.info("Done flashing bootloader")

    if panda.bootstub:
        cloudlog.info("Panda still not booting, exiting")
        raise AssertionError

    panda_signature = panda.get_signature()
    if panda_signature != fw_signature:
        cloudlog.info("Version mismatch after flashing, exiting")
        raise AssertionError
Ejemplo n.º 2
0
def update_panda():
    with open(os.path.join(BASEDIR, "VERSION")) as f:
        repo_version = f.read()
    repo_version += "-EON" if os.path.isfile('/EON') else "-DEV"

    panda = None
    panda_dfu = None

    cloudlog.info("Connecting to panda")

    while True:
        # break on normal mode Panda
        panda_list = Panda.list()
        if len(panda_list) > 0:
            cloudlog.info("Panda found, connecting")
            panda = Panda(panda_list[0])
            break

        # flash on DFU mode Panda
        panda_dfu = PandaDFU.list()
        if len(panda_dfu) > 0:
            cloudlog.info("Panda in DFU mode found, flashing recovery")
            panda_dfu = PandaDFU(panda_dfu[0])
            panda_dfu.recover()

        print "waiting for board..."
        time.sleep(1)

    current_version = "bootstub" if panda.bootstub else str(
        panda.get_version())
    cloudlog.info("Panda connected, version: %s, expected %s" %
                  (current_version, repo_version))

    if panda.bootstub or not current_version.startswith(repo_version):
        cloudlog.info("Panda firmware out of date, update required")

        signed_fn = os.path.join(BASEDIR, "board", "obj", "panda.bin.signed")
        if os.path.exists(signed_fn):
            cloudlog.info("Flashing signed firmware")
            panda.flash(fn=signed_fn)
        else:
            cloudlog.info("Building and flashing unsigned firmware")
            panda.flash()

        cloudlog.info("Done flashing")

    if panda.bootstub:
        cloudlog.info(
            "Flashed firmware not booting, flashing development bootloader")
        panda.recover()
        cloudlog.info("Done flashing bootloader")

    if panda.bootstub:
        cloudlog.info("Panda still not booting, exiting")
        raise AssertionError

    version = str(panda.get_version())
    if not version.startswith(repo_version):
        cloudlog.info("Version mismatch after flashing, exiting")
        raise AssertionError
Ejemplo n.º 3
0
def update_panda():
  repo_version = get_expected_version()

  panda = None
  panda_dfu = None

  cloudlog.info("Connecting to panda")

  while True:
    # break on normal mode Panda
    panda_list = Panda.list()
    if len(panda_list) > 0:
      cloudlog.info("Panda found, connecting")
      panda = Panda(panda_list[0])
      break

    # flash on DFU mode Panda
    panda_dfu = PandaDFU.list()
    if len(panda_dfu) > 0:
      cloudlog.info("Panda in DFU mode found, flashing recovery")
      panda_dfu = PandaDFU(panda_dfu[0])
      panda_dfu.recover()

    print("waiting for board...")
    time.sleep(1)

  try:
    serial = panda.get_serial()[0].decode("utf-8")
  except Exception:
    serial = None
  current_version = "bootstub" if panda.bootstub else panda.get_version()
  cloudlog.warning("Panda %s connected, version: %s, expected %s" % (serial, current_version, repo_version))

  if panda.bootstub or not current_version.startswith(repo_version):
    cloudlog.info("Panda firmware out of date, update required")

    signed_fn = os.path.join(BASEDIR, "board", "obj", "panda.bin.signed")
    if os.path.exists(signed_fn):
      cloudlog.info("Flashing signed firmware")
      panda.flash(fn=signed_fn)
    else:
      cloudlog.info("Building and flashing unsigned firmware")
      panda.flash()

    cloudlog.info("Done flashing")

  if panda.bootstub:
    cloudlog.info("Flashed firmware not booting, flashing development bootloader")
    panda.recover()
    cloudlog.info("Done flashing bootloader")

  if panda.bootstub:
    cloudlog.info("Panda still not booting, exiting")
    raise AssertionError

  version = panda.get_version()
  if not version.startswith(repo_version):
    cloudlog.info("Version mismatch after flashing, exiting")
    raise AssertionError
Ejemplo n.º 4
0
def ensure_st_up_to_date():
    from panda import Panda, PandaDFU, BASEDIR

    with open(os.path.join(BASEDIR, "VERSION")) as f:
        repo_version = f.read()

    repo_version += "-EON" if os.path.isfile('/EON') else "-DEV"

    panda = None
    panda_dfu = None
    should_flash_recover = False

    while 1:
        # break on normal mode Panda
        panda_list = Panda.list()
        if len(panda_list) > 0:
            panda = Panda(panda_list[0])
            break

        # flash on DFU mode Panda
        panda_dfu = PandaDFU.list()
        if len(panda_dfu) > 0:
            panda_dfu = PandaDFU(panda_dfu[0])
            panda_dfu.recover()

        print("waiting for board...")
        time.sleep(1)

    if panda.bootstub or not panda.get_version().startswith(repo_version):
        panda.flash()

    if panda.bootstub:
        panda.recover()

    assert (not panda.bootstub)
    version = str(panda.get_version())
    print("%s should be %s" % (version, repo_version))
    assert (version.startswith(repo_version))