[PATCH i-g-t 2/2] intel-gfx-fw-info: Allow to print checksum
Gustavo Sousa
gustavo.sousa at intel.com
Wed Aug 14 12:25:24 UTC 2024
Quoting Gustavo Sousa (2024-08-14 09:03:11-03:00)
>Quoting Lucas De Marchi (2024-08-13 12:21:41-03:00)
>>Choose a checksum algo and use it to print when parsing a firmware.
>>This may be useful in CI to dump what is the exact firmware used
>>and may also be useful when inspecting the firmware repo and making
>>sure mistakes are not introduced. Configuring intel-gfx-fw-info a diff
>>driver:
>>
>> firmware $ echo "*.bin diff=intelfw" >> .git/info/attributes
>> firmware $ git config --local \
>> diff.intelfw.textconv \
>> "<path-to-igt>/tools/intel-gfx-fw-info -c"
>>
>>Example for the LNL update that happened recently:
>>
>> firmware $ git diff --text bc42cdc34bd8 b5bef5bdbab1 -- xe/lnl_guc_70.bin
>> diff --git a/xe/lnl_guc_70.bin b/xe/lnl_guc_70.bin
>> index 785763163..75a1958f7 100644
>> --- a/xe/lnl_guc_70.bin
>> +++ b/xe/lnl_guc_70.bin
>> @@ -1,3 +1,3 @@
>> -version: 70.20.0
>> -date: 2024-02-09
>> -checksum: 0809f459048a23716fd3019074f36812163e027835cbb43acfcfe72cd83fb0cc
>> +version: 70.29.2
>> +date: 2024-07-26
>> +checksum: e7ceae28b06bd71c53fe177f4f6787aac88956d8944fa02b1ab2ec53b1e961e4
>>
>>If for some reason there's only a checksum change, something went wrong,
>>and without it we wouldn't notice when using this tool as a diff driver.
>>
>>Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
>
>Reviewed-by: Gustavo Sousa <gustavo.sousa at intel.com>
By the way, "Dump GuC/HuC firmware header" is not a very accurate
description for this command anymore, since we skip doing that after
this. Maybe extend this patch to replace it with "Dump GuC/HuC firmware
information"?
--
Gustavo Sousa
>
>>---
>> tools/intel-gfx-fw-info | 17 +++++++++++++++++
>> 1 file changed, 17 insertions(+)
>>
>>diff --git a/tools/intel-gfx-fw-info b/tools/intel-gfx-fw-info
>>index c0d9b00ac..31dc78776 100755
>>--- a/tools/intel-gfx-fw-info
>>+++ b/tools/intel-gfx-fw-info
>>@@ -6,6 +6,7 @@
>>
>> import argparse
>> import logging
>>+import hashlib
>> import sys
>> import typing
>>
>>@@ -151,18 +152,26 @@ def parse_args(argv: typing.List[str]) -> argparse.Namespace:
>>
>> parser.add_argument("-x", "--raw", action="store_true",
>> help="Also print raw header content")
>>+ parser.add_argument("-c", "--checksum", action="store_true",
>>+ help="Also print checksum")
>>
>> parser.add_argument("filename", help="GuC/HuC firmware file")
>>
>> return parser.parse_args(argv)
>>
>>
>>+def calculate_checksum(f: typing.BinaryIO) -> str:
>>+ return hashlib.sha256(f.read()).hexdigest()
>>+
>>+
>> def main(argv: typing.List[str]) -> int:
>> args = parse_args(argv)
>>
>> cparser = cstruct.cstruct()
>> cparser.load(CDEF)
>>
>>+ checksum = None
>>+
>> try:
>> with open(args.filename, mode="rb") as f:
>> magic = cparser.magic(f)
>>@@ -171,6 +180,11 @@ def main(argv: typing.List[str]) -> int:
>> fw = FwGsc(cparser.uc_huc_gsc_header(f))
>> else:
>> fw = FwCss(cparser.uc_css_header(f))
>>+
>>+ if args.checksum:
>>+ f.seek(0, 0)
>>+ checksum = calculate_checksum(f)
>>+
>> except FileNotFoundError as e:
>> logging.fatal(e)
>> return 1
>>@@ -181,6 +195,9 @@ def main(argv: typing.List[str]) -> int:
>> print("raw dump:", end="")
>> cstruct.dumpstruct(fw.fw, color=sys.stdout.isatty())
>>
>>+ if checksum:
>>+ print(f"checksum: {checksum}")
>>+
>> return 0
>>
>>
>>--
>>2.43.0
>>
More information about the igt-dev
mailing list