refactor: replace all config.vitis_path with config.xilinx_path across codebase
Affected files: - flash_programmer.py (2 call sites) — get_program_flash_path - bitstream_programmer.py (3 get_xsct_path + 1 get_vivado_path call sites) Also: removed duplicate _get_vivado_path() (now uses shared one from vitis_checker) Also: removed unused shutil import - reboot_manager.py (1 call site) — get_xsct_path All now use getattr(config, 'xilinx_path', '') consistently. The only remaining 'config.vitis_path' reference is in vitis_checker.py's check_vitis() itself (safe legacy fallback for old configs).
This commit is contained in:
@@ -11,14 +11,13 @@ Compatible with Xilinx 2018.3 — 2023.2.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
|
||||||
import subprocess
|
import subprocess
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
from config_manager import Config
|
from config_manager import Config
|
||||||
from vitis_checker import get_xsct_path
|
from vitis_checker import get_xsct_path, get_vivado_path
|
||||||
|
|
||||||
# ── Types ───────────────────────────────────────────────────────────
|
# ── Types ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -38,35 +37,6 @@ ProgressCallback = Callable[[str, str], None] | None
|
|||||||
# ── Helpers ─────────────────────────────────────────────────────────
|
# ── Helpers ─────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|
||||||
def _get_vivado_path(vitis_path: str) -> str | None:
|
|
||||||
"""Find the Vivado executable.
|
|
||||||
|
|
||||||
Uses shutil.which() for PATH resolution, then common install paths.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
vitis_path: Optional Vitis installation directory.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Path to vivado executable, or None.
|
|
||||||
"""
|
|
||||||
found = shutil.which("vivado")
|
|
||||||
if found:
|
|
||||||
return found
|
|
||||||
if vitis_path:
|
|
||||||
candidate = Path(vitis_path) / "bin" / "vivado"
|
|
||||||
if candidate.is_file():
|
|
||||||
return str(candidate)
|
|
||||||
common = [
|
|
||||||
"/data/xilinx/Vivado/2023.2/bin/vivado",
|
|
||||||
"/opt/xilinx/bin/vivado",
|
|
||||||
os.path.expanduser("~/Xilinx/Vivado/2023.2/bin/vivado"),
|
|
||||||
]
|
|
||||||
for p in common:
|
|
||||||
if os.path.isfile(p):
|
|
||||||
return p
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def _find_ps7_init_tcl(config: Config) -> str:
|
def _find_ps7_init_tcl(config: Config) -> str:
|
||||||
"""Find the ps7_init.tcl file for PS initialization.
|
"""Find the ps7_init.tcl file for PS initialization.
|
||||||
|
|
||||||
@@ -167,16 +137,15 @@ def program_bitstream(
|
|||||||
|
|
||||||
# Try xsct first (preferred)
|
# Try xsct first (preferred)
|
||||||
xsct = get_xsct_path(
|
xsct = get_xsct_path(
|
||||||
vitis_path=config.vitis_path if hasattr(config, 'vitis_path') else "",
|
xilinx_root=getattr(config, "xilinx_path", ""),
|
||||||
xilinx_root=config.xilinx_path if hasattr(config, 'xilinx_path') else "",
|
|
||||||
)
|
)
|
||||||
if xsct:
|
if xsct:
|
||||||
timeout = config.step_timeouts.get("bitstream", 60)
|
timeout = config.step_timeouts.get("bitstream", 60)
|
||||||
return _program_with_xsct(xsct, bit_path, callback, ps7_tcl, timeout)
|
return _program_with_xsct(xsct, bit_path, callback, ps7_tcl, timeout)
|
||||||
|
|
||||||
# Fallback to Vivado
|
# Fallback to Vivado
|
||||||
vivado = _get_vivado_path(
|
vivado = get_vivado_path(
|
||||||
config.vitis_path if hasattr(config, 'vitis_path') else ""
|
xilinx_root=getattr(config, "xilinx_path", ""),
|
||||||
)
|
)
|
||||||
if vivado:
|
if vivado:
|
||||||
return _program_with_vivado(vivado, bit_path, callback)
|
return _program_with_vivado(vivado, bit_path, callback)
|
||||||
@@ -364,8 +333,7 @@ def run_elf(
|
|||||||
callback("start", f"Running ELF: {elf_path.name}...")
|
callback("start", f"Running ELF: {elf_path.name}...")
|
||||||
|
|
||||||
xsct = get_xsct_path(
|
xsct = get_xsct_path(
|
||||||
vitis_path=config.vitis_path if hasattr(config, 'vitis_path') else "",
|
xilinx_root=getattr(config, "xilinx_path", ""),
|
||||||
xilinx_root=config.xilinx_path if hasattr(config, 'xilinx_path') else "",
|
|
||||||
)
|
)
|
||||||
if not xsct:
|
if not xsct:
|
||||||
return BitstreamResult(
|
return BitstreamResult(
|
||||||
@@ -579,8 +547,7 @@ def full_bitstream_program(
|
|||||||
message=f"FSBL not found: {fsbl_path or '(not configured)'}")]
|
message=f"FSBL not found: {fsbl_path or '(not configured)'}")]
|
||||||
|
|
||||||
xsct = get_xsct_path(
|
xsct = get_xsct_path(
|
||||||
vitis_path=config.vitis_path if hasattr(config, 'vitis_path') else "",
|
xilinx_root=getattr(config, "xilinx_path", ""),
|
||||||
xilinx_root=config.xilinx_path if hasattr(config, 'xilinx_path') else "",
|
|
||||||
)
|
)
|
||||||
if not xsct:
|
if not xsct:
|
||||||
return [BitstreamResult(step="bitstream", success=False,
|
return [BitstreamResult(step="bitstream", success=False,
|
||||||
|
|||||||
@@ -113,8 +113,7 @@ def wipe_flash(
|
|||||||
FlashResult with status.
|
FlashResult with status.
|
||||||
"""
|
"""
|
||||||
flash_tool = get_program_flash_path(
|
flash_tool = get_program_flash_path(
|
||||||
vitis_path=config.vitis_path if hasattr(config, 'vitis_path') else "",
|
xilinx_root=getattr(config, "xilinx_path", ""),
|
||||||
xilinx_root=config.xilinx_path if hasattr(config, 'xilinx_path') else "",
|
|
||||||
)
|
)
|
||||||
if not flash_tool:
|
if not flash_tool:
|
||||||
return FlashResult(
|
return FlashResult(
|
||||||
@@ -229,8 +228,7 @@ def program_flash_bin(
|
|||||||
)
|
)
|
||||||
|
|
||||||
flash_tool = get_program_flash_path(
|
flash_tool = get_program_flash_path(
|
||||||
vitis_path=config.vitis_path if hasattr(config, 'vitis_path') else "",
|
xilinx_root=getattr(config, "xilinx_path", ""),
|
||||||
xilinx_root=config.xilinx_path if hasattr(config, 'xilinx_path') else "",
|
|
||||||
)
|
)
|
||||||
if not flash_tool:
|
if not flash_tool:
|
||||||
return FlashResult(
|
return FlashResult(
|
||||||
|
|||||||
@@ -186,8 +186,7 @@ def reboot_via_jtag(
|
|||||||
from vitis_checker import get_xsct_path
|
from vitis_checker import get_xsct_path
|
||||||
|
|
||||||
xsct = get_xsct_path(
|
xsct = get_xsct_path(
|
||||||
vitis_path=config.vitis_path if hasattr(config, 'vitis_path') else "",
|
xilinx_root=getattr(config, "xilinx_path", ""),
|
||||||
xilinx_root=config.xilinx_path if hasattr(config, 'xilinx_path') else "",
|
|
||||||
)
|
)
|
||||||
if not xsct:
|
if not xsct:
|
||||||
return RebootResult(
|
return RebootResult(
|
||||||
|
|||||||
Reference in New Issue
Block a user