Jelajahi Sumber

package temp tailfix with short BitWriter path

Codex 4 bulan lalu
induk
melakukan
aa4409a074

+ 65 - 28
tests/unit/test_remote_scripts.py

@@ -605,10 +605,13 @@ if ($events[2].fields.cmd -ne "FANCH") { throw "ack cmd was $($events[2].fields.
             "commands",
             "commands",
             "pin_inventory.fcb_fpga_mcu0611.json",
             "pin_inventory.fcb_fpga_mcu0611.json",
             "sha256-inventory.json",
             "sha256-inventory.json",
-            "Compress-Archive",
+            "Compress-Archive",
             ".zip.sha256.txt",
             ".zip.sha256.txt",
+            "j6tmp-v2-tailfix",
+            "j6tmp.bit",
+            "collect.ps1",
+            "td.json",
             "temp-uart-ptc-remap",
             "temp-uart-ptc-remap",
-            "j6-host-sensor-real-fan-ptc-temp-uart-ptc-remap-debug921-v2-epochfix-psarrayfix-tailfix",
             "startup-preflight.json",
             "startup-preflight.json",
             "READY profile=temp-uart-ptc-remap",
             "READY profile=temp-uart-ptc-remap",
             "collector first, then PROGRAM_SRAM",
             "collector first, then PROGRAM_SRAM",
@@ -624,9 +627,10 @@ if ($events[2].fields.cmd -ne "FANCH") { throw "ack cmd was $($events[2].fields.
         self.assertNotIn("Set-ExecutionPolicy", script)
         self.assertNotIn("Set-ExecutionPolicy", script)
         self.assertNotIn("-AssumeManualSramProgrammed $true", script)
         self.assertNotIn("-AssumeManualSramProgrammed $true", script)
         for marker in [
         for marker in [
-            "formal-uart",
-            "j6-host-sensor-real-fan-ptc-formal-uart-debug921-v1",
-            "debug115",
+            "formal-uart",
+            "j6-host-sensor-real-fan-ptc-formal-uart-debug921-v1",
+            "j6-host-sensor-real-fan-ptc-temp-uart-ptc-remap-debug921-v2-epochfix-psarrayfix-tailfix",
+            "debug115",
             "swapped",
             "swapped",
             "-ManualSramAttestation",
             "-ManualSramAttestation",
             "$att.status",
             "$att.status",
@@ -664,7 +668,7 @@ if ($events[2].fields.cmd -ne "FANCH") { throw "ack cmd was $($events[2].fields.
                 encoding="utf-8",
                 encoding="utf-8",
             )
             )
             for profile, package_name in [
             for profile, package_name in [
-                ("temp-uart-ptc-remap", "j6-host-sensor-real-fan-ptc-temp-uart-ptc-remap-debug921-v2-epochfix-psarrayfix-tailfix-test"),
+                ("temp-uart-ptc-remap", "j6tmp-v2-tailfix-test"),
             ]:
             ]:
                 with self.subTest(profile=profile):
                 with self.subTest(profile=profile):
                     result = subprocess.run(
                     result = subprocess.run(
@@ -694,14 +698,23 @@ if ($events[2].fields.cmd -ne "FANCH") { throw "ack cmd was $($events[2].fields.
                     output = (result.stderr or b"").decode("utf-8", errors="replace") + (
                     output = (result.stderr or b"").decode("utf-8", errors="replace") + (
                         result.stdout or b""
                         result.stdout or b""
                     ).decode("utf-8", errors="replace")
                     ).decode("utf-8", errors="replace")
-                    self.assertEqual(result.returncode, 0, output)
-                    stage = Path(tmp) / package_name
-                    self.assertTrue((stage / "START-HERE.zh-CN.md").is_file())
-                    self.assertTrue((stage / "collector" / "collect-j6-host-sensor-real-fan-ptc.ps1").is_file())
-                    self.assertTrue((stage / "commands" / "collect-template.ps1").is_file())
-                    self.assertTrue((stage / "bitstreams" / bitstream.name).is_file())
-                    self.assertTrue((stage / "td-receipts" / td_receipt.name).is_file())
-                    self.assertTrue((stage / "config" / "pin_inventory.fcb_fpga_mcu0611.json").is_file())
+                    self.assertEqual(result.returncode, 0, output)
+                    stage = Path(tmp) / package_name
+                    short_bit = stage / "j6tmp.bit"
+                    short_collect = stage / "collect.ps1"
+                    short_td = stage / "td.json"
+                    self.assertTrue((stage / "START-HERE.zh-CN.md").is_file())
+                    self.assertTrue(short_bit.is_file())
+                    self.assertTrue(short_collect.is_file())
+                    self.assertTrue(short_td.is_file())
+                    self.assertTrue((stage / "collector" / "collect-j6-host-sensor-real-fan-ptc.ps1").is_file())
+                    self.assertTrue((stage / "commands" / "collect-template.ps1").is_file())
+                    self.assertTrue((stage / "bitstreams" / bitstream.name).is_file())
+                    self.assertTrue((stage / "td-receipts" / td_receipt.name).is_file())
+                    self.assertEqual(short_bit.read_bytes(), bitstream.read_bytes())
+                    self.assertEqual(json.loads(short_td.read_text(encoding="utf-8-sig"))["status"], "pass")
+                    self.assertLess(len(str(short_bit)), 100)
+                    self.assertTrue((stage / "config" / "pin_inventory.fcb_fpga_mcu0611.json").is_file())
                     self.assertTrue((stage / "schemas" / "real_bmc_j6_host_sensor_real_fan_ptc_debug921_v1_receipt.schema.json").is_file())
                     self.assertTrue((stage / "schemas" / "real_bmc_j6_host_sensor_real_fan_ptc_debug921_v1_receipt.schema.json").is_file())
                     self.assertFalse((stage / "blocked").exists())
                     self.assertFalse((stage / "blocked").exists())
                     self.assertTrue((Path(tmp) / f"{package_name}.zip").is_file())
                     self.assertTrue((Path(tmp) / f"{package_name}.zip").is_file())
@@ -709,10 +722,15 @@ if ($events[2].fields.cmd -ne "FANCH") { throw "ack cmd was $($events[2].fields.
                     start_here = (stage / "START-HERE.zh-CN.md").read_text(encoding="utf-8-sig")
                     start_here = (stage / "START-HERE.zh-CN.md").read_text(encoding="utf-8-sig")
                     self.assertIn("PROGRAM_SRAM", start_here)
                     self.assertIn("PROGRAM_SRAM", start_here)
                     self.assertIn("先启动 collector", start_here)
                     self.assertIn("先启动 collector", start_here)
-                    self.assertIn("collector first, then PROGRAM_SRAM", start_here)
-                    self.assertIn(f"-Profile {profile}", start_here)
-                    self.assertIn(f".\\bitstreams\\{bitstream.name}", start_here)
-                    self.assertIn(f".\\td-receipts\\{td_receipt.name}", start_here)
+                    self.assertIn("collector first, then PROGRAM_SRAM", start_here)
+                    self.assertIn(f"-Profile {profile}", start_here)
+                    self.assertIn(".\\j6tmp.bit", start_here)
+                    self.assertIn(".\\td.json", start_here)
+                    self.assertIn("-File .\\collect.ps1", start_here)
+                    self.assertIn("Cannot open file", start_here)
+                    self.assertIn("bitstreams", start_here)
+                    self.assertNotIn(f".\\bitstreams\\{bitstream.name}", start_here)
+                    self.assertNotIn(f".\\td-receipts\\{td_receipt.name}", start_here)
                     self.assertIn("powershell.exe -NoProfile -ExecutionPolicy Bypass -File", start_here)
                     self.assertIn("powershell.exe -NoProfile -ExecutionPolicy Bypass -File", start_here)
                     self.assertIn("-HostPort COM8 -DebugPort COM7", start_here)
                     self.assertIn("-HostPort COM8 -DebugPort COM7", start_here)
                     self.assertIn("tail drain", start_here)
                     self.assertIn("tail drain", start_here)
@@ -727,17 +745,33 @@ if ($events[2].fields.cmd -ne "FANCH") { throw "ack cmd was $($events[2].fields.
                         encoding="utf-8-sig"
                         encoding="utf-8-sig"
                     )
                     )
                     self.assertNotIn("Set-ExecutionPolicy", collect_template)
                     self.assertNotIn("Set-ExecutionPolicy", collect_template)
-                    self.assertNotIn("-AssumeManualSramProgrammed", collect_template)
-                    self.assertIn("-NoProfile", collect_template)
-                    self.assertIn("-ExecutionPolicy Bypass", collect_template)
-                    self.assertIn("-File .\\collector\\collect-j6-host-sensor-real-fan-ptc.ps1", collect_template)
-                    self.assertNotIn("blocked_pin_conflict_with_locked_debug_uart", start_here)
+                    self.assertNotIn("-AssumeManualSramProgrammed", collect_template)
+                    self.assertIn("-NoProfile", collect_template)
+                    self.assertIn("-ExecutionPolicy Bypass", collect_template)
+                    self.assertIn("-File .\\collect.ps1", collect_template)
+                    shortcut = short_collect.read_text(encoding="utf-8-sig")
+                    self.assertIn("$PSHOME", shortcut)
+                    self.assertIn("$PSScriptRoot", shortcut)
+                    self.assertIn('"-File"', shortcut)
+                    self.assertIn('Join-Path $packageRoot "collector\\collect-j6-host-sensor-real-fan-ptc.ps1"', shortcut)
+                    self.assertIn('[string]$Bitstream = ".\\j6tmp.bit"', shortcut)
+                    self.assertIn('[string]$TdReceipt = ".\\td.json"', shortcut)
+                    self.assertIn('"-Bitstream"', shortcut)
+                    self.assertIn('"-TdReceipt"', shortcut)
+                    self.assertIn("[switch]$SelfTest", shortcut)
+                    self.assertNotIn("Set-ExecutionPolicy", shortcut)
+                    self.assertNotIn("-AssumeManualSramProgrammed", shortcut)
+                    self.assertNotIn("blocked_pin_conflict_with_locked_debug_uart", start_here)
 
 
                     manifest = json.loads((stage / "manifest.json").read_text(encoding="utf-8-sig"))
                     manifest = json.loads((stage / "manifest.json").read_text(encoding="utf-8-sig"))
                     self.assertEqual(manifest["status"], "pass")
                     self.assertEqual(manifest["status"], "pass")
                     self.assertEqual(manifest["pin_profile"], profile)
                     self.assertEqual(manifest["pin_profile"], profile)
-                    self.assertIn("epochfix-psarrayfix-tailfix", manifest["package_name"])
+                    self.assertIn("j6tmp-v2-tailfix", manifest["package_name"])
                     self.assertEqual(manifest["programming_mode"], "PROGRAM_SRAM")
                     self.assertEqual(manifest["programming_mode"], "PROGRAM_SRAM")
+                    self.assertEqual(manifest["bitstream"]["path"], "j6tmp.bit")
+                    self.assertEqual(manifest["td_receipt"]["path"], "td.json")
+                    self.assertEqual(manifest["short_path_aliases"]["bitstream"]["source"], f"bitstreams/{bitstream.name}")
+                    self.assertEqual(manifest["short_path_aliases"]["td_receipt"]["source"], f"td-receipts/{td_receipt.name}")
                     self.assertIn("host_control_commands", manifest)
                     self.assertIn("host_control_commands", manifest)
                     self.assertIn("pin_map", manifest)
                     self.assertIn("pin_map", manifest)
                     self.assertIn("tail_drain", manifest)
                     self.assertIn("tail_drain", manifest)
@@ -745,10 +779,13 @@ if ($events[2].fields.cmd -ne "FANCH") { throw "ack cmd was $($events[2].fields.
 
 
                     inventory = json.loads((stage / "sha256-inventory.json").read_text(encoding="utf-8-sig"))
                     inventory = json.loads((stage / "sha256-inventory.json").read_text(encoding="utf-8-sig"))
                     self.assertEqual(inventory["self_hash_policy"], "excluded_self_referential_file")
                     self.assertEqual(inventory["self_hash_policy"], "excluded_self_referential_file")
-                    inventory_paths = {item["path"] for item in inventory["inventory"]}
-                    self.assertIn("manifest.json", inventory_paths)
-                    self.assertIn("START-HERE.zh-CN.md", inventory_paths)
-                    self.assertIn("collector/collect-j6-host-sensor-real-fan-ptc.ps1", inventory_paths)
+                    inventory_paths = {item["path"] for item in inventory["inventory"]}
+                    self.assertIn("manifest.json", inventory_paths)
+                    self.assertIn("START-HERE.zh-CN.md", inventory_paths)
+                    self.assertIn("j6tmp.bit", inventory_paths)
+                    self.assertIn("collect.ps1", inventory_paths)
+                    self.assertIn("td.json", inventory_paths)
+                    self.assertIn("collector/collect-j6-host-sensor-real-fan-ptc.ps1", inventory_paths)
                     self.assertIn("commands/collect-template.ps1", inventory_paths)
                     self.assertIn("commands/collect-template.ps1", inventory_paths)
                     self.assertNotIn("sha256-inventory.json", inventory_paths)
                     self.assertNotIn("sha256-inventory.json", inventory_paths)
 
 

+ 84 - 21
tools/package_j6_host_sensor_real_fan_ptc_debug921.ps1

@@ -1,5 +1,5 @@
 param(
 param(
-    [string]$OutputDir = ".\j6-host-sensor-real-fan-ptc-temp-uart-ptc-remap-debug921-v2-epochfix-psarrayfix-tailfix-package",
+    [string]$OutputDir = ".\j6tmp-v2-tailfix-package",
     [string]$PackageName = "",
     [string]$PackageName = "",
     [Parameter(Mandatory = $true)]
     [Parameter(Mandatory = $true)]
     [ValidateSet("temp-uart-ptc-remap")]
     [ValidateSet("temp-uart-ptc-remap")]
@@ -14,10 +14,13 @@
 $ErrorActionPreference = "Stop"
 $ErrorActionPreference = "Stop"
 
 
 # Package profile:
 # Package profile:
-# temp-uart-ptc-remap -> j6-host-sensor-real-fan-ptc-temp-uart-ptc-remap-debug921-v2-epochfix-psarrayfix-tailfix
+# temp-uart-ptc-remap -> j6tmp-v2-tailfix
 # The copied collector is tools\remote\collect-j6-host-sensor-real-fan-ptc.ps1.
 # 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.
 # Start the collector first, then run manual PROGRAM_SRAM so READY/J6READY is captured.
 
 
+$ShortBitName = "j6tmp.bit"
+$ShortTdName = "td.json"
+
 function Get-Sha256([string]$Path) {
 function Get-Sha256([string]$Path) {
     if (-not (Test-Path -LiteralPath $Path -PathType Leaf)) {
     if (-not (Test-Path -LiteralPath $Path -PathType Leaf)) {
         throw "File not found: $Path"
         throw "File not found: $Path"
@@ -76,17 +79,17 @@ function New-PinMap([string]$SelectedProfile) {
     }
     }
 }
 }
 
 
-function New-StartHereText([string]$SelectedProfile, [string]$BitName, [string]$TdName) {
+function New-StartHereText([string]$SelectedProfile, [string]$BitName, [string]$TdName, [string]$ShortBit, [string]$ShortTd) {
     if ($SelectedProfile -ne "temp-uart-ptc-remap") {
     if ($SelectedProfile -ne "temp-uart-ptc-remap") {
         throw "Only temp-uart-ptc-remap is supported by this v2 packager"
         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"
+    $title = "J6 temp-uart-ptc-remap Debug921 v2 tailfix short-path package"
     $wiring = @"
     $wiring = @"
 - BMC UART:CPLD TX=T4,RX=R5。
 - BMC UART:CPLD TX=T4,RX=R5。
 - DebugPort:COM7,P10/R10,921600 8N1。
 - DebugPort:COM7,P10/R10,921600 8N1。
 - HostPort:COM8,P7/P8,115200 8N1。
 - HostPort:COM8,P7/P8,115200 8N1。
 - PTC03/PTC04/PTC17/PTC18/PTC21/PTC22 使用临时替代引脚;具体替代关系见 manifest.json。
 - 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 条正式命令序列。
+- HostPort 上电后先输出 READY profile=temp-uart-ptc-remap seq=00000000。collector 会等待 HostPort READY 和 DebugPort J6READY 都出现,保存 startup-preflight.json,再进入严格 12 条正式命令序列。
 "@
 "@
     $hardwareNote = "本 temp profile 保持当前三路调试串口接线不变,只把 6 路与串口冲突的 PTC 输出临时改到复核空闲 GPIO。"
     $hardwareNote = "本 temp profile 保持当前三路调试串口接线不变,只把 6 路与串口冲突的 PTC 输出临时改到复核空闲 GPIO。"
 
 
@@ -95,10 +98,10 @@ function New-StartHereText([string]$SelectedProfile, [string]$BitName, [string]$
 
 
 ## 1. 先启动 collector
 ## 1. 先启动 collector
 
 
-在本包根目录打开 PowerShell,先复制执行下面这一条命令。collector 会先打开 COM8/COM7、等待 READY/J6READY,并把启动同步写入 `startup-preflight.json`。
+在本包根目录打开 PowerShell,先复制执行下面这一条命令。collector 会先打开 COM8/COM7、等待 READY/J6READY,并把启动同步写入 startup-preflight.json。
 
 
 ~~~powershell
 ~~~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.exe -NoProfile -ExecutionPolicy Bypass -File .\collect.ps1 -HostPort COM8 -DebugPort COM7 -DurationSeconds 180 -OutputDir .\evidence-com8-host-com7-debug -Profile $SelectedProfile -Bitstream .\$ShortBit -TdReceipt .\$ShortTd
 ~~~
 ~~~
 
 
 也可以执行包内快捷脚本:
 也可以执行包内快捷脚本:
@@ -109,12 +112,14 @@ powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\commands\collect-templ
 
 
 ## 2. collector 启动后手动刷 SRAM
 ## 2. collector 启动后手动刷 SRAM
 
 
-collector 开始等待后,在 TD/ChipWatcher 中只执行 `PROGRAM_SRAM`,选择下面这个 bitstream:
+collector 开始等待后,在 TD/ChipWatcher/BitWriter 中只执行 PROGRAM_SRAM,选择本包根目录下面这个短路径 bitstream:
 
 
 ~~~text
 ~~~text
-bitstreams/$BitName
+.\$ShortBit
 ~~~
 ~~~
 
 
+不要选择 bitstreams/$BitName 作为现场刷机主路径;那份长文件名副本只用于审计和 hash 对照。若 BitWriter 报 Cannot open file,第一检查项是是否误选了旧长包或 bitstreams 深目录里的长文件名 bitstream。
+
 不要执行任何非易失存储写入、擦除或固化存储相关动作。
 不要执行任何非易失存储写入、擦除或固化存储相关动作。
 
 
 collector first, then PROGRAM_SRAM. collector 会忽略 READY/J6READY 前的旧程序 ACK,并在未锁定新 SRAM epoch 时拒绝发送正式命令。
 collector first, then PROGRAM_SRAM. collector 会忽略 READY/J6READY 前的旧程序 ACK,并在未锁定新 SRAM epoch 时拒绝发送正式命令。
@@ -125,11 +130,11 @@ $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`。
+- 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。
 
 
 ## 包内参考
 ## 包内参考
 
 
@@ -149,7 +154,7 @@ $out = (Resolve-Path -LiteralPath (New-Item -ItemType Directory -Force -Path $Ou
 
 
 if ([string]::IsNullOrWhiteSpace($PackageName)) {
 if ([string]::IsNullOrWhiteSpace($PackageName)) {
     $stamp = Get-Date -Format "yyyyMMdd-HHmmss"
     $stamp = Get-Date -Format "yyyyMMdd-HHmmss"
-    $PackageName = "j6-host-sensor-real-fan-ptc-temp-uart-ptc-remap-debug921-v2-epochfix-psarrayfix-tailfix-$stamp"
+    $PackageName = "j6tmp-v2-tailfix-$stamp"
 }
 }
 
 
 $stage = Join-Path $out $PackageName
 $stage = Join-Path $out $PackageName
@@ -183,12 +188,58 @@ Copy-IntoPackage $pinInventoryPath (Join-Path $stage "config") | Out-Null
 
 
 $bitName = Split-Path -Leaf $bitstreamCopy
 $bitName = Split-Path -Leaf $bitstreamCopy
 $tdName = Split-Path -Leaf $tdReceiptCopy
 $tdName = Split-Path -Leaf $tdReceiptCopy
+Copy-Item -LiteralPath $bitstreamCopy -Destination (Join-Path $stage $ShortBitName) -Force
+Copy-Item -LiteralPath $tdReceiptCopy -Destination (Join-Path $stage $ShortTdName) -Force
+
+$shortcut = @'
+param(
+    [string]$HostPort = "",
+    [string]$DebugPort = "",
+    [int]$DurationSeconds = 180,
+    [string]$OutputDir = ".\evidence-com8-host-com7-debug",
+    [ValidateSet("temp-uart-ptc-remap")]
+    [string]$Profile = "temp-uart-ptc-remap",
+    [string]$Bitstream = ".\j6tmp.bit",
+    [string]$TdReceipt = ".\td.json",
+    [switch]$SelfTest
+)
+
+$ErrorActionPreference = "Stop"
+$packageRoot = $PSScriptRoot
+$collector = Join-Path $packageRoot "collector\collect-j6-host-sensor-real-fan-ptc.ps1"
+$bitstreamPath = if ([System.IO.Path]::IsPathRooted($Bitstream)) { $Bitstream } else { Join-Path $packageRoot $Bitstream }
+$tdReceiptPath = if ([System.IO.Path]::IsPathRooted($TdReceipt)) { $TdReceipt } else { Join-Path $packageRoot $TdReceipt }
+$argsList = @(
+    "-NoProfile",
+    "-ExecutionPolicy", "Bypass",
+    "-File", $collector
+)
+if ($SelfTest) {
+    $argsList += "-SelfTest"
+} else {
+    $argsList += @(
+        "-HostPort", $HostPort,
+        "-DebugPort", $DebugPort,
+        "-DurationSeconds", $DurationSeconds,
+        "-OutputDir", $OutputDir,
+        "-Profile", $Profile,
+        "-Bitstream", $bitstreamPath,
+        "-TdReceipt", $tdReceiptPath
+    )
+}
+& "$PSHOME\powershell.exe" @argsList
+if ($LASTEXITCODE -ne 0) {
+    exit $LASTEXITCODE
+}
+'@
+Set-Content -LiteralPath (Join-Path $stage "collect.ps1") -Encoding UTF8 -Value $shortcut
+
 $template = @'
 $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__
+& "$PSHOME\powershell.exe" -NoProfile -ExecutionPolicy Bypass -File .\collect.ps1 -HostPort COM8 -DebugPort COM7 -DurationSeconds 180 -OutputDir .\evidence-com8-host-com7-debug -Profile __PROFILE__ -Bitstream .\j6tmp.bit -TdReceipt .\td.json
 '@
 '@
-$template = $template.Replace("__PROFILE__", $Profile).Replace("__BITSTREAM__", $bitName).Replace("__TD_RECEIPT__", $tdName)
+$template = $template.Replace("__PROFILE__", $Profile)
 Set-Content -LiteralPath (Join-Path $stage "commands\collect-template.ps1") -Encoding UTF8 -Value $template
 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)
+Set-Content -LiteralPath (Join-Path $stage "START-HERE.zh-CN.md") -Encoding UTF8 -Value (New-StartHereText $Profile $bitName $tdName $ShortBitName $ShortTdName)
 
 
 $hostControlCommands = @(
 $hostControlCommands = @(
     "SET PTC 01 10",
     "SET PTC 01 10",
@@ -213,9 +264,21 @@ $manifest = [ordered]@{
     diagnostic_scope = "host_sensor_real_fan_ptc_debug921"
     diagnostic_scope = "host_sensor_real_fan_ptc_debug921"
     pin_profile = $Profile
     pin_profile = $Profile
     programming_mode = "PROGRAM_SRAM"
     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 }
+    bitstream = [ordered]@{ path = $ShortBitName; sha256 = Get-Sha256 (Join-Path $stage $ShortBitName) }
+    td_receipt = [ordered]@{ path = $ShortTdName; sha256 = Get-Sha256 (Join-Path $stage $ShortTdName) }
+    short_path_aliases = [ordered]@{
+        bitstream = [ordered]@{
+            path = $ShortBitName
+            source = "bitstreams/$bitName"
+            sha256 = Get-Sha256 (Join-Path $stage $ShortBitName)
+        }
+        td_receipt = [ordered]@{
+            path = $ShortTdName
+            source = "td-receipts/$tdName"
+            sha256 = Get-Sha256 (Join-Path $stage $ShortTdName)
+        }
+    }
+    collector = [ordered]@{ path = "collector/collect-j6-host-sensor-real-fan-ptc.ps1"; shortcut = "collect.ps1"; profile_argument = $Profile }
     host_control_commands = $hostControlCommands
     host_control_commands = $hostControlCommands
     startup_preflight = [ordered]@{
     startup_preflight = [ordered]@{
         expected_artifact = "startup-preflight.json"
         expected_artifact = "startup-preflight.json"