| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561 |
- param(
- [string]$OutputDir = ".\j6-binary921-deliverables",
- [string]$PackageName = "",
- [Parameter(Mandatory = $true)]
- [ValidateSet("debug-photo-bmc-replay-binary921", "formal-uart1-bmc-replay-binary921", "production-two-uart-bmc-replay-binary921")]
- [string]$Profile,
- [Parameter(Mandatory = $true)]
- [string]$Bitstream,
- [Parameter(Mandatory = $true)]
- [string]$TdReceipt,
- [string]$BmcReplayPayload = "",
- [switch]$ForceOverwrite
- )
- $ErrorActionPreference = "Stop"
- $ShortBitName = "j6bin.bit"
- $ShortTdName = "td.json"
- function Get-Sha256([string]$Path) {
- if (-not (Test-Path -LiteralPath $Path -PathType Leaf)) {
- throw "File not found: $Path"
- }
- return (Get-FileHash -LiteralPath $Path -Algorithm SHA256).Hash.ToLowerInvariant()
- }
- function Test-Sha256String([object]$Value) {
- if ($null -eq $Value) { return $false }
- return ([string]$Value) -match '^[0-9a-fA-F]{64}$'
- }
- function Get-AsciiSha256([string]$Text) {
- $bytes = [System.Text.Encoding]::ASCII.GetBytes($Text)
- $sha = [System.Security.Cryptography.SHA256]::Create()
- try {
- return (($sha.ComputeHash($bytes) | ForEach-Object { $_.ToString("x2") }) -join "")
- } finally {
- $sha.Dispose()
- }
- }
- function Read-JsonFile([string]$Path, [string]$Label) {
- try {
- return Get-Content -LiteralPath $Path -Raw -Encoding UTF8 | ConvertFrom-Json
- } catch {
- throw "$Label is not valid JSON: $Path"
- }
- }
- function Assert-ProductionTdReceipt([string]$ReceiptPath, [string]$BitstreamPath, [string]$SelectedProfile) {
- $receipt = Read-JsonFile $ReceiptPath "TD receipt"
- $expectedTop = "uart_rs232_j6_host_sensor_real_fan_ptc_production_two_uart_bmc_replay_binary921"
- $expectedModule = "${expectedTop}_top"
- if ($receipt.status -ne "pass") { throw "TD receipt status must be pass for production package" }
- if ($receipt.top -ne $expectedTop) { throw "TD receipt top mismatch for production package" }
- if ($receipt.top_module -ne $expectedModule) { throw "TD receipt top_module mismatch for production package" }
- if ($receipt.pin_profile -ne $SelectedProfile) { throw "TD receipt pin_profile mismatch for production package" }
- if ($receipt.mode -ne "implementation") { throw "TD receipt mode must be implementation for production package" }
- if ($receipt.timing_gate.status -ne "pass") { throw "TD receipt timing_gate.status must be pass for production package" }
- $receiptBitSha = [string]$receipt.bitstream.sha256
- if (-not (Test-Sha256String $receiptBitSha)) { throw "TD receipt bitstream.sha256 missing or invalid for production package" }
- $actualBitSha = Get-Sha256 $BitstreamPath
- if ($receiptBitSha.ToLowerInvariant() -ne $actualBitSha) {
- throw "TD receipt bitstream.sha256 does not match provided bitstream"
- }
- return $receipt
- }
- function Assert-ProductionBmcPayload([string]$PayloadPath) {
- $payload = Read-JsonFile $PayloadPath "BMC replay payload"
- if ($payload.status -ne "pass") { throw "BMC replay payload status must be pass" }
- if ($payload.source -ne "real_bmc_capture") { throw "BMC replay payload source must be real_bmc_capture" }
- if ($payload.bmc_source -ne "pc_replay_from_real_bmc_capture") { throw "BMC replay payload bmc_source mismatch" }
- if ([int]$payload.byte_count -ne 48) { throw "BMC replay payload byte_count must be 48" }
- if ([int]$payload.valid_count -ne 2 -or [int]$payload.missing_count -ne 22) {
- throw "BMC replay payload for this production package must be the historical 2-valid/22-missing sample"
- }
- $replySha = [string]$payload.reply_sha256
- if (-not (Test-Sha256String $replySha)) { throw "BMC replay payload reply_sha256 missing or invalid" }
- $expectedHistoricalSha = "06c173f91f8b6b0e56f9c381b49d5b127d2dbf3a09402843838a0ff2b812f1af"
- if ($replySha.ToLowerInvariant() -ne $expectedHistoricalSha) {
- throw "BMC replay payload reply_sha256 must match the locked historical production sample"
- }
- $replyText = [string]$payload.reply_text
- if ([string]::IsNullOrWhiteSpace($replyText)) { throw "BMC replay payload reply_text missing" }
- $actualReplySha = Get-AsciiSha256 $replyText
- if ($actualReplySha -ne $replySha.ToLowerInvariant()) {
- throw "BMC replay payload reply_sha256 does not match reply_text"
- }
- if (-not (Test-Sha256String $payload.capture_text_sha256)) {
- throw "BMC replay payload capture_text_sha256 missing or invalid"
- }
- return $payload
- }
- function New-InventoryItem([string]$Path, [string]$Root) {
- $full = (Resolve-Path -LiteralPath $Path).Path
- $base = (Resolve-Path -LiteralPath $Root).Path.TrimEnd('\')
- $relative = $full.Substring($base.Length).TrimStart('\').Replace('\', '/')
- return [ordered]@{
- path = $relative
- sha256 = Get-Sha256 $full
- bytes = (Get-Item -LiteralPath $full).Length
- }
- }
- function Copy-IntoPackage([string]$Source, [string]$DestinationDir, [string]$DestinationName = "") {
- if (-not (Test-Path -LiteralPath $Source -PathType Leaf)) {
- throw "File not found: $Source"
- }
- New-Item -ItemType Directory -Force -Path $DestinationDir | Out-Null
- $name = if ([string]::IsNullOrWhiteSpace($DestinationName)) { Split-Path -Leaf $Source } else { $DestinationName }
- $destination = Join-Path $DestinationDir $name
- Copy-Item -LiteralPath $Source -Destination $destination -Force
- return $destination
- }
- function Remove-PythonCache([string]$Root) {
- if (-not (Test-Path -LiteralPath $Root -PathType Container)) { return }
- Get-ChildItem -LiteralPath $Root -Recurse -Force -Directory -Filter "__pycache__" | ForEach-Object {
- Remove-Item -LiteralPath $_.FullName -Recurse -Force
- }
- Get-ChildItem -LiteralPath $Root -Recurse -Force -File |
- Where-Object { $_.Extension -in @(".pyc", ".pyo") } |
- ForEach-Object { Remove-Item -LiteralPath $_.FullName -Force }
- }
- function New-Binary921PinMap([string]$SelectedProfile) {
- $reservedFutureUart = [ordered]@{
- UART1_TX = [ordered]@{ fpga_ball = "L10"; bank_io_net = "BANK2_GPIO52"; used = ($SelectedProfile -in @("formal-uart1-bmc-replay-binary921", "production-two-uart-bmc-replay-binary921")) }
- UART1_RX = [ordered]@{ fpga_ball = "M9"; bank_io_net = "BANK2_GPIO53"; used = ($SelectedProfile -in @("formal-uart1-bmc-replay-binary921", "production-two-uart-bmc-replay-binary921")) }
- UART2_TX = [ordered]@{ fpga_ball = "M10"; bank_io_net = "BANK2_GPIO54"; used = ($SelectedProfile -in @("formal-uart1-bmc-replay-binary921", "production-two-uart-bmc-replay-binary921")) }
- UART2_RX = [ordered]@{ fpga_ball = "N11"; bank_io_net = "BANK2_GPIO55"; used = ($SelectedProfile -in @("formal-uart1-bmc-replay-binary921", "production-two-uart-bmc-replay-binary921")) }
- }
- if ($SelectedProfile -eq "debug-photo-bmc-replay-binary921") {
- return [ordered]@{
- name = $SelectedProfile
- transport = "separate_host_debug_uart"
- bmc_source = "pc_replay_from_real_bmc_capture"
- live_bmc_link_status = "not_used"
- hardware_access_status = "photo_visible_header"
- uart_assignments = [ordered]@{
- bmc_replay_uart_tx = [ordered]@{ fpga_ball = "T4"; role = "pc_replay_bmc_tx" }
- bmc_replay_uart_rx = [ordered]@{ fpga_ball = "R5"; role = "pc_replay_bmc_rx" }
- host_uart_tx = [ordered]@{ fpga_ball = "P7"; role = "binary921_host_tx" }
- host_uart_rx = [ordered]@{ fpga_ball = "P8"; role = "binary921_host_rx" }
- debug_uart_rx = [ordered]@{ fpga_ball = "P10"; role = "binary921_debug_rx" }
- debug_uart_tx = [ordered]@{ fpga_ball = "R10"; role = "binary921_debug_tx" }
- }
- ptc_substitutions = [ordered]@{
- PTC03 = [ordered]@{ original_ball = "T4"; substitute_ball = "P5"; bank_io_net = "BANK2_GPIO40"; reason = "photo_visible_uart_overlap_remap" }
- PTC04 = [ordered]@{ original_ball = "R5"; substitute_ball = "T8"; bank_io_net = "BANK2_GPIO41"; reason = "photo_visible_uart_overlap_remap" }
- PTC17 = [ordered]@{ original_ball = "P8"; substitute_ball = "M14"; bank_io_net = "BANK2_GPIO42"; reason = "photo_visible_uart_overlap_remap" }
- PTC18 = [ordered]@{ original_ball = "P7"; substitute_ball = "M15"; bank_io_net = "BANK2_GPIO43"; reason = "photo_visible_uart_overlap_remap" }
- PTC21 = [ordered]@{ original_ball = "P10"; substitute_ball = "P15"; bank_io_net = "BANK2_GPIO44"; reason = "photo_visible_uart_overlap_remap" }
- PTC22 = [ordered]@{ original_ball = "R10"; substitute_ball = "N14"; bank_io_net = "BANK2_GPIO45"; reason = "photo_visible_uart_overlap_remap" }
- }
- reserved_future_uart = $reservedFutureUart
- }
- }
- if ($SelectedProfile -eq "production-two-uart-bmc-replay-binary921") {
- return [ordered]@{
- name = $SelectedProfile
- transport = "combined_host_debug_uart"
- bmc_source = "pc_replay_from_real_bmc_capture"
- live_bmc_link_status = "not_used"
- hardware_access_status = "production_uart1_uart2_access_confirmed_by_user"
- uart_assignments = [ordered]@{
- bmc_replay_uart_tx = [ordered]@{ fpga_ball = "L10"; role = "pc_replay_bmc_tx"; baud = 115200 }
- bmc_replay_uart_rx = [ordered]@{ fpga_ball = "M9"; role = "pc_replay_bmc_rx"; baud = 115200 }
- combined_debug_host_uart_tx = [ordered]@{ fpga_ball = "M10"; role = "binary921_combined_tx"; baud = 921600 }
- combined_debug_host_uart_rx = [ordered]@{ fpga_ball = "N11"; role = "binary921_combined_rx"; baud = 921600 }
- }
- ptc_substitutions = [ordered]@{}
- reserved_future_uart = $reservedFutureUart
- jtag = [ordered]@{
- connector = "J3 CON/2x5P/2.54"
- pinout = @("1=TCK", "2=GND", "3=TDO", "4=VREF", "5=TMS", "6=NC", "7=NC", "8=NC", "9=TDI", "10=GND")
- speed_hz = 200000
- program_mode = "PROGRAM_SRAM"
- power_cycle_required = $false
- }
- }
- }
- return [ordered]@{
- name = $SelectedProfile
- transport = "separate_host_debug_uart"
- bmc_source = "pc_replay_from_real_bmc_capture"
- live_bmc_link_status = "not_used"
- hardware_access_status = "blocked_waiting_for_uart1_uart2_access"
- uart_assignments = [ordered]@{
- bmc_replay_uart_tx = [ordered]@{ fpga_ball = "L10"; role = "pc_replay_bmc_tx" }
- bmc_replay_uart_rx = [ordered]@{ fpga_ball = "M9"; role = "pc_replay_bmc_rx" }
- host_uart_tx = [ordered]@{ fpga_ball = "M10"; role = "binary921_host_tx" }
- host_uart_rx = [ordered]@{ fpga_ball = "N11"; role = "binary921_host_rx" }
- debug_uart_rx = [ordered]@{ fpga_ball = "M14"; role = "binary921_debug_rx" }
- debug_uart_tx = [ordered]@{ fpga_ball = "M15"; role = "binary921_debug_tx" }
- }
- ptc_substitutions = [ordered]@{}
- reserved_future_uart = $reservedFutureUart
- }
- }
- function New-StartHere([string]$SelectedProfile) {
- $pinMap = New-Binary921PinMap $SelectedProfile
- if ($SelectedProfile -eq "production-two-uart-bmc-replay-binary921") {
- return @"
- # 生产温控板两串口 Binary921 包
- Profile: $SelectedProfile
- ## 现场顺序
- 1. 生产温控板先正常供电;本流程不要求重新上电,也不要求断电重插。
- 2. AL-Link 排线接生产板 `J3 CON/2x5P/2.54`,TD/BitWriter speed 设 `200k`。
- 3. 先启动 BMC replay。
- 4. 再启动 combined collector。
- 5. 看到 collector 等待 binary921 READY 后,手动执行 `PROGRAM_SRAM`,选择包根目录短 bitstream:
- ~~~text
- .\j6bin.bit
- ~~~
- 不要执行 flash/erase/spi flash。这个包只用于 SRAM;如果 BitWriter 识别不到器件,优先检查生产板是否已经外部供电,而不是先反复重启。
- ## JTAG J3 接线
- - 1=TCK
- - 2=GND
- - 3=TDO
- - 4=VREF
- - 5=TMS
- - 6=NC
- - 7=NC
- - 8=NC
- - 9=TDI
- - 10=GND
- `VREF` 不是给板子供电,只是 AL-Link 读取目标板 IO 电平参考。生产板必须另行正常供电;之前识别失败优先检查板子是否有电、排线方向、AL-Link 是否被 TD/BitWriter 独占、speed 是否为 200k。
- ## 两个串口
- - BMC replay UART1: TX=L10, RX=M9, 115200 8N1,接 PC replay,不接 live BMC。
- - Combined Debug+Host UART2: TX=M10, RX=N11, 921600 8N1,同一个 COM 口双向使用。
- ## 启动 BMC replay
- ~~~powershell
- powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\replay-bmc.ps1 -BmcReplayPort COM9 -Payload .\bmc-replay-payload.json -Iterations 3 -TimeoutSeconds 600
- ~~~
- 该 payload 来自历史真实 BMC 样本:2 valid / 22 missing,DIMM1=30.75C,DIMM13=32.25C,reply SHA256 固化在 `manifest.json`。
- ## 启动 collector
- ~~~powershell
- powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\collect-binary921.ps1 -CombinedPort COM7 -Profile $SelectedProfile -OutputDir .\evidence-binary921 -DurationSeconds 180 -Bitstream .\j6bin.bit -TdReceipt .\td.json -BmcReplayReceipt .\bmc-replay-session.json
- ~~~
- collector 只打开显式 `-CombinedPort`,不枚举未知 COM,不安装 Python/pip/driver。Combined 口会写 Host binary command,也会从同一流读取 READY/ACK/debug frames。
- ## 边界
- - protocol=binary921。
- - transport=combined_host_debug_uart。
- - bmc_source=pc_replay_from_real_bmc_capture。
- - live_bmc_link_status=not_used。
- - real_fan_ptc_hardware_status=not_run,直到风扇/PTC 真实负载接线、极性和示波器/证据验证完成。
- - 不声明 flash、真实热性能、真实 PID 闭环或真实 PTC/FAN 负载通过。
- "@
- }
- $substitutionText = if ($SelectedProfile -eq "debug-photo-bmc-replay-binary921") {
- "PTC03/PTC04/PTC17/PTC18/PTC21/PTC22 use substitute spare GPIO in this debug-photo package. It does not claim full real HEAT pinout pass."
- } else {
- "HEAT/PTC/FAN/FG/INSTALL stay on real PDF/inventory pins. UART1/2 access and M14/M15 debug wiring still need board-level access verification."
- }
- return @"
- # J6 BMC-Replay Binary921 Package
- Profile: $SelectedProfile
- ## Order
- 1. Start the BMC replay window first.
- 2. Start the binary921 collector.
- 3. When the collector is waiting for READY, manually run PROGRAM_SRAM and select the root short bitstream:
- ~~~text
- .\j6bin.bit
- ~~~
- Before PROGRAM_SRAM, confirm board power is connected and set BitWriter/TD GUI JTAG speed 200k. A power-cycle is not required for this package; if the JTAG device is not detected, check board power first, then cable/AL-Link and speed.
- collector first, then PROGRAM_SRAM. Do not select a deep `bitstreams\...` path for BitWriter unless you are only auditing hashes.
- ## BMC replay
- Use a second PowerShell window:
- ~~~powershell
- powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\replay-bmc.ps1 -BmcReplayPort COM9 -Payload .\bmc-replay-payload.example.json
- ~~~
- This writes `.\bmc-replay-session.json`. Strict evidence should replace the example payload with a real BMC capture normalized by `tools\bmc_replay_uart.py`. This package does not install Python, pip, drivers, or enumerate unknown COM ports.
- ## Collector
- Use a third PowerShell window:
- ~~~powershell
- powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\collect-binary921.ps1 -HostPort COM8 -DebugPort COM7 -Profile $SelectedProfile -OutputDir .\evidence-binary921 -DurationSeconds 180 -Bitstream .\j6bin.bit -TdReceipt .\td.json -BmcReplayReceipt .\bmc-replay-session.json
- ~~~
- The collector writes binary HostPort commands and reads DebugPort binary921 frames. DebugPort is read-only.
- ## Pins
- - BMC replay UART TX=$($pinMap.uart_assignments.bmc_replay_uart_tx.fpga_ball), RX=$($pinMap.uart_assignments.bmc_replay_uart_rx.fpga_ball), 115200 8N1.
- - HostPort TX=$($pinMap.uart_assignments.host_uart_tx.fpga_ball), RX=$($pinMap.uart_assignments.host_uart_rx.fpga_ball), COM8, 115200 8N1.
- - DebugPort RX=$($pinMap.uart_assignments.debug_uart_rx.fpga_ball), TX=$($pinMap.uart_assignments.debug_uart_tx.fpga_ball), COM7, 921600 8N1.
- - $substitutionText
- ## Boundary
- - protocol=binary921.
- - bmc_source=pc_replay_from_real_bmc_capture.
- - live_bmc_link_status=not_used.
- - real_fan_ptc_hardware_status=not_run until real loads are wired and measured.
- - No flash, no driver install, no unknown COM enumeration, no DebugPort writes, no thermal performance claim, no PID closed-loop pass claim.
- "@
- }
- $repoRoot = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")
- $out = (Resolve-Path -LiteralPath (New-Item -ItemType Directory -Force -Path $OutputDir)).Path
- if ([string]::IsNullOrWhiteSpace($PackageName)) {
- $stamp = Get-Date -Format "yyyyMMdd-HHmmss"
- $PackageName = if ($Profile -eq "debug-photo-bmc-replay-binary921") {
- "j6bin-debug-photo-$stamp"
- } elseif ($Profile -eq "production-two-uart-bmc-replay-binary921") {
- "j6prod-2uart-bmc-replay-$stamp"
- } else {
- "j6bin-formal-uart1-$stamp"
- }
- }
- if ($Profile -eq "production-two-uart-bmc-replay-binary921") {
- Assert-ProductionTdReceipt $TdReceipt $Bitstream $Profile | Out-Null
- if ([string]::IsNullOrWhiteSpace($BmcReplayPayload)) {
- throw "BmcReplayPayload is required for production-two-uart-bmc-replay-binary921"
- }
- Assert-ProductionBmcPayload $BmcReplayPayload | Out-Null
- }
- $stage = Join-Path $out $PackageName
- if (Test-Path -LiteralPath $stage) {
- if (-not $ForceOverwrite) {
- throw "Package staging directory already exists: $stage"
- }
- Remove-Item -LiteralPath $stage -Recurse -Force
- }
- foreach ($dir in @("bitstreams", "td-receipts", "tools", "commands", "config")) {
- New-Item -ItemType Directory -Force -Path (Join-Path $stage $dir) | Out-Null
- }
- Copy-IntoPackage $Bitstream $stage $ShortBitName | Out-Null
- Copy-IntoPackage $Bitstream (Join-Path $stage "bitstreams") | Out-Null
- Copy-IntoPackage $TdReceipt $stage $ShortTdName | Out-Null
- Copy-IntoPackage $TdReceipt (Join-Path $stage "td-receipts") | Out-Null
- Copy-IntoPackage (Join-Path $repoRoot "tools\remote\collect_j6_binary921.py") (Join-Path $stage "tools") | Out-Null
- Copy-IntoPackage (Join-Path $repoRoot "tools\binary921.py") (Join-Path $stage "tools") | Out-Null
- Copy-IntoPackage (Join-Path $repoRoot "tools\bmc_replay_uart.py") (Join-Path $stage "tools") | Out-Null
- Copy-IntoPackage (Join-Path $repoRoot "config\pin_inventory.fcb_fpga_mcu0611.json") (Join-Path $stage "config") | Out-Null
- $bmcReplayPayloadInfo = $null
- if ($Profile -eq "production-two-uart-bmc-replay-binary921") {
- $payloadTarget = Copy-IntoPackage $BmcReplayPayload $stage "bmc-replay-payload.json"
- $payloadJson = Assert-ProductionBmcPayload $payloadTarget
- $bmcReplayPayloadInfo = [ordered]@{
- path = "bmc-replay-payload.json"
- sha256 = Get-Sha256 $payloadTarget
- reply_sha256 = [string]$payloadJson.reply_sha256
- capture_text_sha256 = [string]$payloadJson.capture_text_sha256
- byte_count = [int]$payloadJson.byte_count
- valid_count = [int]$payloadJson.valid_count
- missing_count = [int]$payloadJson.missing_count
- source = [string]$payloadJson.source
- }
- }
- $collectorWrapper = @'
- param(
- [string]$HostPort = "COM8",
- [string]$DebugPort = "COM7",
- [string]$CombinedPort = "",
- [ValidateSet("debug-photo-bmc-replay-binary921", "formal-uart1-bmc-replay-binary921", "production-two-uart-bmc-replay-binary921")]
- [string]$Profile = "__PROFILE__",
- [string]$OutputDir = ".\evidence-binary921",
- [int]$DurationSeconds = 180,
- [string]$Bitstream = ".\j6bin.bit",
- [string]$TdReceipt = ".\td.json",
- [string]$BmcReplayReceipt = ".\bmc-replay-session.json",
- [switch]$SelfTest
- )
- $ErrorActionPreference = "Stop"
- $root = $PSScriptRoot
- $python = "python"
- $collector = Join-Path $root "tools\collect_j6_binary921.py"
- $env:PYTHONDONTWRITEBYTECODE = "1"
- if ($SelfTest) {
- & $python $collector --selftest
- } else {
- if ($Profile -eq "production-two-uart-bmc-replay-binary921") {
- if ([string]::IsNullOrWhiteSpace($CombinedPort)) { throw "CombinedPort is required for production-two-uart-bmc-replay-binary921" }
- & $python $collector --transport combined-single-com --combined-port $CombinedPort --profile $Profile --output-dir $OutputDir --duration-sec $DurationSeconds --bitstream $Bitstream --td-receipt $TdReceipt --bmc-replay-receipt $BmcReplayReceipt --json
- } else {
- & $python $collector --transport two-uart --host-port $HostPort --debug-port $DebugPort --profile $Profile --output-dir $OutputDir --duration-sec $DurationSeconds --bitstream $Bitstream --td-receipt $TdReceipt --bmc-replay-receipt $BmcReplayReceipt --json
- }
- }
- if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- '@
- $collectorWrapper = $collectorWrapper.Replace("__PROFILE__", $Profile)
- Set-Content -LiteralPath (Join-Path $stage "collect-binary921.ps1") -Encoding UTF8 -Value $collectorWrapper
- if ($Profile -eq "production-two-uart-bmc-replay-binary921") {
- Set-Content -LiteralPath (Join-Path $stage "commands\collect-binary921-template.ps1") -Encoding UTF8 -Value ('powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\collect-binary921.ps1 -CombinedPort COM7 -Profile {0} -OutputDir .\evidence-binary921 -DurationSeconds 180 -Bitstream .\j6bin.bit -TdReceipt .\td.json -BmcReplayReceipt .\bmc-replay-session.json' -f $Profile)
- } else {
- Set-Content -LiteralPath (Join-Path $stage "commands\collect-binary921-template.ps1") -Encoding UTF8 -Value ('powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\collect-binary921.ps1 -HostPort COM8 -DebugPort COM7 -Profile {0} -OutputDir .\evidence-binary921 -DurationSeconds 180 -Bitstream .\j6bin.bit -TdReceipt .\td.json -BmcReplayReceipt .\bmc-replay-session.json' -f $Profile)
- }
- $replayWrapper = @'
- param(
- [ValidatePattern('^COM[0-9]+$')]
- [string]$BmcReplayPort = "COM9",
- [string]$Payload = "__BMC_PAYLOAD_DEFAULT__",
- [int]$Iterations = 3,
- [int]$TimeoutSeconds = 600,
- [switch]$SelfTest
- )
- $ErrorActionPreference = "Stop"
- $root = $PSScriptRoot
- $helper = Join-Path $root "tools\bmc_replay_uart.py"
- $env:PYTHONDONTWRITEBYTECODE = "1"
- if ($SelfTest) {
- & python $helper selftest
- } else {
- & python $helper replay --port $BmcReplayPort --payload $Payload --iterations $Iterations --timeout-sec $TimeoutSeconds --json | Tee-Object -FilePath (Join-Path $root "bmc-replay-session.json")
- }
- if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- '@
- $replayWrapper = $replayWrapper.Replace("__BMC_PAYLOAD_DEFAULT__", ($(if ($Profile -eq "production-two-uart-bmc-replay-binary921") { ".\bmc-replay-payload.json" } else { ".\bmc-replay-payload.example.json" })))
- Set-Content -LiteralPath (Join-Path $stage "replay-bmc.ps1") -Encoding UTF8 -Value $replayWrapper
- $examplePayload = [ordered]@{
- schema = "j6-bmc-replay-payload-v1"
- status = "debug_example_only"
- source = "synthetic_example"
- bmc_source = "pc_replay_from_real_bmc_capture"
- live_bmc_link_status = "not_used"
- replay_mode = "poll_response"
- poll_text = "ipmitool raw 0x36 0x6c 0xdf 0xdd 0x00 0x03"
- poll_command_text = "ipmitool raw 0x36 0x6c 0xdf 0xdd 0x00 0x03`n"
- reply_text = "28 00 29 00 2a 00 2b 00 2c 00 2d 00 2e 00 2f 00 30 00 31 00 32 00 33 00 34 00 35 00 36 00 37 00 38 00 39 00 3a 00 3b 00 3c 00 3d 00 3e 00 3f 00`r`n"
- byte_count = 48
- valid_count = 24
- missing_count = 0
- authority_boundary = "Synthetic example payload for temporary BMC replay wiring debug only. It is not real BMC evidence."
- }
- $examplePayload | ConvertTo-Json -Depth 16 | Set-Content -LiteralPath (Join-Path $stage "bmc-replay-payload.example.json") -Encoding UTF8
- Set-Content -LiteralPath (Join-Path $stage "START-HERE.zh-CN.md") -Encoding UTF8 -Value (New-StartHere $Profile)
- $pinMap = New-Binary921PinMap $Profile
- $packageStatus = if ($Profile -eq "formal-uart1-bmc-replay-binary921") {
- "blocked_waiting_for_uart1_uart2_access"
- } else {
- "pass"
- }
- $transport = if ($Profile -eq "production-two-uart-bmc-replay-binary921") { "combined_host_debug_uart" } else { "separate_host_debug_uart" }
- $manifest = [ordered]@{
- schema = "j6-bmc-replay-binary921-package-manifest-v1"
- status = $packageStatus
- generated_at = (Get-Date).ToUniversalTime().ToString("o")
- package_name = $PackageName
- protocol = "binary921"
- pin_profile = $Profile
- transport = $transport
- combined_uart_baud = $(if ($transport -eq "combined_host_debug_uart") { 921600 } else { $null })
- bmc_replay_uart_baud = 115200
- programming_mode = "PROGRAM_SRAM"
- jtag_programming = [ordered]@{
- program_mode = "PROGRAM_SRAM"
- jtag_speed_hz = 200000
- board_power_present_before_program = $true
- power_cycle_required = $false
- connector = "J3 CON/2x5P/2.54"
- pinout = @("1=TCK", "2=GND", "3=TDO", "4=VREF", "5=TMS", "6=NC", "7=NC", "8=NC", "9=TDI", "10=GND")
- tooling = "manual BitWriter/TD GUI"
- cli_programming_supported = $false
- cli_speed_mapping_proven = $false
- }
- bitstream = [ordered]@{ path = $ShortBitName; sha256 = Get-Sha256 (Join-Path $stage $ShortBitName) }
- td_receipt = [ordered]@{ path = $ShortTdName; sha256 = Get-Sha256 (Join-Path $stage $ShortTdName) }
- bmc_source = "pc_replay_from_real_bmc_capture"
- live_bmc_link_status = "not_used"
- bmc_replay_payload = $bmcReplayPayloadInfo
- pin_map = $pinMap
- real_fan_ptc_hardware_status = "not_run"
- hardware_access_status = $pinMap.hardware_access_status
- collector = [ordered]@{
- wrapper = "collect-binary921.ps1"
- python = "tools/collect_j6_binary921.py"
- transport = $transport
- host_port = $(if ($transport -eq "combined_host_debug_uart") { $null } else { "COM8" })
- debug_port = $(if ($transport -eq "combined_host_debug_uart") { $null } else { "COM7" })
- combined_port = $(if ($transport -eq "combined_host_debug_uart") { "COM7" } else { $null })
- debug_port_write_policy = $(if ($transport -eq "combined_host_debug_uart") { "combined_port_writes_host_commands_only" } else { "read_only" })
- bmc_replay_receipt = "bmc-replay-session.json"
- expected_artifact = "binary921-evidence-manifest.json"
- }
- host_control_commands = @("SET_PTC 1 10", "SET_PTC 24 20", "SET_FAN 1 40", "SET_FAN 4 30", "SET_PID_REQUESTED 1", "GET_STATUS", "GET_MAP", "GET_SENSOR", "GET_SENSOR", "GET_SENSOR", "SET_PID_REQUESTED 0", "DISABLE")
- safety = [ordered]@{
- flash_attempted = $false
- driver_install_attempted = $false
- programs_nonvolatile = $false
- enumerates_com_ports = $false
- debug_port_writes_to_serial = $false
- toggles_dtr_rts = $false
- }
- authority_boundary = "SRAM-only binary921 diagnostic package. It does not claim live BMC, thermal performance, PID closed-loop, or real PTC/FAN load pass."
- }
- $manifest | ConvertTo-Json -Depth 64 | Set-Content -LiteralPath (Join-Path $stage "manifest.json") -Encoding UTF8
- Remove-PythonCache $stage
- $inventory = New-Object System.Collections.Generic.List[object]
- Get-ChildItem -LiteralPath $stage -Recurse -File | Sort-Object FullName | ForEach-Object {
- if ($_.Name -eq "sha256-inventory.json") { return }
- $inventory.Add((New-InventoryItem $_.FullName $stage)) | Out-Null
- }
- [ordered]@{
- schema = "j6-bmc-replay-binary921-package-sha256-inventory-v1"
- generated_at = (Get-Date).ToUniversalTime().ToString("o")
- self_hash_policy = "excluded_self_referential_file"
- inventory = $inventory
- } | ConvertTo-Json -Depth 32 | Set-Content -LiteralPath (Join-Path $stage "sha256-inventory.json") -Encoding UTF8
- $zipPath = Join-Path $out ($PackageName + ".zip")
- if (Test-Path -LiteralPath $zipPath) {
- if (-not $ForceOverwrite) { throw "Package zip already exists: $zipPath" }
- Remove-Item -LiteralPath $zipPath -Force
- }
- $zipSidecar = $zipPath + ".sha256.txt"
- if (Test-Path -LiteralPath $zipSidecar) {
- if (-not $ForceOverwrite) { throw "Package zip sidecar already exists: $zipSidecar" }
- Remove-Item -LiteralPath $zipSidecar -Force
- }
- Compress-Archive -Path (Join-Path $stage "*") -DestinationPath $zipPath -Force
- $zipSha = Get-Sha256 $zipPath
- Set-Content -LiteralPath $zipSidecar -Encoding ASCII -Value ("{0} {1}" -f $zipSha, (Split-Path -Leaf $zipPath))
- Write-Host "Wrote $stage"
- Write-Host "Wrote $zipPath"
- Write-Host ("SHA256 {0} {1}" -f $zipSha, $zipPath)
|