Skip to content

Commit e114337

Browse files
committed
scripts: Fix version parsing
The family is parsed wrong, fix the names and parsing logic. Signed-off-by: Chaitanya Tata <[email protected]>
1 parent b1cf92c commit e114337

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

scripts/update_blobs.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,24 @@
3030
def parse_version_from_binary(binary_data: bytes) -> str:
3131
"""
3232
Parse version from firmware binary.
33-
Version is stored at bytes 8-12, e.g., 02 0e 02 01 -> 1.2.14.2
33+
Version format: FAMILY.MAJOR.MINOR.PATCH
34+
Based on patch_info.h: RPU_FAMILY, RPU_MAJOR_VERSION, RPU_MINOR_VERSION, RPU_PATCH_VERSION
3435
"""
3536
if len(binary_data) < 12:
3637
logger.warning("Binary too short to extract version, using default")
3738
return "1.0.0"
3839

39-
# Extract version bytes (positions 8-12 reversed)
40-
version_bytes = binary_data[12:8:-1]
41-
42-
# Convert to version string: 01 02 0e 02 -> 1.2.14.2
43-
44-
version = ".".join(str(byte) for byte in version_bytes)
40+
# Extract version bytes (positions 8-11)
41+
# Display format: FAMILY.MAJOR.MINOR.PATCH
42+
# Bytes are stored in reverse order due to endianness: patch.min.maj.fam
43+
# Example: 33 0d 02 01 -> 1.1.2.51 (FAMILY.MAJOR.MINOR.PATCH)
44+
patch = binary_data[8] # byte 8 = patch version (RPU_PATCH_VERSION) - 0x33 = 51
45+
minor = binary_data[9] # byte 9 = minor version (RPU_MINOR_VERSION) - 0x0d = 13
46+
major = binary_data[10] # byte 10 = major version (RPU_MAJOR_VERSION) - 0x02 = 2
47+
family = binary_data[11] # byte 11 = family (RPU_FAMILY) - 0x01 = 1
48+
49+
# Display as FAMILY.MAJOR.MINOR.PATCH
50+
version = f"{family}.{major}.{minor}.{patch}"
4551
logger.debug(f"Extracted version from binary: {version}")
4652
return version
4753

0 commit comments

Comments
 (0)