浏览代码

feat(gui): adapt 6400-v2 to 35 PTC channels and 94-byte telemetry

Prod2U Recovery 1 月之前
父节点
当前提交
feb3f2cb69

+ 1 - 0
generated/6400_v2/contract-sha256.txt

@@ -0,0 +1 @@
+db49ddaf44048113b956b7ff5c366943164c9c25d71697d455703cd35a5d8f3d

+ 343 - 0
generated/6400_v2/manual-uart-contract.json

@@ -0,0 +1,343 @@
+{
+  "board": "FCB V2.0",
+  "contract_sha256": "db49ddaf44048113b956b7ff5c366943164c9c25d71697d455703cd35a5d8f3d",
+  "device": "EF2L45BG256B",
+  "outputs": {
+    "default_front_percent": 20,
+    "default_ptc_percent": 0,
+    "default_rear_percent": 20,
+    "fan_board_invert_mask": 255,
+    "fan_board_invert_mask_is_the_only_inversion_point": true,
+    "fan_duty_is_not_rpm_or_airflow": true,
+    "fan_duty_semantics": "connector_requested_duty_percent",
+    "fan_pwm_hz": 500,
+    "front_fan_count": 4,
+    "front_fan_order": [
+      {
+        "ball": "P12",
+        "connector": "CON155.5",
+        "index": 0
+      },
+      {
+        "ball": "D8",
+        "connector": "CON155.11",
+        "index": 1
+      },
+      {
+        "ball": "C4",
+        "connector": "CON154.5",
+        "index": 2
+      },
+      {
+        "ball": "B1",
+        "connector": "CON154.11",
+        "index": 3
+      }
+    ],
+    "ptc_active_level": "high",
+    "ptc_count": 35,
+    "ptc_pwm_hz": 500,
+    "rear_fan_count": 4,
+    "rear_fan_order": [
+      {
+        "ball": "A10",
+        "connector": "CON155.6",
+        "index": 0
+      },
+      {
+        "ball": "C7",
+        "connector": "CON155.12",
+        "index": 1
+      },
+      {
+        "ball": "B5",
+        "connector": "CON154.6",
+        "index": 2
+      },
+      {
+        "ball": "A14",
+        "connector": "CON154.12",
+        "index": 3
+      }
+    ]
+  },
+  "product": "6400-v2",
+  "schema": "prod2u-6400-manual-uart-v4-8bit",
+  "snapshot": {
+    "byte_order": "little",
+    "contract_sha256": "db49ddaf44048113b956b7ff5c366943164c9c25d71697d455703cd35a5d8f3d",
+    "fields": {
+      "bmc_temp_c": {
+        "count": 24,
+        "name": "bmc_temp_c",
+        "offset": 43,
+        "size": 24,
+        "source": "bmc_ascii",
+        "type": "u8",
+        "unit": "celsius"
+      },
+      "ct_temp_c": {
+        "count": 27,
+        "name": "ct_temp_c",
+        "offset": 67,
+        "size": 27,
+        "source": "ct7428_i2c",
+        "type": "u8",
+        "unit": "celsius"
+      },
+      "front_fan_percent": {
+        "count": 4,
+        "name": "front_fan_percent",
+        "offset": 35,
+        "semantics": "connector_side_currently_effective_output",
+        "size": 4,
+        "type": "u8",
+        "unit": "percent"
+      },
+      "ptc_percent": {
+        "count": 35,
+        "name": "ptc_percent",
+        "offset": 0,
+        "semantics": "currently_effective_output",
+        "size": 35,
+        "type": "u8",
+        "unit": "percent"
+      },
+      "rear_fan_percent": {
+        "count": 4,
+        "name": "rear_fan_percent",
+        "offset": 39,
+        "semantics": "connector_side_currently_effective_output",
+        "size": 4,
+        "type": "u8",
+        "unit": "percent"
+      }
+    },
+    "length": 94,
+    "output_defaults": {
+      "front_fan_percent": 20,
+      "note": "Defaults apply after reset, at boot, in standby and whenever the watchdog has expired without a genuinely applied new SET. GET must return these defaults after expiry, never a stale bank.",
+      "ptc_percent": 0,
+      "rear_fan_percent": 20
+    },
+    "payload_length": 94,
+    "payload_type": 66,
+    "schema": "prod2u-6400-get-data-v1",
+    "temperature_encoding": {
+      "ff00_is_not_invalid": true,
+      "host_side_scaling": "none",
+      "invalid": 255,
+      "low_byte_truncation_of_16_bit_raw": "forbidden",
+      "negative_never_becomes_valid_zero": true,
+      "reject_before_truncation": [
+        "negative",
+        "at_or_above_255",
+        "acquisition_failure",
+        "never_sampled",
+        "untrusted_source"
+      ],
+      "representation": "uint8_celsius",
+      "rounding": "truncate_fractional_part",
+      "sdk_mapping": "None if byte == 0xFF else byte",
+      "two_byte_temperature_output": "forbidden",
+      "valid_range": [
+        0,
+        254
+      ]
+    }
+  },
+  "temperature": {
+    "bmc_channels": 24,
+    "conversion_runs_on": "cpld",
+    "ct_channels": 27,
+    "encoding": "uint8_celsius",
+    "semantics": "acquisition_only_never_decides_any_output"
+  },
+  "watchdog": {
+    "feed_on": [
+      "successful_set_accept",
+      "legal_get_accept"
+    ],
+    "seconds": 30
+  },
+  "wire": {
+    "bmc_uart": {
+      "baud": 115200,
+      "clks_per_bit": 217,
+      "format": "8N1",
+      "optional": true,
+      "poll_ascii": "ipmitool raw 0x36 0x6c 0xdf 0xdd 0x00 0x03",
+      "poll_command_bytes": 43,
+      "poll_line_terminator": 10,
+      "response_hex_tokens": 48,
+      "response_lines_typical": 3,
+      "response_pairs": 24,
+      "rs232": {
+        "connector": "CON77",
+        "rx_ball": "M9",
+        "rx_connector_pin": 2,
+        "status": "confirmed",
+        "tx_ball": "L10",
+        "tx_connector_pin": 1
+      },
+      "set_all_allowed_without_bmc": true
+    },
+    "commands": {
+      "GET_ALL": {
+        "data_is_not_an_ack": true,
+        "feeds_watchdog": true,
+        "payload_length": 0,
+        "response": [
+          "GET_ACK",
+          "GET_DATA"
+        ],
+        "response_order": "ack_then_data_contiguous_group",
+        "type": 2
+      },
+      "HEARTBEAT": {
+        "feeds_watchdog": true,
+        "note": "Simplest independent heartbeat ping for physical link health verification. Immediately acknowledged without touching thermal banks. Payload can be 0 or 4 (nonce). If 4-byte nonce provided, HEARTBEAT_ACK echoes it.",
+        "payload_length": "0_or_4",
+        "response": "HEARTBEAT_ACK",
+        "type": 3
+      },
+      "SET_ALL": {
+        "admission": "SET_ACCEPT_after_validation_and_reservation",
+        "fan_duty_meaning": "connector_requested_duty_not_rpm_not_airflow",
+        "feeds_watchdog": true,
+        "payload_fields": [
+          {
+            "count": 35,
+            "maximum": 100,
+            "minimum": 0,
+            "name": "ptc_duty_percent",
+            "offset": 0,
+            "unit": "percent"
+          },
+          {
+            "count": 4,
+            "maximum": 100,
+            "minimum": 0,
+            "name": "front_fan_duty_percent",
+            "offset": 35,
+            "unit": "percent"
+          },
+          {
+            "count": 4,
+            "maximum": 100,
+            "minimum": 0,
+            "name": "rear_fan_duty_percent",
+            "offset": 39,
+            "unit": "percent"
+          }
+        ],
+        "payload_length": 43,
+        "response": "SET_ACK",
+        "type": 1
+      },
+      "UNLISTED_TYPES": "UNSUPPORTED"
+    },
+    "host_uart": {
+      "baud": 921600,
+      "conflict_detection": "none",
+      "exact_baud": {
+        "div": 15625,
+        "mul": 576,
+        "relation": "clock_hz_times_mul_over_div_equals_baud"
+      },
+      "fair_arbitration": "none",
+      "fixed_candidate_clks_per_bit": 27,
+      "format": "8N1",
+      "rs232": {
+        "connector": "CON134",
+        "rx_ball": "R13",
+        "rx_connector_pin": 2,
+        "status": "confirmed",
+        "tx_ball": "T14",
+        "tx_connector_pin": 1
+      },
+      "source_select": "minimal_rx_source_select_with_broadcast_tx",
+      "ttl": {
+        "connector": "CON12",
+        "level": "LVCMOS33",
+        "note": "6400 V2.0 external STM32H7 TTL binding on CON12. This is a UART-only binding; the product has no host register interface and no other host bus.",
+        "rx_ball": "J4",
+        "rx_connector_pin": 4,
+        "status": "confirmed",
+        "tx_ball": "K2",
+        "tx_connector_pin": 3
+      }
+    },
+    "inter_byte_timeout_clks": 250000,
+    "inter_byte_timeout_us": 10000,
+    "responses": {
+      "BEACON": {
+        "autonomous": true,
+        "feeds_watchdog": false,
+        "payload_length": 0,
+        "type": 81
+      },
+      "GET_ACK": {
+        "payload_length": 0,
+        "type": 130
+      },
+      "GET_DATA": {
+        "payload_contract": "6400-snapshot.yaml",
+        "payload_length": 94,
+        "type": 66
+      },
+      "HEARTBEAT_ACK": {
+        "payload_length": "0_or_4",
+        "type": 131
+      },
+      "MOTOR_DONE": {
+        "product_behavior": "NOT_PRESENT",
+        "type": 80
+      },
+      "NACK": {
+        "no_detail_strings": true,
+        "no_extra_fault_state": true,
+        "no_field_index": true,
+        "payload": [
+          "request_type",
+          "reason"
+        ],
+        "payload_length": 2,
+        "reason": {
+          "BAD_LENGTH": 2,
+          "BAD_VALUE": 3,
+          "BUSY": 5,
+          "QUEUE_FULL": 4,
+          "UNSUPPORTED": 1
+        },
+        "type": 192
+      },
+      "RESPONSE_TYPES_ARE_REQUESTS": "UNSUPPORTED",
+      "SET_ACK": {
+        "payload_length": 0,
+        "type": 129
+      }
+    },
+    "uart": {
+      "baud": 921600,
+      "crc": "CRC-16/CCITT-FALSE",
+      "format": "8N1",
+      "get_ack_type": 130,
+      "get_all_type": 2,
+      "get_data_payload_bytes": 94,
+      "get_data_type": 66,
+      "header": [
+        165,
+        90
+      ],
+      "length_width_bits": 8,
+      "motor_done_type": 80,
+      "nack_type": 192,
+      "response_types_are_requests": "UNSUPPORTED",
+      "set_ack_type": 129,
+      "set_all_payload_bytes": 43,
+      "set_all_type": 1,
+      "unlisted_types": "UNSUPPORTED"
+    }
+  }
+}

