don't reflash agnos update if already flashed (#19944)

Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: c95c4df51d
commatwo_master
Adeeb Shihadeh 4 years ago committed by GitHub
parent 933f2952bd
commit 5db3d3f18e
  1. 9
      selfdrive/hardware/tici/agnos.py

@ -80,8 +80,15 @@ def flash_partition(cloudlog, spinner, target_slot, partition):
cloudlog.info(f"Downloading and writing {partition['name']}")
downloader = StreamingDecompressor(partition['url'])
with open(f"/dev/disk/by-partlabel/{partition['name']}{target_slot}", 'wb') as out:
with open(f"/dev/disk/by-partlabel/{partition['name']}{target_slot}", 'wb+') as out:
partition_size = partition['size']
# Check if partition is already flashed
out.seek(partition_size)
if out.read(64) == partition['hash_raw'].lower().encode():
cloudlog.info(f"Already flashed {partition['name']}")
return
# Clear hash before flashing
out.seek(partition_size)
out.write(b"\x00" * 64)

Loading…
Cancel
Save