|
@@ -7,6 +7,7 @@ import argparse
|
|
|
import hashlib
|
|
import hashlib
|
|
|
import json
|
|
import json
|
|
|
import os
|
|
import os
|
|
|
|
|
+import re
|
|
|
import shutil
|
|
import shutil
|
|
|
import subprocess
|
|
import subprocess
|
|
|
import sys
|
|
import sys
|
|
@@ -20,6 +21,8 @@ if str(_ROOT) not in sys.path:
|
|
|
sys.path.insert(0, str(_ROOT))
|
|
sys.path.insert(0, str(_ROOT))
|
|
|
|
|
|
|
|
from tools.generate_target import generate_named_target
|
|
from tools.generate_target import generate_named_target
|
|
|
|
|
+from tools.generate_6400_v1 import generate as generate_6400_v1
|
|
|
|
|
+from tools.run_6400_td import HARDWARE_PROFILES, source_closure as td_source_closure
|
|
|
from tools.target_registry import ROOT, load_source_closure, release_blocked, resolve_target
|
|
from tools.target_registry import ROOT, load_source_closure, release_blocked, resolve_target
|
|
|
|
|
|
|
|
|
|
|
|
@@ -43,19 +46,75 @@ def _add(zipf: zipfile.ZipFile, src: Path, dest: str, sums: dict[str, str]) -> N
|
|
|
sums[dest] = _sha256(src)
|
|
sums[dest] = _sha256(src)
|
|
|
|
|
|
|
|
|
|
|
|
|
-def _6400_bitstream() -> Path:
|
|
|
|
|
- configured = os.environ.get("PROD2U_6400_BITSTREAM", "").strip()
|
|
|
|
|
- candidates = [Path(configured)] if configured else []
|
|
|
|
|
- candidates.extend(
|
|
|
|
|
- (
|
|
|
|
|
- ROOT / "dist" / "6400-bitstream" / "prod2u_6400_front_back.bit",
|
|
|
|
|
- ROOT / "evidence" / "bitstream" / "prod2u_6400_front_back.bit",
|
|
|
|
|
|
|
+def _check_active_6400_generated() -> None:
|
|
|
|
|
+ expected = generate_6400_v1(ROOT / "generated/6400")
|
|
|
|
|
+ drift = [
|
|
|
|
|
+ str(path.relative_to(ROOT))
|
|
|
|
|
+ for path, content in expected.items()
|
|
|
|
|
+ if not path.is_file() or path.read_bytes() != content
|
|
|
|
|
+ ]
|
|
|
|
|
+ if drift:
|
|
|
|
|
+ raise SystemExit("6400 package blocked: active generated contract drift: " + ", ".join(drift))
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def _resolve_6400_profile(target_name: str, profile_name: str | None) -> str:
|
|
|
|
|
+ if target_name in HARDWARE_PROFILES:
|
|
|
|
|
+ if profile_name is not None and profile_name != target_name:
|
|
|
|
|
+ raise SystemExit("6400 package blocked: target/profile mismatch")
|
|
|
|
|
+ return target_name
|
|
|
|
|
+ if target_name == "6400-sim-debug" or profile_name == "6400-sim-debug":
|
|
|
|
|
+ raise SystemExit("6400 package blocked: Sim-Debug cannot produce a hardware package")
|
|
|
|
|
+ if target_name != "6400" or profile_name not in HARDWARE_PROFILES:
|
|
|
|
|
+ raise SystemExit(
|
|
|
|
|
+ "6400 package blocked: explicitly select --profile "
|
|
|
|
|
+ "6400-control or 6400-identification"
|
|
|
)
|
|
)
|
|
|
- )
|
|
|
|
|
- for candidate in candidates:
|
|
|
|
|
- if candidate.is_file() and candidate.stat().st_size > 0:
|
|
|
|
|
- return candidate.resolve()
|
|
|
|
|
- raise SystemExit("firmware package blocked: 6400 production bitstream is missing")
|
|
|
|
|
|
|
+ return profile_name
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def _validated_td_bitstream(
|
|
|
|
|
+ profile_name: str, receipt_path: Path | None, commit: str
|
|
|
|
|
+) -> tuple[Path, dict[str, object]]:
|
|
|
|
|
+ if receipt_path is None or not receipt_path.is_file():
|
|
|
|
|
+ raise SystemExit("6400 firmware package blocked: explicit --td-receipt is required")
|
|
|
|
|
+ receipt = json.loads(receipt_path.read_text(encoding="utf-8"))
|
|
|
|
|
+ profile = HARDWARE_PROFILES[profile_name]
|
|
|
|
|
+ project_path = ROOT / str(profile["project"])
|
|
|
|
|
+ closure_path = ROOT / str(profile["closure"])
|
|
|
|
|
+ expected = {
|
|
|
|
|
+ "schema": "prod2u-6400-td-receipt-v1",
|
|
|
|
|
+ "status": "PASS",
|
|
|
|
|
+ "profile": profile_name,
|
|
|
|
|
+ "project": str(profile["project"]),
|
|
|
|
|
+ "source_closure": str(profile["closure"]),
|
|
|
|
|
+ "commit": commit,
|
|
|
|
|
+ "production": bool(profile["production"]),
|
|
|
|
|
+ "stimulus": bool(profile["stimulus"]),
|
|
|
|
|
+ "simulation_only": False,
|
|
|
|
|
+ "artifact_basename": str(profile["artifact_basename"]),
|
|
|
|
|
+ "timing_pass_25mhz": True,
|
|
|
|
|
+ "project_sha256": _sha256(project_path),
|
|
|
|
|
+ "source_closure_sha256": _sha256(closure_path),
|
|
|
|
|
+ }
|
|
|
|
|
+ mismatches = [
|
|
|
|
|
+ f"{key}: expected {value!r}, got {receipt.get(key)!r}"
|
|
|
|
|
+ for key, value in expected.items()
|
|
|
|
|
+ if receipt.get(key) != value
|
|
|
|
|
+ ]
|
|
|
|
|
+ if mismatches:
|
|
|
|
|
+ raise SystemExit("6400 firmware package blocked: TD receipt mismatch: " + "; ".join(mismatches))
|
|
|
|
|
+ bitstream_value = receipt.get("bitstream")
|
|
|
|
|
+ if not isinstance(bitstream_value, str) or not bitstream_value:
|
|
|
|
|
+ raise SystemExit("6400 firmware package blocked: TD receipt has no bitstream")
|
|
|
|
|
+ bitstream = Path(bitstream_value)
|
|
|
|
|
+ if not bitstream.is_absolute():
|
|
|
|
|
+ bitstream = receipt_path.parent / bitstream
|
|
|
|
|
+ expected_name = f"{profile['artifact_basename']}.bit"
|
|
|
|
|
+ if bitstream.name != expected_name or not bitstream.is_file() or bitstream.stat().st_size == 0:
|
|
|
|
|
+ raise SystemExit("6400 firmware package blocked: receipt bitstream is missing or misnamed")
|
|
|
|
|
+ if receipt.get("bitstream_sha256") != _sha256(bitstream):
|
|
|
|
|
+ raise SystemExit("6400 firmware package blocked: receipt bitstream SHA-256 mismatch")
|
|
|
|
|
+ return bitstream.resolve(), receipt
|
|
|
|
|
|
|
|
|
|
|
|
|
def build_target_package(
|
|
def build_target_package(
|
|
@@ -63,35 +122,79 @@ def build_target_package(
|
|
|
kind: str,
|
|
kind: str,
|
|
|
output_dir: Path,
|
|
output_dir: Path,
|
|
|
include_reference: bool = False,
|
|
include_reference: bool = False,
|
|
|
|
|
+ *,
|
|
|
|
|
+ profile_name: str | None = None,
|
|
|
|
|
+ td_receipt: Path | None = None,
|
|
|
) -> Path:
|
|
) -> Path:
|
|
|
- target = resolve_target(target_name)
|
|
|
|
|
- generate_named_target(target.alias)
|
|
|
|
|
- project = json.loads(target.project_config.read_text(encoding="utf-8"))
|
|
|
|
|
- blocked, pins = release_blocked(target, project)
|
|
|
|
|
|
|
+ is_6400 = target_name == "6400" or target_name.startswith("6400-")
|
|
|
|
|
+ receipt_payload: dict[str, object] | None = None
|
|
|
|
|
+ expanded_closure: dict[str, object] | None = None
|
|
|
|
|
+ if is_6400:
|
|
|
|
|
+ selected_profile = _resolve_6400_profile(target_name, profile_name)
|
|
|
|
|
+ profile = HARDWARE_PROFILES[selected_profile]
|
|
|
|
|
+ _check_active_6400_generated()
|
|
|
|
|
+ project_path = ROOT / str(profile["project"])
|
|
|
|
|
+ closure_path = ROOT / str(profile["closure"])
|
|
|
|
|
+ generated_dir = ROOT / "generated/6400"
|
|
|
|
|
+ project = json.loads(project_path.read_text(encoding="utf-8"))
|
|
|
|
|
+ sources, _closure_inputs = td_source_closure(selected_profile)
|
|
|
|
|
+ top_module = str(project["top"])
|
|
|
|
|
+ project_id = selected_profile
|
|
|
|
|
+ target_alias = "6400"
|
|
|
|
|
+ package_label = selected_profile
|
|
|
|
|
+ blocked, pins = False, ()
|
|
|
|
|
+ expanded_closure = {
|
|
|
|
|
+ "schema": "prod2u-source-closure-expanded-v1",
|
|
|
|
|
+ "project_id": selected_profile,
|
|
|
|
|
+ "top_module": top_module,
|
|
|
|
|
+ "sources": sources,
|
|
|
|
|
+ }
|
|
|
|
|
+ else:
|
|
|
|
|
+ target = resolve_target(target_name)
|
|
|
|
|
+ generate_named_target(target.alias)
|
|
|
|
|
+ project_path = target.project_config
|
|
|
|
|
+ closure_path = target.source_closure
|
|
|
|
|
+ generated_dir = target.generated_dir
|
|
|
|
|
+ project = json.loads(project_path.read_text(encoding="utf-8"))
|
|
|
|
|
+ blocked, pins = release_blocked(target, project)
|
|
|
|
|
+ sources = list(load_source_closure(target))
|
|
|
|
|
+ top_module = target.top_module
|
|
|
|
|
+ project_id = target.project_id
|
|
|
|
|
+ target_alias = target.alias
|
|
|
|
|
+ package_label = target.alias
|
|
|
|
|
+ selected_profile = target.profile
|
|
|
if kind == "firmware" and blocked:
|
|
if kind == "firmware" and blocked:
|
|
|
raise SystemExit(
|
|
raise SystemExit(
|
|
|
"release_blocked\n" + "\n".join(f"{name} pin unresolved" for name in pins)
|
|
"release_blocked\n" + "\n".join(f"{name} pin unresolved" for name in pins)
|
|
|
)
|
|
)
|
|
|
- bitstream_path = _6400_bitstream() if kind == "firmware" and target.alias == "6400" else None
|
|
|
|
|
- td_evidence = ROOT / "dist" / "6400-td" if target.alias == "6400" and kind == "firmware" else None
|
|
|
|
|
commit = _git(ROOT, "rev-parse", "HEAD")
|
|
commit = _git(ROOT, "rev-parse", "HEAD")
|
|
|
|
|
+ bitstream_path: Path | None = None
|
|
|
|
|
+ if kind == "firmware" and is_6400:
|
|
|
|
|
+ if not re.fullmatch(r"[0-9a-f]{40}", commit):
|
|
|
|
|
+ raise SystemExit("6400 firmware package blocked: exact Git commit is unavailable")
|
|
|
|
|
+ bitstream_path, receipt_payload = _validated_td_bitstream(
|
|
|
|
|
+ selected_profile, td_receipt, commit
|
|
|
|
|
+ )
|
|
|
run_id = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
|
|
run_id = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
|
|
|
- name = f"prod2u-{target.alias}-{kind}-{commit[:12]}-{run_id}"
|
|
|
|
|
|
|
+ name = f"prod2u-{package_label}-{kind}-{commit[:12]}-{run_id}"
|
|
|
output_dir.mkdir(parents=True, exist_ok=True)
|
|
output_dir.mkdir(parents=True, exist_ok=True)
|
|
|
zip_path = output_dir / f"{name}.zip"
|
|
zip_path = output_dir / f"{name}.zip"
|
|
|
- sources = load_source_closure(target)
|
|
|
|
|
manifest = {
|
|
manifest = {
|
|
|
"schema": "prod2u-target-package-v1",
|
|
"schema": "prod2u-target-package-v1",
|
|
|
- "target_alias": target.alias,
|
|
|
|
|
- "project_id": target.project_id,
|
|
|
|
|
- "top": target.top_module,
|
|
|
|
|
|
|
+ "target_alias": target_alias,
|
|
|
|
|
+ "profile": selected_profile,
|
|
|
|
|
+ "firmware_role": (
|
|
|
|
|
+ "production"
|
|
|
|
|
+ if selected_profile == "6400-control"
|
|
|
|
|
+ else "identification" if selected_profile == "6400-identification" else "legacy"
|
|
|
|
|
+ ),
|
|
|
|
|
+ "project_id": project_id,
|
|
|
|
|
+ "top": top_module,
|
|
|
"kind": kind,
|
|
"kind": kind,
|
|
|
"commit": commit,
|
|
"commit": commit,
|
|
|
"run_id": run_id,
|
|
"run_id": run_id,
|
|
|
- "project_config_sha256": hashlib.sha256(target.project_config.read_bytes()).hexdigest(),
|
|
|
|
|
- "source_manifest_sha256": hashlib.sha256(target.generated_dir.joinpath("td-source-manifest.json").read_bytes()).hexdigest()
|
|
|
|
|
- if (target.generated_dir / "td-source-manifest.json").is_file()
|
|
|
|
|
- else None,
|
|
|
|
|
|
|
+ "project_config_sha256": _sha256(project_path),
|
|
|
|
|
+ "source_manifest_sha256": _sha256(closure_path),
|
|
|
"bitstream_sha256": _sha256(bitstream_path) if bitstream_path else None,
|
|
"bitstream_sha256": _sha256(bitstream_path) if bitstream_path else None,
|
|
|
"hardware_validation": "NOT RUN",
|
|
"hardware_validation": "NOT RUN",
|
|
|
"release_blocked": blocked,
|
|
"release_blocked": blocked,
|
|
@@ -101,11 +204,16 @@ def build_target_package(
|
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
|
stage = Path(tmp)
|
|
stage = Path(tmp)
|
|
|
(stage / "manifest.json").write_text(json.dumps(manifest, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
|
(stage / "manifest.json").write_text(json.dumps(manifest, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
|
|
- shutil.copy2(target.project_config, stage / "project.json")
|
|
|
|
|
- shutil.copy2(target.source_closure, stage / "source-closure.json")
|
|
|
|
|
- gen_dir = stage / "generated"
|
|
|
|
|
- if target.generated_dir.is_dir():
|
|
|
|
|
- shutil.copytree(target.generated_dir, gen_dir)
|
|
|
|
|
|
|
+ shutil.copy2(project_path, stage / "project.json")
|
|
|
|
|
+ shutil.copy2(closure_path, stage / "source-closure.json")
|
|
|
|
|
+ if expanded_closure is not None:
|
|
|
|
|
+ (stage / "source-closure-expanded.json").write_text(
|
|
|
|
|
+ json.dumps(expanded_closure, indent=2, sort_keys=True) + "\n",
|
|
|
|
|
+ encoding="utf-8",
|
|
|
|
|
+ )
|
|
|
|
|
+ gen_dir = stage / ("generated/6400" if is_6400 else "generated")
|
|
|
|
|
+ if generated_dir.is_dir():
|
|
|
|
|
+ shutil.copytree(generated_dir, gen_dir)
|
|
|
src_dir = stage / "src"
|
|
src_dir = stage / "src"
|
|
|
src_dir.mkdir()
|
|
src_dir.mkdir()
|
|
|
for rel in sources:
|
|
for rel in sources:
|
|
@@ -113,48 +221,36 @@ def build_target_package(
|
|
|
dest.parent.mkdir(parents=True, exist_ok=True)
|
|
dest.parent.mkdir(parents=True, exist_ok=True)
|
|
|
shutil.copy2(ROOT / rel, dest)
|
|
shutil.copy2(ROOT / rel, dest)
|
|
|
if bitstream_path is not None:
|
|
if bitstream_path is not None:
|
|
|
- shutil.copy2(bitstream_path, stage / "prod2u_6400_front_back.bit")
|
|
|
|
|
|
|
+ bitstream_name = bitstream_path.name
|
|
|
|
|
+ shutil.copy2(bitstream_path, stage / bitstream_name)
|
|
|
(stage / "BITSTREAM-SHA256.txt").write_text(
|
|
(stage / "BITSTREAM-SHA256.txt").write_text(
|
|
|
- f"{_sha256(bitstream_path)} prod2u_6400_front_back.bit\n",
|
|
|
|
|
|
|
+ f"{_sha256(bitstream_path)} {bitstream_name}\n",
|
|
|
encoding="ascii",
|
|
encoding="ascii",
|
|
|
)
|
|
)
|
|
|
|
|
+ role = "生产" if selected_profile == "6400-control" else "Identification 专用"
|
|
|
(stage / "FLASH-INSTRUCTIONS.zh-CN.txt").write_text(
|
|
(stage / "FLASH-INSTRUCTIONS.zh-CN.txt").write_text(
|
|
|
- "6400 生产固件刷写说明\n"
|
|
|
|
|
|
|
+ f"6400 {role}固件说明\n"
|
|
|
"========================\n"
|
|
"========================\n"
|
|
|
"目标器件:EF2L45BG256B(6400 前后独立温控)\n"
|
|
"目标器件:EF2L45BG256B(6400 前后独立温控)\n"
|
|
|
- "固件文件:prod2u_6400_front_back.bit\n"
|
|
|
|
|
|
|
+ f"固件文件:{bitstream_name}\n"
|
|
|
"\n"
|
|
"\n"
|
|
|
"1. 关闭目标板电源,连接板卡厂商支持的 JTAG 下载器。\n"
|
|
"1. 关闭目标板电源,连接板卡厂商支持的 JTAG 下载器。\n"
|
|
|
"2. 在 Anlogic TD 2026.1 SP2 中选择 EF2L45BG256B,打开该 .bit 文件。\n"
|
|
"2. 在 Anlogic TD 2026.1 SP2 中选择 EF2L45BG256B,打开该 .bit 文件。\n"
|
|
|
"3. 先执行 Erase/Program,再执行 Verify;确认校验通过后断电重启。\n"
|
|
"3. 先执行 Erase/Program,再执行 Verify;确认校验通过后断电重启。\n"
|
|
|
- "4. 串口使用 115200 8N1,无硬件流控;上位机选择 6400 HEX GUI。\n"
|
|
|
|
|
|
|
+ f"4. Host 串口使用 921600 8N1;每条合法命令先独立 ACK;上位机选择 {selected_profile}。\n"
|
|
|
"5. 本包只包含 6400 固件,不能用于 MRDIMM 门控板。\n"
|
|
"5. 本包只包含 6400 固件,不能用于 MRDIMM 门控板。\n"
|
|
|
- "\n"
|
|
|
|
|
|
|
+ + (
|
|
|
|
|
+ "6. 本固件含 SET_STIMULUS,仅限 Identification,不得作为 Production。\n"
|
|
|
|
|
+ if selected_profile == "6400-identification"
|
|
|
|
|
+ else "6. Production 固件不包含 SET_STIMULUS。\n"
|
|
|
|
|
+ )
|
|
|
|
|
+ + "\n"
|
|
|
"注意:本次交付未执行真实 JTAG/硬件烧录,硬件验证状态为 NOT RUN。\n",
|
|
"注意:本次交付未执行真实 JTAG/硬件烧录,硬件验证状态为 NOT RUN。\n",
|
|
|
encoding="utf-8",
|
|
encoding="utf-8",
|
|
|
)
|
|
)
|
|
|
- if td_evidence is not None and td_evidence.is_dir():
|
|
|
|
|
- shutil.copytree(td_evidence, stage / "td-evidence", dirs_exist_ok=True)
|
|
|
|
|
|
|
+ assert receipt_payload is not None
|
|
|
(stage / "TD-BUILD-RECEIPT.json").write_text(
|
|
(stage / "TD-BUILD-RECEIPT.json").write_text(
|
|
|
- json.dumps(
|
|
|
|
|
- {
|
|
|
|
|
- "schema": "prod2u-6400-td-build-receipt-v1",
|
|
|
|
|
- "target_alias": "6400",
|
|
|
|
|
- "project_id": target.project_id,
|
|
|
|
|
- "top_module": target.top_module,
|
|
|
|
|
- "td_version": "TD Release_2026.1_SP2 build 6.2.2.200067",
|
|
|
|
|
- "source_commit": commit,
|
|
|
|
|
- "project_config_sha256": manifest["project_config_sha256"],
|
|
|
|
|
- "source_manifest_sha256": manifest["source_manifest_sha256"],
|
|
|
|
|
- "bitstream": "prod2u_6400_front_back.bit",
|
|
|
|
|
- "bitstream_sha256": manifest["bitstream_sha256"],
|
|
|
|
|
- "stages": ["syn", "phy", "bitgen"],
|
|
|
|
|
- "hardware_validation": "NOT RUN",
|
|
|
|
|
- },
|
|
|
|
|
- indent=2,
|
|
|
|
|
- sort_keys=True,
|
|
|
|
|
- )
|
|
|
|
|
- + "\n",
|
|
|
|
|
|
|
+ json.dumps(receipt_payload, indent=2, sort_keys=True) + "\n",
|
|
|
encoding="utf-8",
|
|
encoding="utf-8",
|
|
|
)
|
|
)
|
|
|
if include_reference:
|
|
if include_reference:
|
|
@@ -191,20 +287,62 @@ def _selftest(zip_path: Path) -> None:
|
|
|
observed = _sha256(dest / name)
|
|
observed = _sha256(dest / name)
|
|
|
if observed != digest:
|
|
if observed != digest:
|
|
|
raise SystemExit(f"hash mismatch {name}")
|
|
raise SystemExit(f"hash mismatch {name}")
|
|
|
|
|
+ if manifest.get("target_alias") == "6400":
|
|
|
|
|
+ profile_name = manifest.get("profile")
|
|
|
|
|
+ if profile_name not in HARDWARE_PROFILES:
|
|
|
|
|
+ raise SystemExit("package selftest: invalid 6400 hardware profile")
|
|
|
|
|
+ members = [path.relative_to(dest).as_posix() for path in dest.rglob("*")]
|
|
|
|
|
+ if any(name.startswith("src/generated/6400/") for name in members):
|
|
|
|
|
+ raise SystemExit("package selftest: historical src/generated/6400 leaked")
|
|
|
|
|
+ closure = json.loads(
|
|
|
|
|
+ (dest / "source-closure-expanded.json").read_text(encoding="utf-8")
|
|
|
|
|
+ )
|
|
|
|
|
+ closure_text = "\n".join(closure["sources"])
|
|
|
|
|
+ if "src/generated/6400" in closure_text or "prod2u_6400_front_back_top" in closure_text:
|
|
|
|
|
+ raise SystemExit("package selftest: historical 6400 closure leaked")
|
|
|
if manifest.get("target_alias") == "6400" and manifest.get("kind") == "firmware":
|
|
if manifest.get("target_alias") == "6400" and manifest.get("kind") == "firmware":
|
|
|
- bit = dest / "prod2u_6400_front_back.bit"
|
|
|
|
|
|
|
+ expected_name = (
|
|
|
|
|
+ "prod2u_6400_front_back.bit"
|
|
|
|
|
+ if manifest["profile"] == "6400-control"
|
|
|
|
|
+ else "prod2u_6400_identification.bit"
|
|
|
|
|
+ )
|
|
|
|
|
+ bit = dest / expected_name
|
|
|
if not bit.is_file() or _sha256(bit) != manifest.get("bitstream_sha256"):
|
|
if not bit.is_file() or _sha256(bit) != manifest.get("bitstream_sha256"):
|
|
|
raise SystemExit("package selftest: 6400 bitstream identity mismatch")
|
|
raise SystemExit("package selftest: 6400 bitstream identity mismatch")
|
|
|
|
|
+ receipt = json.loads(
|
|
|
|
|
+ (dest / "TD-BUILD-RECEIPT.json").read_text(encoding="utf-8")
|
|
|
|
|
+ )
|
|
|
|
|
+ if receipt.get("profile") != manifest["profile"] or receipt.get(
|
|
|
|
|
+ "bitstream_sha256"
|
|
|
|
|
+ ) != manifest["bitstream_sha256"]:
|
|
|
|
|
+ raise SystemExit("package selftest: TD receipt/profile identity mismatch")
|
|
|
|
|
+ instructions = (dest / "FLASH-INSTRUCTIONS.zh-CN.txt").read_text(
|
|
|
|
|
+ encoding="utf-8"
|
|
|
|
|
+ )
|
|
|
|
|
+ if "921600 8N1" not in instructions or "独立 ACK" not in instructions:
|
|
|
|
|
+ raise SystemExit("package selftest: Host UART/ACK contract missing")
|
|
|
|
|
|
|
|
|
|
|
|
|
def main(argv: list[str] | None = None) -> int:
|
|
def main(argv: list[str] | None = None) -> int:
|
|
|
parser = argparse.ArgumentParser()
|
|
parser = argparse.ArgumentParser()
|
|
|
parser.add_argument("--target", required=True)
|
|
parser.add_argument("--target", required=True)
|
|
|
parser.add_argument("--kind", choices=("source", "review", "firmware"), default="source")
|
|
parser.add_argument("--kind", choices=("source", "review", "firmware"), default="source")
|
|
|
|
|
+ parser.add_argument(
|
|
|
|
|
+ "--profile",
|
|
|
|
|
+ choices=("6400-control", "6400-identification", "6400-sim-debug"),
|
|
|
|
|
+ )
|
|
|
|
|
+ parser.add_argument("--td-receipt", type=Path)
|
|
|
parser.add_argument("--output-dir", type=Path, default=ROOT / "dist")
|
|
parser.add_argument("--output-dir", type=Path, default=ROOT / "dist")
|
|
|
parser.add_argument("--include-reference", action="store_true")
|
|
parser.add_argument("--include-reference", action="store_true")
|
|
|
args = parser.parse_args(argv)
|
|
args = parser.parse_args(argv)
|
|
|
- path = build_target_package(args.target, args.kind, args.output_dir, args.include_reference)
|
|
|
|
|
|
|
+ path = build_target_package(
|
|
|
|
|
+ args.target,
|
|
|
|
|
+ args.kind,
|
|
|
|
|
+ args.output_dir,
|
|
|
|
|
+ args.include_reference,
|
|
|
|
|
+ profile_name=args.profile,
|
|
|
|
|
+ td_receipt=args.td_receipt,
|
|
|
|
|
+ )
|
|
|
print(json.dumps({"status": "pass", "package": str(path), "sha256": _sha256(path)}, indent=2))
|
|
print(json.dumps({"status": "pass", "package": str(path), "sha256": _sha256(path)}, indent=2))
|
|
|
return 0
|
|
return 0
|
|
|
|
|
|