+ 1 - 1
tools/6400_v2_hex_gui.py

@@ -17,7 +17,7 @@ METADATA = MODEL.metadata
 GOLDEN = json_golden = {
     "contract_sha256": CONTRACT.get("contract_sha256"),
     "frames": {
-        "set_all_safe": "A5 5A 01 20 " + "00 " * 24 + "14 " * 8,  # PTC=0%, Front=20%, Rear=20%
+        "set_all_safe": "A5 5A 01 2B " + "00 " * 35 + "14 " * 8,  # PTC=0% (35ch), Front=20% (4ch), Rear=20% (4ch)
         "get_all": "A5 5A 02 00 6D 7B",
         "set_all_ack": "A5 5A 81 00 A6 35",
         "get_ack": "A5 5A 82 00 F5 60",

+ 14 - 7
tools/_vendor/prod2u_status.py

@@ -18,14 +18,21 @@ def decode_temperature(byte: int) -> int | None:
 
 def state_6400(payload: bytes | bytearray, layout: dict[str, Any] | None = None) -> dict[str, Any]:
     p = bytes(payload)
-    if len(p) != 83:
-        raise ValueError(f"6400 GET_DATA payload length must be 83, got {len(p)}")
-    ptc = list(p[0:24])
-    front = list(p[24:28])
-    rear = list(p[28:32])
-    bmc_raw = list(p[32:56])
+    if len(p) == 94:
+        ptc = list(p[0:35])
+        front = list(p[35:39])
+        rear = list(p[39:43])
+        bmc_raw = list(p[43:67])
+        ct_raw = list(p[67:94])
+    elif len(p) == 83:
+        ptc = list(p[0:24])
+        front = list(p[24:28])
+        rear = list(p[28:32])
+        bmc_raw = list(p[32:56])
+        ct_raw = list(p[56:83])
+    else:
+        raise ValueError(f"6400 GET_DATA payload length must be 83 or 94, got {len(p)}")
     bmc_temps = [decode_temperature(b) for b in bmc_raw]
-    ct_raw = list(p[56:83])
     ct_temps = [decode_temperature(b) for b in ct_raw]
     return {
         "product": "6400-front-rear",

+ 6 - 6
tools/build_windows_exes_remote.py

@@ -31,13 +31,13 @@ PRODUCTS = {
         "exe_name": "Prod2U-6400-V2-GUI",
         "script": "tools/6400_v2_hex_gui.py",
         "board": "FCB V2.0",
-        "generated": "6400",
-        "bitstream": ROOT / "build/bitstreams/prod2u_6400_v2_20261020.bit",
-        "receipt": Path("/data/prod2u/cpld-runs/6400-v2-td-20261020T024100Z-39e3adf7/td-receipt.json"),
+        "generated": "6400_v2",
+        "bitstream": ROOT / "build/bitstreams/prod2u_6400_v2.bit",
+        "receipt": Path("/data/prod2u/cpld-runs/6400-v2-td-20261020T071349Z-d317191a/td-receipt.json"),
         "assets": [
-            ("generated/6400/manual-uart-contract.json", "generated/6400"),
-            ("generated/6400/golden-vectors.json", "generated/6400"),
-            ("contracts/ct7428-format.json", "generated/6400"),
+            ("generated/6400_v2/manual-uart-contract.json", "generated/6400_v2"),
+            ("generated/6400/golden-vectors.json", "generated/6400_v2"),
+            ("contracts/ct7428-format.json", "generated/6400_v2"),
         ],
     },
     "mrdimm-chamber": {

+ 3 - 3
tools/prod2u_gui.py

@@ -146,7 +146,7 @@ class Model:
             raise ValueError("未知产品: " + product)
         self.product = product
         self.motor = (product == "mrdimm-chamber")
-        self.folder = "mrdimm" if self.motor else "6400"
+        self.folder = "mrdimm" if self.motor else ("6400_v2" if product == "6400-v2" else "6400")
         filename = "snapshot-layout.json" if self.motor else "manual-uart-contract.json"
         self.contract = json.loads(self.asset(filename).read_text(encoding="utf-8"))
         self.wire = self.contract["control"]["wire"] if self.motor else self.contract["wire"]
@@ -459,7 +459,7 @@ def self_test(product: str) -> int:
     frame = model.set_all(values)
     parsed = decode_frame(frame)
     assert parsed.crc_ok
-    expected_len = 68 if model.motor else 32
+    expected_len = 68 if model.motor else sum(count for _, count, _ in model.groups())
     assert len(parsed.payload) == expected_len
     exp_set = model.explain(frame)
     assert exp_set["crc_ok"] is True
@@ -1087,7 +1087,7 @@ def run_gui(product: str) -> int:
                                 lines.append(" | ".join(f"PTC{c+j:02d}:{v:3d}%" for j, v in enumerate(chunk)))
                             front_d = st.get("front", [])
                             rear_d = st.get("rear", [])
-                            lbl_realtime_ptc.config(text=f"【PTC 生效占空比 (共24路)】:\n  " + "\n  ".join(lines) + f"\n【风扇占空比】: Front={front_d} | Rear={rear_d}")
+                            lbl_realtime_ptc.config(text=f"【PTC 生效占空比 (共{len(ptc_d)}路)】:\n  " + "\n  ".join(lines) + f"\n【风扇占空比】: Front={front_d} | Rear={rear_d}")
                     lbl_realtime_stat.config(text=summary)
                     # Also update TAB 3 output
                     do_parse_get_resp(frame_hex(frame_data))