Ejemplo n.º 1
0
    def test_verify_update(self):
        # good state
        download_neos_update(self.fake_manifest)
        self.assertTrue(verify_update_ready(self.fake_manifest))

        # corrupt recovery
        self._corrupt_recovery()
        self.assertFalse(verify_update_ready(self.fake_manifest))

        # back to good state
        download_neos_update(self.fake_manifest)
        self.assertTrue(verify_update_ready(self.fake_manifest))

        # corrupt ota
        self._corrupt_recovery()
        with open(
                os.path.join(NEOSUPDATE_DIR,
                             os.path.basename(self.manifest['ota_url'])),
                "ab") as f:
            f.write(b'\x00')
        self.assertFalse(verify_update_ready(self.fake_manifest))
Ejemplo n.º 2
0
def handle_neos_update(wait_helper: WaitTimeHelper) -> None:
    from selfdrive.hardware.eon.neos import download_neos_update

    cur_neos = HARDWARE.get_os_version()
    updated_neos = run([
        "bash", "-c",
        r"unset REQUIRED_NEOS_VERSION && source launch_env.sh && \
                       echo -n $REQUIRED_NEOS_VERSION"
    ], OVERLAY_MERGED).strip()

    cloudlog.info(f"NEOS version check: {cur_neos} vs {updated_neos}")
    if cur_neos == updated_neos:
        return

    cloudlog.info(f"Beginning background download for NEOS {updated_neos}")
    set_offroad_alert("Offroad_NeosUpdate", True)

    update_manifest = os.path.join(OVERLAY_MERGED,
                                   "selfdrive/hardware/eon/neos.json")

    neos_downloaded = False
    start_time = time.monotonic()
    # Try to download for one day
    while not neos_downloaded and not wait_helper.shutdown and \
          (time.monotonic() - start_time < 60*60*24):
        wait_helper.ready_event.clear()
        try:
            download_neos_update(update_manifest, cloudlog)
            neos_downloaded = True
        except Exception:
            cloudlog.info("NEOS background download failed, retrying")
            wait_helper.sleep(120)

    # If the download failed, we'll show the alert again when we retry
    set_offroad_alert("Offroad_NeosUpdate", False)
    if not neos_downloaded:
        raise Exception("Failed to download NEOS update")
    cloudlog.info(
        f"NEOS background download successful, took {time.monotonic() - start_time} seconds"
    )
Ejemplo n.º 3
0
 def test_download_update(self):
     download_neos_update(self.fake_manifest)
     self.assertTrue(verify_update_ready(self.fake_manifest))