Files
retroSoC/scripts/hp_tools.py
T
maksyuki 0e36b6a82f feat: introduce RV64 support and related tooling for HP workloads
- Added build_hp_rtthread.py for building the RT-Thread kernel with RV64 support.
- Updated build_hp_smoke.py to target RV64 architecture and modified output filenames.
- Modified generate_vexiiriscv.py to reflect RV64 configuration and memory management.
- Created hp_tools.py for shared utilities related to RV64 builds.
- Enhanced package_hp_boot.py to package RV64 workloads and updated versioning.
- Implemented run_hp_sim.py for executing and validating HP workloads with specific markers.
- Developed setup_hp_rtthread.py for installing RT-Thread source and environment setup.
- Updated GenerateRetroSocHp.scala to generate RV64 application cores.
- Enhanced tests for HP boot bundles, platform specifications, and tool utilities to accommodate RV64 changes.
- Adjusted test cases to validate new workload types and ensure compatibility with RV64 architecture.
2026-09-26 15:47:26 +08:00

47 lines
1.7 KiB
Python

"""Shared locked RV64 build helpers for HP payloads."""
from __future__ import annotations
import argparse
import struct
import subprocess
from pathlib import Path
try:
from scripts.dependency_lock import load_lock
except ModuleNotFoundError:
from dependency_lock import load_lock
def cross_prefix(root: Path) -> str:
spec = load_lock(root / "dependencies/dependencies.lock.json")["toolchains"]["ubuntu-22.04"][
"riscv_gnu_hp"
]
return str(root / ".cache/retrosoc/development/toolchains" /
f"riscv_gnu_hp-{spec['version']}" / spec["path"] / "riscv64-unknown-elf-")
def require_rv64_elf(path: Path) -> None:
header = path.read_bytes()[:64]
if (len(header) < 64 or header[:6] != b"\x7fELF\x02\x01" or
struct.unpack_from("<H", header, 18)[0] != 243):
raise ValueError(f"expected a little-endian RV64 ELF: {path}")
def require_revision(root: Path, name: str) -> Path:
spec = load_lock(root / "dependencies/dependencies.lock.json")["sources"][name]
source = root / spec["destination"]
actual = subprocess.check_output(["git", "-C", str(source), "rev-parse", "HEAD"], text=True).strip()
if actual != spec["revision"]:
raise ValueError(f"{name} revision mismatch: {actual} != {spec['revision']}")
if subprocess.run(["git", "-C", str(source), "diff", "--quiet", "HEAD", "--"],
check=False).returncode:
raise ValueError(f"{name} has modified tracked source files: {source}")
return source
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--root", type=Path, required=True)
print(cross_prefix(parser.parse_args().root.resolve()))