diff --git a/tools/_binary_path.py b/tools/_binary_path.py index 1c6f6a7b..1de61cec 100644 --- a/tools/_binary_path.py +++ b/tools/_binary_path.py @@ -35,7 +35,11 @@ def verify_580_binary(path: Path, expected_sha256: str = REFERENCE_580_SHA256) - def resolve_580_binary(*, verify: bool = False) -> Path: """Resolve `nv-kernel.o_binary` via env overrides, local target, system `/usr/src`, or legacy path.""" path: Path | None = None - explicit = os.environ.get("NV_RS_580_BINARY") or os.environ.get("NV_RS_ORIGINAL") + explicit = ( + os.environ.get("NV_RS_580_BINARY") + or os.environ.get("NV_RS_ORIGINAL_BINARY") + or os.environ.get("NV_RS_ORIGINAL") + ) if explicit: path = Path(explicit) else: diff --git a/tools/gp106/bar2_setup.py b/tools/gp106/bar2_setup.py index 14935abd..27b88642 100644 --- a/tools/gp106/bar2_setup.py +++ b/tools/gp106/bar2_setup.py @@ -43,18 +43,24 @@ BUS_BYTES, GPU_BYTES = 0xB400, 0x1000 def load_harness(): """Definitions of the frozen GV100 harness, with the binary path injected.""" - local = ROOT / "target/reference-580.178.04/kernel/nvidia/nv-kernel.o_binary" - default = ( - local - if local.is_file() - else Path("/home/geodd/nvidia-driver/analysis-580.178.04/extracted/kernel/nvidia/nv-kernel.o_binary") - ) - binary = Path(os.environ.get("NV_RS_ORIGINAL_BINARY", os.environ.get("NV_RS_ORIGINAL", default))) + tools_dir = str(ROOT / "tools") + if tools_dir not in sys.path: + sys.path.insert(0, tools_dir) + from _binary_path import resolve_580_binary + + binary = resolve_580_binary() if not binary.is_absolute(): binary = (ROOT / binary).resolve() source = HARNESS.read_text() - source = re.sub(r"^ORIGINAL = Path\(.*\)$", "ORIGINAL = Path(%r)" % str(binary), - source, count=1, flags=re.M) + source, replaced = re.subn( + r"^ORIGINAL = (?:Path\(.*\)|resolve_580_binary\(.*\))$", + "ORIGINAL = Path(%r)" % str(binary), + source, + count=1, + flags=re.M, + ) + if replaced != 1: + raise SystemExit("the frozen GV100 harness no longer has a patchable ORIGINAL assignment") head, marker, _ = source.partition("\nrows = []\n") if not marker: raise SystemExit("the frozen GV100 harness no longer has its case-list marker")