Skip to content

Commit

Permalink
agnos.py: retry swap (commaai#21608)
Browse files Browse the repository at this point in the history
* retry until success

* try this

* redirect stderr

* also check positive

* add logging

* f string
  • Loading branch information
pd0wm authored Jul 15, 2021
1 parent d20154e commit f4d87ce
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions selfdrive/hardware/tici/agnos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -246,6 +252,6 @@ def verify_agnos_update(manifest_path: str, target_slot_number: int) -> bool:
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)

0 comments on commit f4d87ce

Please sign in to comment.