本文定义 binary921 HostPort 与 DebugPort 的机器帧格式。它是 docs/j6-bmc-replay-binary921-architecture.zh-CN.md 的 wire-level 合同。
所有多字节整数使用 little-endian。CRC 使用 CRC16-CCITT,初值 0xffff,多项式 0x1021,覆盖 version 到 payload,不覆盖 magic 和 crc16 本身。
| 字段 | 字节数 | 说明 |
|---|---|---|
magic |
2 | 固定 a5 5a |
version |
1 | 当前 01 |
profile_id |
1 | 01=debug-photo-bmc-replay-binary921,02=formal-uart1-bmc-replay-binary921 |
frame_type |
1 | 见第 2 节 |
seq |
4 | little-endian 递增序号 |
timestamp_tick |
4 | little-endian CPLD tick |
payload_len |
1 | 0..255 |
payload |
N | 固定结构或 TLV |
crc16 |
2 | little-endian CRC16-CCITT |
decoder 必须支持流式重同步:遇到错误 magic、长度越界、CRC 错、version 不支持、unknown frame type 时丢弃当前候选帧并继续搜索下一处 a5 5a。validator 必须把这些错误计入 receipt,不能静默忽略。
| 值 | 名称 | 方向 | 用途 |
|---|---|---|---|
0x01 |
READY |
CPLD -> Host/Debug | epoch 起点 |
0x02 |
BMC_POLL |
CPLD -> Debug | CPLD 已向 BMC replay UART 发 poll |
0x03 |
BMC_PAYLOAD |
CPLD -> Debug | CPLD 收到并解析 replay payload |
0x04 |
SENSOR_CACHE |
CPLD -> Debug/Host response | 24 DIMM cache 摘要或分片 |
0x05 |
HOST_CMD |
Host -> CPLD 或 Debug echo | Host 控制命令 |
0x06 |
HOST_ACK |
CPLD -> Host/Debug | Host 命令 ACK/NACK |
0x07 |
PWM_STATE |
CPLD -> Debug | PTC/FAN PWM state |
0x08 |
PID_STATE |
CPLD -> Debug | PID requested/active boundary |
0x09 |
TIMEOUT_STATE |
CPLD -> Debug | 5 秒 Host timeout fallback |
0x0a |
PIN_PROFILE |
CPLD -> Debug | 当前 pin profile 和 remap 摘要 |
0x0b |
MODULE_SNAPSHOT |
CPLD -> Debug | 内部模块快照 |
0x0c |
ERROR_COUNTERS |
CPLD -> Debug | drop/error/bad-frame counters |
The production two-UART wrapper uses an internal configuration POR: reset stays active for 1024 sys_clk cycles at 25 MHz, and the production ADC does not expose an external sys_rst_n pin. The production runtime profile is profile_id=3.
READY payload is seven bytes and is emitted at the startup tick after STARTUP_DELAY_TICKS (production default 250000):
| offset | field | meaning |
|---|---|---|
| 0 | profile_id_payload |
Runtime profile ID, 0x03 for production Prod2U |
| 1..4 | BUILD_ID |
32-bit build identity, little-endian, from the top/core BUILD_ID parameter |
| 5 | por_reason |
0x01 = configuration POR |
| 6 | announcement_seq |
0-based startup announcement number |
The startup epoch is frame seq=1; the frame timestamp is the startup tick. To tolerate a receiver that begins reading shortly after SRAM configuration, the READY announcement is emitted at most three times with announcement_seq=0,1,2. Repeats retain seq=1, the same timestamp, profile, build identity, and POR reason; only announcement_seq changes, so the host can distinguish announcements without creating new fresh epochs.
HOST_CMD payload 固定 4 字节:
| offset | 字段 | 说明 |
|---|---|---|
| 0 | cmd_id |
见下表 |
| 1 | channel |
1-based;无通道命令为 0 |
| 2 | value |
百分比或 enable;无值命令为 0 |
| 3 | flags |
v1 固定 0 |
cmd_id |
名称 | 合法范围 |
|---|---|---|
0x20 |
SET_PTC |
channel=1..24,value=0..100 |
0x21 |
SET_FAN |
channel=1..4,value=0..100 |
0x22 |
GET_SENSOR |
channel=0,value=0 |
0x23 |
GET_MAP |
channel=0,value=0 |
0x24 |
GET_STATUS |
channel=0,value=0 |
0x25 |
SET_PID_REQUESTED |
channel=0,value=0/1 |
0x26 |
DISABLE |
channel=0,value=0 |
负向命令必须 NACK:
SET_PTC 的 channel=0 或 channel>24。SET_FAN 的 channel=0 或 channel>4。value>100。cmd_id。HOST_ACK payload 固定 8 字节:
| offset | 字段 | 说明 |
|---|---|---|
| 0 | ok |
1=accepted,0=rejected |
| 1 | cmd_id |
被响应的命令 |
| 2 | status_code |
见第 5 节 |
| 3 | channel |
被响应通道;无通道为 0 |
| 4 | value |
被应用值;无值为 0 |
| 5 | state_flags |
bit0=timeout_active, bit1=pid_requested, bit2=pid_active, bit3=disabled |
| 6..7 | applied_state_hash |
little-endian 16-bit 摘要 |
ACK 的帧级 seq 必须等于 Host command seq。collector 必须逐条匹配 seq/cmd_id/status_code/profile_id,不能把错后一条 ACK 归给下一条命令。
| 值 | 名称 | 含义 |
|---|---|---|
0x00 |
OK |
命令被接受 |
0x01 |
BAD_CHANNEL |
1-based 通道越界 |
0x02 |
BAD_VALUE |
百分比或 enable 值非法 |
0x03 |
BAD_LENGTH |
payload 长度错误 |
0x04 |
BAD_CRC |
CRC 错误 |
0x05 |
BAD_PROFILE |
profile_id 不匹配 |
0x06 |
BAD_COMMAND |
unknown command |
0x07 |
BUSY |
CPLD 当前不能接收命令 |
0x08 |
INTERNAL_ERROR |
内部错误,需要 DebugPort 进一步归因 |
BMC_PAYLOAD payload:
| offset | 字段 | 说明 |
|---|---|---|
| 0 | payload_seq_lsb |
replay payload seq 低 8 位 |
| 1 | byte_count |
v1 必须为 48 |
| 2 | valid_count |
0..24 |
| 3 | missing_count |
0..24 |
| 4..7 | payload_hash32 |
payload SHA256 前 32 bit,小端保存 |
| 8..N | payload_bytes |
可选,verbose 固件可包含 48 字节;验收固件可只发 hash 摘要 |
SENSOR_CACHE payload 可采用摘要或分片:
mode=0x00,含 valid/missing/error/hash。mode=0x01,含 snapshot_seq/chunk_index/chunk_count 和最多 48 字节 DIMM cache。validator 对 strict pass 至少要求能证明 24 个 DIMM 槽位都被覆盖;可以来自单帧完整 cache,也可以来自完整分片重组。
PWM_STATE 必须能证明:
PTC01=10%。PTC24=20%。FAN01=40%。FAN04=30%。DISABLE 或 timeout 后 PTC 全 0。PID_STATE 必须证明:
SET_PID_REQUESTED(enabled=1) 后 pid_requested=1。pid_active=0,不接管 PWM。SET_PID_REQUESTED(enabled=0) 后 requested 清零。TIMEOUT_STATE 必须证明:
timeout_active=1。PIN_PROFILE 必须至少编码:
profile_id。hardware_access_status。bmc_source。blocked_waiting_for_uart1_uart2_access 标记,直到可接性复核通过。PC decoder 负责把该帧展开成人读 pin map;CPLD 不拼接长文本。
MODULE_SNAPSHOT payload 头固定:
| offset | 字段 | 说明 |
|---|---|---|
| 0 | snapshot_group |
例如 UART/BMC/PWM/PID/TIMEOUT/CACHE |
| 1 | snapshot_seq |
8-bit,可回绕 |
| 2 | chunk_index |
从 0 开始 |
| 3 | chunk_count |
总分片数 |
| 4..N | chunk_payload |
固定结构字段 |
同一个 snapshot_seq 的 chunk 必须全部到齐且 CRC 正确。缺 chunk、重复 chunk、chunk_count 改变、跨 profile 混流都必须 blocked。
strict pass 必须同时满足:
status=pass 且 payload hash 匹配。not_run,不得写 pass。