agnos.py: retry swap (#21608)

* retry until success

* try this

* redirect stderr

* also check positive

* add logging

* f string
pull/21614/head
Willem Melching 4 years ago committed by GitHub
parent d20154e6f4
commit f4d87cecf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      selfdrive/hardware/tici/agnos.py

@ -176,13 +176,19 @@ def flash_partition(target_slot_number: int, partition: dict, cloudlog, spinner:
out.write(partition['hash_raw'].lower().encode())
def swap(manifest_path: str, target_slot_number: int) -> None:
def swap(manifest_path: str, target_slot_number: int, cloudlog) -> None:
update = json.load(open(manifest_path))
for partition in update:
if not partition.get('full_check', False):
clear_partition_hash(target_slot_number, partition)
subprocess.check_output(f"abctl --set_active {target_slot_number}", shell=True)
while True:
out = subprocess.check_output(f"abctl --set_active {target_slot_number}", shell=True, stderr=subprocess.STDOUT, encoding='utf8')
if ("No such file or directory" not in out) and ("lun as boot lun" in out):
cloudlog.info(f"Swap successfull {out}")
break
else:
cloudlog.error(f"Swap failed {out}")
def flash_agnos_update(manifest_path: str, target_slot_number: int, cloudlog, spinner: Optional[Spinner] = None) -> None:
@ -246,6 +252,6 @@ if __name__ == "__main__":
flash_agnos_update(args.manifest, target_slot_number, logging, spinner)
logging.warning(f"Verification succeeded. Swapping to slot {target_slot_number}")
swap(args.manifest, target_slot_number)
swap(args.manifest, target_slot_number, logging)
else:
flash_agnos_update(args.manifest, target_slot_number, logging, spinner)

Loading…
Cancel
Save