From 5db3d3f18e031c751c5500bea5c5f4700f0db681 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Wed, 27 Jan 2021 17:10:54 -0800 Subject: [PATCH] don't reflash agnos update if already flashed (#19944) Co-authored-by: Comma Device old-commit-hash: c95c4df51df33094ed88ff78ee16000208272678 --- selfdrive/hardware/tici/agnos.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/selfdrive/hardware/tici/agnos.py b/selfdrive/hardware/tici/agnos.py index 26b6d8f7b1..b85fc4ad24 100755 --- a/selfdrive/hardware/tici/agnos.py +++ b/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)