feat(margin): Save every LTC2977 in one command, and stop lying about failures
margin_save discarded the result of every write, so a NACK printed
"Change Saved" exactly like a successful store. For the one permanent
operation in this tool that is the worst place to stay quiet. Each store
is now checked, named on failure, and reflected in the exit code.
STORE_USER_ALL also went out as 0x15 followed by a dummy 0x00 - an SMBus
write-byte where the command is a send-byte. The LTC2977 tolerated it,
but tolerance is not correctness. Now i2cset ... 0x15 c on the native
path and a no-data cb_pmbus_write on the FPGA path.
Two new subcommands:
margin_save all - all nine boards in settings/, then re-init
whichever board was loaded beforehand so a
following margin_status still reports the board
you were looking at. Does not stop on the first
failure; a half-saved set is harder to reason
about than a fully-attempted one.
margin_save blanton - this platform exposes the CB FPGA F3 I2C
channels as native Linux i2c buses (Ch6->13,
Ch7->14, Ch8->15, Ch9->16; CB stays on bus 4),
so all 18 LTC2977 can be stored with plain
i2cset: no margin_init, no FPGA channel setup,
no pcimem. 18 commands instead of 42.
The 18 raw commands were verified on the DUT 2026-08-27; the wrapper was
tested against stubbed hardware only. Release notes say so.
Board list is MARGIN_BLANTON_STORE at the top of margin.sh - comment out
what this DUT does not have rather than letting it talk to absent boards.
Missing bus and unresponsive chip are reported as distinct failures.
MARGIN_STORE_SETTLE (0.5s) sits between stores because nothing here polls
the part's busy bit, and blanton fires 18 in a row.
Script A -> V1.0.11.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014RetWKFZFG1ZHcitQAyhwM
This commit is contained in:
+27
-1
@@ -192,6 +192,7 @@ Blanton_TTL_Script/
|
||||
│ # ↑ 三支都要 chmod +x 才能跑(見 Key Constraints)
|
||||
└── LTC2980_Margin_Script/ # 電壓 margin 子專案(另有獨立 repo)
|
||||
├── margin.sh # margin_init/status/set/apply_profile/save
|
||||
# # v2.7.0:margin_save all / margin_save blanton
|
||||
├── settings/*.conf # 一個 .conf = 一顆 LTC2980(CB + SWB0/1 × CONN13~16)
|
||||
├── profiles/*.conf # 16-ch 批次組合(comboA/B、high3/5、low3/5、normal、off)
|
||||
├── script/*_all.sh # 跨 9 顆 LTC2980 的批次 status / apply / save
|
||||
@@ -251,6 +252,21 @@ Channel 定址:`ch / 8` → `CHIPS[]` index,`ch % 8` → LTC2977 PMBus PAGE
|
||||
> 同一顆 LTC2980 的兩個位址**相差 2**(7-bit,由規格書 8-bit 配對除以 2 而來),不是 1。
|
||||
> 兩張板共用一條通道,所以同通道上的位址必須互斥 —— 上表兩組(`0x5C/0x5E` 與 `0x62/0x64`)不重疊。
|
||||
|
||||
**同一批 LTC2977 也掛在原生 i2c bus 上**(2026-08-27 上機驗證):Blanton 的 SONiC 把 CB FPGA F3
|
||||
的這四條 I2C 通道同時註冊成 kernel i2c adapter,因此除了 `cb_pmbus_*` → pcimem 這條路,
|
||||
還可以用 `i2cset -f -y <bus>` 直接打到同一顆晶片:
|
||||
|
||||
| FPGA F3 通道 | Linux bus | CB FPGA 路徑 | 原生 i2c 路徑 |
|
||||
|---|---|---|---|
|
||||
| Ch6 | 13 | `cb_pmbus_write 6 <addr> …` | `i2cset -f -y 13 <addr> …` |
|
||||
| Ch7 | 14 | `cb_pmbus_write 7 <addr> …` | `i2cset -f -y 14 <addr> …` |
|
||||
| Ch8 | 15 | `cb_pmbus_write 8 <addr> …` | `i2cset -f -y 15 <addr> …` |
|
||||
| Ch9 | 16 | `cb_pmbus_write 9 <addr> …` | `i2cset -f -y 16 <addr> …` |
|
||||
|
||||
`margin.sh` 的 `margin_save blanton` 走原生路徑(`MARGIN_BLANTON_STORE` 表),
|
||||
其餘功能仍走 `TRANSPORT="swb"` 的 FPGA 路徑。兩條路到的是同一顆 LTC2977,
|
||||
**不要同時用**(同一條匯流排上兩個 master 語意的存取)。
|
||||
|
||||
**全通道 net / 電壓對照:`docs/LTC2980_channel_map.csv`**(9 個 `.conf` × 16ch = 144 列,
|
||||
欄位 `Board,CONN,Ch,NetName,Vnom`)。查「某個 net 在哪片哪個 channel」比翻 9 個 `.conf` 快。
|
||||
CSV 是產出物,不是正本 —— 改完 `.conf` 用 `./tools/gen_channel_map.sh` 重產,別手改 CSV。
|
||||
@@ -330,6 +346,7 @@ PROFILE_CHANNELS=( "0:high:8" "1:low:8" ... ) # "channel:operation:change_perc
|
||||
| **溫度** | `temp_cb` / `temp_icb` / `temp_all` | TMP75(12-bit 左靠齊 ×0.0625)、TMP432(含 RANGE bit 的 −64 偏移、remote1/2) |
|
||||
| **電源資料** | `pwr_data` / `pwr_data_pdb` / `pwr_pdb_id` | SWB VRM 全軌 Vin/Vout/Iout/Temp 對齊表;MP29816 解析度**執行期從 `MFR_VOUT_SCALE_LOOP` 讀**,不寫死 |
|
||||
| **電壓 Margin** | `margin_init/status/set/apply_profile/save` + `*_all.sh` | 9 顆 LTC2980(CB CONN13、SWB0/1 CONN13~16)批次 high/low margin 與狀態掃描。v2.6.0 起 SWB 路徑真正接上共用 cb_i2c 後端,並有 `margin_swb_info/probe/scan/reset/sem` 除錯包裝 |
|
||||
| **Margin 寫 NVM** | `margin_save` / `margin_save all` / `margin_save blanton` | ⚠️ 永久寫入。`0x15` 送 PMBus **send-byte**(不帶 data byte)。`all` = 依 `settings/` 走 9 顆、跑完還原原本載入的板子;`blanton` = 本平台捷徑,18 顆全走原生 i2c bus(`MARGIN_BLANTON_STORE` 表),不需 `margin_init`。每筆之間 `MARGIN_STORE_SETTLE`(0.5s),工具**不 poll busy bit** |
|
||||
| **管理網路 ping** | `mgmt_ping_monitor.sh {start\|stop\|status\|fg\|tail\|clear\|summary}` | 一輪 = 10G leg + 1G leg,各自 `ip address/route replace` 後 `ping -I <if>` 打自己的對端;兩張卡都保持 up。每 leg 記 `ip -s link show` 與該卡的 TX/RX packet delta,另出一行可 grep 的 `RESULT` |
|
||||
| **BMC 監控** | `bmc_monitor.sh {start\|stop\|status\|fg\|tail\|clear}` | 由 host 端 `bmc-manager run` 週期取樣 `free -m`,另加一組 **I2C 寫入/讀回圖樣測試**(bus 1、addr 0x41、offset 0x00C0,寫 `55AA55AA` 讀回、再寫 `AA55AA55` 讀回)。B 啟動、C 停止並 `cat log/bmc_poll.log` |
|
||||
| **BMC DDR 壓力** | `bmc_monitor_ddr.sh` | ⚠️ **已停用** —— B/C 內呼叫處已註解,改由 `bgctl run bmc-manager run memtester` 取代。檔案保留未刪 |
|
||||
@@ -435,6 +452,8 @@ pwr_data
|
||||
只吃 Sr;只有純暫存器裝置兩種都行。
|
||||
7. **`margin_save`(`STORE_USER_ALL`)會永久寫進 NVM**,斷電保留。測試流程中**絕不執行**,
|
||||
以免覆蓋客戶出廠 config。`margin.sh` 的 auto-enable 只改 RAM(`ON_OFF_CONFIG`),斷電復原。
|
||||
`margin_save all` / `margin_save blanton`(v2.7.0)一次對 9 顆 LTC2980(18 個 LTC2977)
|
||||
下同一道命令,風險同性質但範圍是全機;命令本身是 PMBus send-byte(`0x15`,不帶 data byte)。
|
||||
8. **操作硬體電壓有損壞 DUT 的風險**:套 profile 前先確認該軌 OV/UV limit 與 servo DAC 注入電阻
|
||||
有 populate(本板部分 margin 電阻標 PROTO,沒 populate 的軌電壓不會動)。
|
||||
9. **`ARB_LOST` 不等於裝置存在**:`vi2c_scan` 只看 `RX_ACK`,仲裁失敗會被誤報成「有裝置」。
|
||||
@@ -483,7 +502,7 @@ pwr_data
|
||||
| **客戶機密文件** | `docs/` 內 FPGA 規格(docx/xlsx/md)屬客戶 NDA 範圍;schematic 原始檔(`*.DSN`)一律 gitignore,不進 repo |
|
||||
| **Remote 限制** | 只推私有 remote:`nas`(`git.et-wen.com:51222`)+ `gitea`(`etgit.et-wen.com`)。**不設 GitHub `origin`** |
|
||||
| **測試 log** | `logs/*.log` 含 DUT 序號、MAC、韌體版本等可識別資訊 → gitignore,只保留目錄結構(`.gitkeep`) |
|
||||
| **破壞性硬體指令** | `margin_save` / `STORE_USER_ALL` 為永久 NVM 寫入,工具預設不呼叫;批次腳本 `margin_save_all.sh` 在 README 與腳本頂端都有警語 |
|
||||
| **破壞性硬體指令** | `margin_save` / `margin_save all` / `margin_save blanton` / `STORE_USER_ALL` 為永久 NVM 寫入,工具預設不呼叫;`margin_save all` 與批次腳本 `margin_save_all.sh` 在 README 與程式頂端都有警語 |
|
||||
| **root 權限** | 全流程在 `root@sonic:~#` 下執行(pcimem / i2c 需要);腳本不留任何 `chmod 777` 或放寬權限的動作 |
|
||||
| **For_AI/** | AI 協作素材(截圖、草稿筆記)整個資料夾 gitignore,避免不小心把客戶圖面帶進 repo |
|
||||
|
||||
@@ -756,6 +775,13 @@ margin status、全部 VRM 軌的 Vin/Vout/Iout/Temp、CB + ICB 溫感讀值,
|
||||
PktSize=324 PortList=1-259,270-565` 這組指令(含 `port all lb=mac` + `l2 learn off` 前置),
|
||||
目前只能手貼。它與 `blanton_traffic_linespeed` 是兩條互斥的打流路線(都會動 loopback 與 L2 學習),
|
||||
要腳本化的話得先決定兩者怎麼共存,不能同時跑。
|
||||
- **SWB 的 LTC2977 有兩條路可以到,目前工具兩條都在用**:`cb_pmbus_*`(CB FPGA F3 → pcimem)
|
||||
是 `margin_init` / `margin_status` / `margin_set` 走的路;原生 i2c bus(Ch+7 = bus 13/14/15/16)
|
||||
是 `margin_save blanton` 走的路。後者短很多 —— 不需要通道初始化、不需要 pcimem,
|
||||
單一 `i2cset` 就到。若原生 bus 在這平台夠穩,整個 `TRANSPORT="swb"` 層其實可以退成
|
||||
「bus 號不同的 i2c 路徑」,`_swb_*`、probe、semaphore、prescale 那整套都能拿掉。
|
||||
要動之前得先確認:讀取(`margin_status` 的 LINEAR16 word read)是否也同樣可靠,
|
||||
以及 kernel driver 有沒有搶著存取(`margin_save blanton` 帶 `-f` 就是為了繞過這件事)。
|
||||
- **`settings/` 裡 SWB0 與 SWB1 是兩份相同的資料**:8 個 `.conf` 中,SWB1 的四個除了 `CHIPS[]` 的
|
||||
bus 與 `CB_I2C_CH` 之外,net name 與 `VNOM` 與 SWB0 逐欄相同(見 `docs/LTC2980_channel_map.csv`)。
|
||||
改一邊忘了改另一邊不會有任何警告。可考慮改成「共用 net 定義 + 各自的 transport 覆寫」兩層檔案。
|
||||
|
||||
Reference in New Issue
Block a user