From 18f37937cc0edb0151d17ee7d15a142e88ec3a5b Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Wed, 8 Apr 2026 18:34:21 +0200 Subject: [PATCH] compute_version_hash: normalize Windows line endings (#2383) * compute_version_hash: normalize Windows line endings * also update function in SConscript --- SConscript | 3 ++- python/constants.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/SConscript b/SConscript index 45abd074..de770920 100644 --- a/SConscript +++ b/SConscript @@ -154,7 +154,8 @@ with open("board/obj/cert.h", "w") as f: # Packet version defines: SHA hash of the struct header files def version_hash(path): with open(path, "rb") as f: - return int.from_bytes(hashlib.sha256(f.read()).digest()[:4], 'little') + # Normalize line endings on Windows + return int.from_bytes(hashlib.sha256(f.read().replace(b'\r', b'')).digest()[:4], 'little') hh, ch, jh = version_hash("board/health.h"), version_hash(os.path.join(opendbc.INCLUDE_PATH, "opendbc/safety/can.h")), version_hash("board/jungle/jungle_health.h") common_flags += [f"-DHEALTH_PACKET_VERSION=0x{hh:08X}U", f"-DCAN_PACKET_VERSION_HASH=0x{ch:08X}U", f"-DJUNGLE_HEALTH_PACKET_VERSION=0x{jh:08X}U"] diff --git a/python/constants.py b/python/constants.py index 85e8c99c..d69f2050 100644 --- a/python/constants.py +++ b/python/constants.py @@ -8,7 +8,8 @@ FW_PATH = os.path.join(BASEDIR, "board/obj/") def compute_version_hash(filepath): with open(filepath, "rb") as f: - return int.from_bytes(hashlib.sha256(f.read()).digest()[:4], 'little') + # Normalize line endings on Windows + return int.from_bytes(hashlib.sha256(f.read().replace(b'\r', b'')).digest()[:4], 'little') USBPACKET_MAX_SIZE = 0x40