|
@@ -26,6 +26,10 @@ from tools.run_6400_td import HARDWARE_PROFILES, source_closure as td_source_clo
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+CANDIDATE_NOTICE_ZH_CN = "候选,仅供审核;未冻结TTL Pin/未做硬件验证前不要烧录"
|
|
|
|
|
+DO_NOT_PROGRAM_LINE = "DO NOT PROGRAM / 不要烧录"
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
def _sha256(path: Path) -> str:
|
|
def _sha256(path: Path) -> str:
|
|
|
digest = hashlib.sha256()
|
|
digest = hashlib.sha256()
|
|
|
with path.open("rb") as handle:
|
|
with path.open("rb") as handle:
|
|
@@ -103,6 +107,23 @@ def _validated_td_bitstream(
|
|
|
]
|
|
]
|
|
|
if mismatches:
|
|
if mismatches:
|
|
|
raise SystemExit("6400 firmware package blocked: TD receipt mismatch: " + "; ".join(mismatches))
|
|
raise SystemExit("6400 firmware package blocked: TD receipt mismatch: " + "; ".join(mismatches))
|
|
|
|
|
+ known_unbound_ports = receipt.get("known_unbound_ports")
|
|
|
|
|
+ if (
|
|
|
|
|
+ not isinstance(known_unbound_ports, list)
|
|
|
|
|
+ or any(
|
|
|
|
|
+ not isinstance(port, str) or not port
|
|
|
|
|
+ for port in known_unbound_ports
|
|
|
|
|
+ )
|
|
|
|
|
+ or len(set(known_unbound_ports)) != len(known_unbound_ports)
|
|
|
|
|
+ ):
|
|
|
|
|
+ raise SystemExit(
|
|
|
|
|
+ "6400 firmware package blocked: TD receipt has invalid known_unbound_ports"
|
|
|
|
|
+ )
|
|
|
|
|
+ deployment_status = receipt.get("deployment_status")
|
|
|
|
|
+ if not isinstance(deployment_status, str) or not deployment_status:
|
|
|
|
|
+ raise SystemExit(
|
|
|
|
|
+ "6400 firmware package blocked: TD receipt has invalid deployment_status"
|
|
|
|
|
+ )
|
|
|
bitstream_value = receipt.get("bitstream")
|
|
bitstream_value = receipt.get("bitstream")
|
|
|
if not isinstance(bitstream_value, str) or not bitstream_value:
|
|
if not isinstance(bitstream_value, str) or not bitstream_value:
|
|
|
raise SystemExit("6400 firmware package blocked: TD receipt has no bitstream")
|
|
raise SystemExit("6400 firmware package blocked: TD receipt has no bitstream")
|
|
@@ -129,6 +150,9 @@ def build_target_package(
|
|
|
is_6400 = target_name == "6400" or target_name.startswith("6400-")
|
|
is_6400 = target_name == "6400" or target_name.startswith("6400-")
|
|
|
receipt_payload: dict[str, object] | None = None
|
|
receipt_payload: dict[str, object] | None = None
|
|
|
expanded_closure: dict[str, object] | None = None
|
|
expanded_closure: dict[str, object] | None = None
|
|
|
|
|
+ hardware_validation = "NOT RUN"
|
|
|
|
|
+ known_unbound_ports: tuple[str, ...] = ()
|
|
|
|
|
+ deployment_status: str | None = None
|
|
|
if is_6400:
|
|
if is_6400:
|
|
|
selected_profile = _resolve_6400_profile(target_name, profile_name)
|
|
selected_profile = _resolve_6400_profile(target_name, profile_name)
|
|
|
profile = HARDWARE_PROFILES[selected_profile]
|
|
profile = HARDWARE_PROFILES[selected_profile]
|
|
@@ -175,6 +199,15 @@ def build_target_package(
|
|
|
bitstream_path, receipt_payload = _validated_td_bitstream(
|
|
bitstream_path, receipt_payload = _validated_td_bitstream(
|
|
|
selected_profile, td_receipt, commit
|
|
selected_profile, td_receipt, commit
|
|
|
)
|
|
)
|
|
|
|
|
+ ports_value = receipt_payload["known_unbound_ports"]
|
|
|
|
|
+ status_value = receipt_payload["deployment_status"]
|
|
|
|
|
+ assert isinstance(ports_value, list)
|
|
|
|
|
+ assert all(isinstance(port, str) for port in ports_value)
|
|
|
|
|
+ assert isinstance(status_value, str)
|
|
|
|
|
+ known_unbound_ports = tuple(ports_value)
|
|
|
|
|
+ deployment_status = status_value
|
|
|
|
|
+ blocked = bool(known_unbound_ports) or hardware_validation != "PASS"
|
|
|
|
|
+ pins = known_unbound_ports
|
|
|
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-{package_label}-{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)
|
|
@@ -196,14 +229,42 @@ def build_target_package(
|
|
|
"project_config_sha256": _sha256(project_path),
|
|
"project_config_sha256": _sha256(project_path),
|
|
|
"source_manifest_sha256": _sha256(closure_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": hardware_validation,
|
|
|
"release_blocked": blocked,
|
|
"release_blocked": blocked,
|
|
|
"unresolved_pins": list(pins),
|
|
"unresolved_pins": list(pins),
|
|
|
"include_reference": include_reference,
|
|
"include_reference": include_reference,
|
|
|
}
|
|
}
|
|
|
|
|
+ if is_6400:
|
|
|
|
|
+ manifest.update(
|
|
|
|
|
+ {
|
|
|
|
|
+ "production": bool(profile["production"]),
|
|
|
|
|
+ "stimulus": bool(profile["stimulus"]),
|
|
|
|
|
+ "simulation_only": False,
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ if is_6400 and kind == "firmware":
|
|
|
|
|
+ manifest.update(
|
|
|
|
|
+ {
|
|
|
|
|
+ "candidate_notice_zh_CN": CANDIDATE_NOTICE_ZH_CN,
|
|
|
|
|
+ "candidate_only": blocked,
|
|
|
|
|
+ "deployable": not blocked,
|
|
|
|
|
+ "deployment_status": deployment_status,
|
|
|
|
|
+ "known_unbound_ports": list(known_unbound_ports),
|
|
|
|
|
+ "unresolved_ports": list(known_unbound_ports),
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
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")
|
|
|
|
|
+ if is_6400 and kind == "firmware" and blocked:
|
|
|
|
|
+ (stage / "CANDIDATE-NOTICE.zh-CN.txt").write_text(
|
|
|
|
|
+ DO_NOT_PROGRAM_LINE + "\n"
|
|
|
|
|
+ + CANDIDATE_NOTICE_ZH_CN + "\n"
|
|
|
|
|
+ + f"未冻结端口:{', '.join(known_unbound_ports)}\n"
|
|
|
|
|
+ + f"部署状态:{deployment_status}\n"
|
|
|
|
|
+ + f"硬件验证:{hardware_validation}\n",
|
|
|
|
|
+ encoding="utf-8",
|
|
|
|
|
+ )
|
|
|
shutil.copy2(project_path, stage / "project.json")
|
|
shutil.copy2(project_path, stage / "project.json")
|
|
|
shutil.copy2(closure_path, stage / "source-closure.json")
|
|
shutil.copy2(closure_path, stage / "source-closure.json")
|
|
|
if expanded_closure is not None:
|
|
if expanded_closure is not None:
|
|
@@ -229,20 +290,19 @@ def build_target_package(
|
|
|
)
|
|
)
|
|
|
role = "生产" if selected_profile == "6400-control" else "Identification 专用"
|
|
role = "生产" if selected_profile == "6400-control" else "Identification 专用"
|
|
|
(stage / "FLASH-INSTRUCTIONS.zh-CN.txt").write_text(
|
|
(stage / "FLASH-INSTRUCTIONS.zh-CN.txt").write_text(
|
|
|
- f"6400 {role}固件说明\n"
|
|
|
|
|
|
|
+ DO_NOT_PROGRAM_LINE + "\n"
|
|
|
|
|
+ + CANDIDATE_NOTICE_ZH_CN + "\n\n"
|
|
|
|
|
+ + f"6400 {role}固件审核说明\n"
|
|
|
"========================\n"
|
|
"========================\n"
|
|
|
"目标器件:EF2L45BG256B(6400 前后独立温控)\n"
|
|
"目标器件:EF2L45BG256B(6400 前后独立温控)\n"
|
|
|
f"固件文件:{bitstream_name}\n"
|
|
f"固件文件:{bitstream_name}\n"
|
|
|
- "\n"
|
|
|
|
|
- "1. 关闭目标板电源,连接板卡厂商支持的 JTAG 下载器。\n"
|
|
|
|
|
- "2. 在 Anlogic TD 2026.1 SP2 中选择 EF2L45BG256B,打开该 .bit 文件。\n"
|
|
|
|
|
- "3. 先执行 Erase/Program,再执行 Verify;确认校验通过后断电重启。\n"
|
|
|
|
|
- f"4. Host 串口使用 921600 8N1;每条合法命令先独立 ACK;上位机选择 {selected_profile}。\n"
|
|
|
|
|
- "5. 本包只包含 6400 固件,不能用于 MRDIMM 门控板。\n"
|
|
|
|
|
|
|
+ "请审核 BITSTREAM-SHA256.txt 与 TD-BUILD-RECEIPT.json 后再冻结制品。\n"
|
|
|
|
|
+ f"Host 串口使用 921600 8N1;每条合法命令先独立 ACK;Profile={selected_profile}。\n"
|
|
|
|
|
+ "本包只包含 6400 固件,不能用于 MRDIMM 门控板。\n"
|
|
|
+ (
|
|
+ (
|
|
|
- "6. 本固件含 SET_STIMULUS,仅限 Identification,不得作为 Production。\n"
|
|
|
|
|
|
|
+ "本固件含 SET_STIMULUS,仅限 Identification,不得作为 Production。\n"
|
|
|
if selected_profile == "6400-identification"
|
|
if selected_profile == "6400-identification"
|
|
|
- else "6. Production 固件不包含 SET_STIMULUS。\n"
|
|
|
|
|
|
|
+ else "Production 固件不包含 SET_STIMULUS(stimulus=false)。\n"
|
|
|
)
|
|
)
|
|
|
+ "\n"
|
|
+ "\n"
|
|
|
"注意:本次交付未执行真实 JTAG/硬件烧录,硬件验证状态为 NOT RUN。\n",
|
|
"注意:本次交付未执行真实 JTAG/硬件烧录,硬件验证状态为 NOT RUN。\n",
|
|
@@ -316,10 +376,32 @@ def _selftest(zip_path: Path) -> None:
|
|
|
"bitstream_sha256"
|
|
"bitstream_sha256"
|
|
|
) != manifest["bitstream_sha256"]:
|
|
) != manifest["bitstream_sha256"]:
|
|
|
raise SystemExit("package selftest: TD receipt/profile identity mismatch")
|
|
raise SystemExit("package selftest: TD receipt/profile identity mismatch")
|
|
|
|
|
+ receipt_ports = receipt.get("known_unbound_ports")
|
|
|
|
|
+ if (
|
|
|
|
|
+ manifest.get("release_blocked") is not True
|
|
|
|
|
+ or manifest.get("deployable") is not False
|
|
|
|
|
+ or manifest.get("candidate_only") is not True
|
|
|
|
|
+ or manifest.get("known_unbound_ports") != receipt_ports
|
|
|
|
|
+ or manifest.get("unresolved_ports") != receipt_ports
|
|
|
|
|
+ or manifest.get("unresolved_pins") != receipt_ports
|
|
|
|
|
+ or manifest.get("deployment_status") != receipt.get("deployment_status")
|
|
|
|
|
+ ):
|
|
|
|
|
+ raise SystemExit("package selftest: unsafe deployment gate mismatch")
|
|
|
|
|
+ if not (dest / "CANDIDATE-NOTICE.zh-CN.txt").is_file():
|
|
|
|
|
+ raise SystemExit("package selftest: candidate notice missing")
|
|
|
|
|
+ production = manifest["profile"] == "6400-control"
|
|
|
|
|
+ if manifest.get("production") is not production or manifest.get(
|
|
|
|
|
+ "stimulus"
|
|
|
|
|
+ ) is production:
|
|
|
|
|
+ raise SystemExit("package selftest: firmware profile semantics mismatch")
|
|
|
instructions = (dest / "FLASH-INSTRUCTIONS.zh-CN.txt").read_text(
|
|
instructions = (dest / "FLASH-INSTRUCTIONS.zh-CN.txt").read_text(
|
|
|
encoding="utf-8"
|
|
encoding="utf-8"
|
|
|
)
|
|
)
|
|
|
- if "921600 8N1" not in instructions or "独立 ACK" not in instructions:
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+ not instructions.startswith(DO_NOT_PROGRAM_LINE)
|
|
|
|
|
+ or "921600 8N1" not in instructions
|
|
|
|
|
+ or "独立 ACK" not in instructions
|
|
|
|
|
+ ):
|
|
|
raise SystemExit("package selftest: Host UART/ACK contract missing")
|
|
raise SystemExit("package selftest: Host UART/ACK contract missing")
|
|
|
|
|
|
|
|
|
|
|