diff --git a/src/vitis_checker.py b/src/vitis_checker.py index bb241cf..67f3d60 100644 --- a/src/vitis_checker.py +++ b/src/vitis_checker.py @@ -317,6 +317,19 @@ def get_bootgen_path(vitis_path: str = "", xilinx_root: str = "") -> str | None: return _find_executable("bootgen", vitis_path, platform.system().lower(), xilinx_root) +def get_vivado_path(vitis_path: str = "", xilinx_root: str = "") -> str | None: + """Find the Vivado executable (JTAG operations via hw_server). + + Args: + vitis_path: Legacy Vitis installation directory. + xilinx_root: Xilinx root directory. + + Returns: + Path to vivado executable, or None. + """ + return _find_executable("vivado", vitis_path, platform.system().lower(), xilinx_root) + + # ── Tool version detection ─────────────────────────────────────────── diff --git a/src/zynq_checker.py b/src/zynq_checker.py index f231551..1936a66 100644 --- a/src/zynq_checker.py +++ b/src/zynq_checker.py @@ -10,13 +10,13 @@ from __future__ import annotations import os import re -import shutil import subprocess from dataclasses import dataclass, field from pathlib import Path from typing import Callable from config_manager import Config +from vitis_checker import get_vivado_path, build_tool_command @dataclass @@ -86,9 +86,10 @@ def check_zynq_jtag(config: Config, callback: Callable | None = None) -> ZynqChe if callback: callback("start", "Connecting to hw_server...") - # Find vivado executable - vivado_path = _get_vivado_path( - config.vitis_path if hasattr(config, 'vitis_path') else "" + # Find vivado executable via Xilinx root scan + vivado_path = get_vivado_path( + vitis_path=getattr(config, "vitis_path", ""), + xilinx_root=getattr(config, "xilinx_path", ""), ) if not vivado_path: return ZynqCheckResult( @@ -110,8 +111,8 @@ def check_zynq_jtag(config: Config, callback: Callable | None = None) -> ZynqChe if callback: callback("progress", "Scanning JTAG chain...") - # Run Vivado in batch mode - cmd = [vivado_path, "-mode", "batch", "-source", str(tcl_path)] + # Run Vivado in batch mode (with environment setup) + cmd = build_tool_command(vivado_path, "-mode", "batch", "-source", str(tcl_path)) result = subprocess.run( cmd, capture_output=True, @@ -322,35 +323,6 @@ def _parse_zynq_device(device_name: str) -> ZynqDevice | None: ) -def _get_vivado_path(vitis_path: str) -> str | None: - """Find the Vivado executable path. - - Args: - vitis_path: Vitis installation path. - - Returns: - Path to Vivado executable, or None if not found. - """ - path = shutil.which("vivado") - if path: - return path - if vitis_path: - candidate = Path(vitis_path) / "bin" / "vivado" - if candidate.exists(): - return str(candidate) - candidate = Path(vitis_path) / "bin" / "vivado.exe" - if candidate.exists(): - return str(candidate) - common_paths = [ - "/opt/xilinx/bin/vivado", - os.path.expanduser("~/Xilinx/Vivado/bin/vivado"), - ] - for p in common_paths: - if os.path.isfile(p): - return p - return None - - def get_zynq_status_dict(result: ZynqCheckResult) -> dict: """Convert a ZynqCheckResult to a serializable dictionary.