param( [string]$OutputDir = ".\j6-host-sensor-real-fan-ptc-temp-uart-ptc-remap-debug921-v2-epochfix-psarrayfix-tailfix-package", [string]$PackageName = "", [Parameter(Mandatory = $true)] [ValidateSet("temp-uart-ptc-remap")] [string]$Profile, [Parameter(Mandatory = $true)] [string]$Bitstream, [Parameter(Mandatory = $true)] [string]$TdReceipt, [switch]$ForceOverwrite ) $ErrorActionPreference = "Stop" # Package profile: # temp-uart-ptc-remap -> j6-host-sensor-real-fan-ptc-temp-uart-ptc-remap-debug921-v2-epochfix-psarrayfix-tailfix # The copied collector is tools\remote\collect-j6-host-sensor-real-fan-ptc.ps1. # Start the collector first, then run manual PROGRAM_SRAM so READY/J6READY is captured. 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 Copy-IntoPackage([string]$Source, [string]$DestinationDir) { if (-not (Test-Path -LiteralPath $Source -PathType Leaf)) { throw "File not found: $Source" } New-Item -ItemType Directory -Force -Path $DestinationDir | Out-Null $name = Split-Path -Leaf $Source $destination = Join-Path $DestinationDir $name Copy-Item -LiteralPath $Source -Destination $destination -Force return $destination } 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 New-PinMap([string]$SelectedProfile) { if ($SelectedProfile -ne "temp-uart-ptc-remap") { throw "Only temp-uart-ptc-remap is supported by this v2 packager" } return [ordered]@{ name = "temp-uart-ptc-remap" bmc_tx_ball = "T4" bmc_rx_ball = "R5" host_tx_ball = "P7" host_rx_ball = "P8" debug_rx_ball = "P10" debug_tx_ball = "R10" ptc_substitutions = [ordered]@{ PTC03 = [ordered]@{ original_ball = "T4"; substitute_ball = "P5"; bank_io_net = "BANK2_GPIO40" } PTC04 = [ordered]@{ original_ball = "R5"; substitute_ball = "T8"; bank_io_net = "BANK2_GPIO41" } PTC17 = [ordered]@{ original_ball = "P8"; substitute_ball = "M14"; bank_io_net = "BANK2_GPIO42" } PTC18 = [ordered]@{ original_ball = "P7"; substitute_ball = "M15"; bank_io_net = "BANK2_GPIO43" } PTC21 = [ordered]@{ original_ball = "P10"; substitute_ball = "P15"; bank_io_net = "BANK2_GPIO44" } PTC22 = [ordered]@{ original_ball = "R10"; substitute_ball = "N14"; bank_io_net = "BANK2_GPIO45" } } reserved_future_uart = [ordered]@{ UART1_TX = [ordered]@{ fpga_ball = "L10"; bank_io_net = "BANK2_GPIO52"; used = $false } UART1_RX = [ordered]@{ fpga_ball = "M9"; bank_io_net = "BANK2_GPIO53"; used = $false } UART2_TX = [ordered]@{ fpga_ball = "M10"; bank_io_net = "BANK2_GPIO54"; used = $false } UART2_RX = [ordered]@{ fpga_ball = "N11"; bank_io_net = "BANK2_GPIO55"; used = $false } } } } function New-StartHereText([string]$SelectedProfile, [string]$BitName, [string]$TdName) { if ($SelectedProfile -ne "temp-uart-ptc-remap") { throw "Only temp-uart-ptc-remap is supported by this v2 packager" } $title = "J6 Host Sensor Real FAN/PTC temp-uart-ptc-remap Debug921 v2 epochfix psarrayfix tailfix" $wiring = @" - BMC UART:CPLD TX=T4,RX=R5。 - DebugPort:COM7,P10/R10,921600 8N1。 - HostPort:COM8,P7/P8,115200 8N1。 - PTC03/PTC04/PTC17/PTC18/PTC21/PTC22 使用临时替代引脚;具体替代关系见 manifest.json。 - HostPort 上电后先输出 `READY profile=temp-uart-ptc-remap seq=00000000`。collector 会等待 HostPort READY 和 DebugPort J6READY 都出现,保存 startup-preflight.json,再进入严格 12 条正式命令序列。 "@ $hardwareNote = "本 temp profile 保持当前三路调试串口接线不变,只把 6 路与串口冲突的 PTC 输出临时改到复核空闲 GPIO。" return @" # $title ## 1. 先启动 collector 在本包根目录打开 PowerShell,先复制执行下面这一条命令。collector 会先打开 COM8/COM7、等待 READY/J6READY,并把启动同步写入 `startup-preflight.json`。 ~~~powershell powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\collector\collect-j6-host-sensor-real-fan-ptc.ps1 -HostPort COM8 -DebugPort COM7 -DurationSeconds 180 -OutputDir .\evidence-com8-host-com7-debug -Profile $SelectedProfile -Bitstream .\bitstreams\$BitName -TdReceipt .\td-receipts\$TdName ~~~ 也可以执行包内快捷脚本: ~~~powershell powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\commands\collect-template.ps1 ~~~ ## 2. collector 启动后手动刷 SRAM collector 开始等待后,在 TD/ChipWatcher 中只执行 `PROGRAM_SRAM`,选择下面这个 bitstream: ~~~text bitstreams/$BitName ~~~ 不要执行任何非易失存储写入、擦除或固化存储相关动作。 collector first, then PROGRAM_SRAM. collector 会忽略 READY/J6READY 前的旧程序 ACK,并在未锁定新 SRAM epoch 时拒绝发送正式命令。 ## 接线 $wiring ## 采集内容 - HostPort 会发送 `SET PTC 01 10`、`SET PTC 24 20`、`SET FAN 01 40`、`SET FAN 04 30`、`SET PID ENABLE`、`GET STATUS`、`GET MAP`、三次 `GET SENSOR`、`SET PID DISABLE` 和 `DISABLE`。 - `startup-preflight.json` 记录 `READY/J6READY` epoch 锁定和 pre-SRAM noise;正式 transcript 必须仍然只有 12 条命令和 12 条匹配 ACK。 - DebugPort 只读,预期证据帧包括 `J6CMD/J6RAW/J6EVT/J6PWM/J6MOD/J6STAT/J6MAP/J6TEMP`。 - collector 结束前会执行 tail drain,等待 DebugPort 静默并记录最后 `J6STAT` 是否覆盖最后完整 `J6RAW`;若末尾只有不完整行,会记录到 manifest/debug-frame-stream,不会当作有效 replay 帧。 - BMC 温度仍来自 J6 UART raw 命令,不使用 I2C、MCU、`BMC_SCL/SDA` 或 `TEMP_SCL/SDA`。 ## 包内参考 - [中文 runbook](docs/j6-host-sensor-real-fan-ptc-debug921-runbook.zh-CN.md) - [collector 脚本](collector/collect-j6-host-sensor-real-fan-ptc.ps1) - [SHA256 inventory](sha256-inventory.json) ## 边界 $hardwareNote 本包只声明 SRAM-only 诊断链路、HostPort 控制、BMC raw 采样、温度解析和证据采集成立;不声明非易失存储写入、真实热性能、真实 PTC/FAN 负载或 PID 闭环通过。 "@ } $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 = "j6-host-sensor-real-fan-ptc-temp-uart-ptc-remap-debug921-v2-epochfix-psarrayfix-tailfix-$stamp" } $stage = Join-Path $out $PackageName if (Test-Path -LiteralPath $stage) { if (-not $ForceOverwrite) { throw "Package staging directory already exists: $stage. Move it aside, choose a different -PackageName, or pass -ForceOverwrite." } $resolvedStage = (Resolve-Path -LiteralPath $stage).Path $resolvedOut = (Resolve-Path -LiteralPath $out).Path.TrimEnd('\') if (-not $resolvedStage.StartsWith($resolvedOut, [System.StringComparison]::OrdinalIgnoreCase)) { throw "Refusing to remove package directory outside output dir: $resolvedStage" } Remove-Item -LiteralPath $resolvedStage -Recurse -Force } foreach ($dir in @("bitstreams", "td-receipts", "collector", "commands", "schemas", "docs", "config")) { New-Item -ItemType Directory -Force -Path (Join-Path $stage $dir) | Out-Null } $collectorPath = Join-Path $repoRoot "tools\remote\collect-j6-host-sensor-real-fan-ptc.ps1" $schemaPath = Join-Path $repoRoot "schemas\real_bmc_j6_host_sensor_real_fan_ptc_debug921_v1_receipt.schema.json" $runbookPath = Join-Path $repoRoot "docs\j6-host-sensor-real-fan-ptc-debug921-runbook.zh-CN.md" $pinInventoryPath = Join-Path $repoRoot "config\pin_inventory.fcb_fpga_mcu0611.json" $bitstreamCopy = Copy-IntoPackage $Bitstream (Join-Path $stage "bitstreams") $tdReceiptCopy = Copy-IntoPackage $TdReceipt (Join-Path $stage "td-receipts") Copy-IntoPackage $collectorPath (Join-Path $stage "collector") | Out-Null Copy-IntoPackage $schemaPath (Join-Path $stage "schemas") | Out-Null Copy-IntoPackage $runbookPath (Join-Path $stage "docs") | Out-Null Copy-IntoPackage $pinInventoryPath (Join-Path $stage "config") | Out-Null $bitName = Split-Path -Leaf $bitstreamCopy $tdName = Split-Path -Leaf $tdReceiptCopy $template = @' & "$PSHOME\powershell.exe" -NoProfile -ExecutionPolicy Bypass -File .\collector\collect-j6-host-sensor-real-fan-ptc.ps1 -HostPort COM8 -DebugPort COM7 -DurationSeconds 180 -OutputDir .\evidence-com8-host-com7-debug -Profile __PROFILE__ -Bitstream .\bitstreams\__BITSTREAM__ -TdReceipt .\td-receipts\__TD_RECEIPT__ '@ $template = $template.Replace("__PROFILE__", $Profile).Replace("__BITSTREAM__", $bitName).Replace("__TD_RECEIPT__", $tdName) Set-Content -LiteralPath (Join-Path $stage "commands\collect-template.ps1") -Encoding UTF8 -Value $template Set-Content -LiteralPath (Join-Path $stage "START-HERE.zh-CN.md") -Encoding UTF8 -Value (New-StartHereText $Profile $bitName $tdName) $hostControlCommands = @( "SET PTC 01 10", "SET PTC 24 20", "SET FAN 01 40", "SET FAN 04 30", "SET PID ENABLE", "GET STATUS", "GET MAP", "GET SENSOR", "GET SENSOR", "GET SENSOR", "SET PID DISABLE", "DISABLE" ) $pinMap = New-PinMap $Profile $manifest = [ordered]@{ schema = "j6-host-sensor-real-fan-ptc-debug921-package-manifest-v1" status = "pass" generated_at = (Get-Date).ToUniversalTime().ToString("o") package_name = $PackageName diagnostic_scope = "host_sensor_real_fan_ptc_debug921" pin_profile = $Profile programming_mode = "PROGRAM_SRAM" bitstream = [ordered]@{ path = "bitstreams/$bitName"; sha256 = Get-Sha256 $bitstreamCopy } td_receipt = [ordered]@{ path = "td-receipts/$tdName"; sha256 = Get-Sha256 $tdReceiptCopy } collector = [ordered]@{ path = "collector/collect-j6-host-sensor-real-fan-ptc.ps1"; profile_argument = $Profile } host_control_commands = $hostControlCommands startup_preflight = [ordered]@{ expected_artifact = "startup-preflight.json" ready_line = "READY profile=temp-uart-ptc-remap seq=00000000" j6ready_line = "J6READY profile=temp-uart-ptc-remap" epoch_locked_required = $true formal_ack_count = 12 } tail_drain = [ordered]@{ expected_manifest_field = "debug_tail" expected_stream_field = "tail" purpose = "Close the DebugPort capture window so post-J6STAT complete J6RAW tail is attributed instead of misreported as frame loss." } pin_map = $pinMap real_fan_ptc_hardware_status = "not_run" remote_dependencies = "PowerShell and .NET SerialPort only; no remote dependency install." sha256_inventory_policy = "sha256-inventory.json excludes itself because it is self-referential; the package zip is sealed by the adjacent .zip.sha256.txt file." authority_boundary = "SRAM-only diagnostic package. It does not program nonvolatile memory, install drivers, enumerate unknown COM ports, write DebugPort, claim thermal performance, or claim PID closed-loop pass." } $manifestPath = Join-Path $stage "manifest.json" $manifest | ConvertTo-Json -Depth 64 | Set-Content -LiteralPath $manifestPath -Encoding UTF8 $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-host-sensor-real-fan-ptc-debug921-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. Move it aside, choose a different -PackageName, or pass -ForceOverwrite." } Remove-Item -LiteralPath $zipPath -Force } $zipSidecar = $zipPath + ".sha256.txt" if (Test-Path -LiteralPath $zipSidecar) { if (-not $ForceOverwrite) { throw "Package zip sidecar already exists: $zipSidecar. Move it aside, choose a different -PackageName, or pass -ForceOverwrite." } 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)