Single-card flow; preflight sudo precondition + Ubuntu package install

This commit is contained in:
2026-09-26 17:27:35 +02:00
parent 4e53bd880c
commit 94818ebdec
3 changed files with 219 additions and 183 deletions
+45 -29
View File
@@ -1,6 +1,6 @@
# cmp170hx_check
Guided, one-card-at-a-time batch checker for **NVIDIA CMP 170HX** cards (PCI IDs `10de:20c2` / `10de:2082`) — verifies the PCIe capacitor mod, records PCIe bus health, backs up VBIOS, runs the cmpunlocker verification, and optionally stresses VRAM. Built for a 23-card run, with one folder + JSON report per card serial.
Single-card checker for **NVIDIA CMP 170HX** cards (PCI IDs `10de:20c2` / `10de:2082`) — run it **one card at a time**: it waits for the card, verifies the PCIe capacitor mod, records PCIe bus health, backs up VBIOS, runs the cmpunlocker verification, and optionally stresses VRAM. Each card gets its own folder + JSON report named by serial, so the folders accumulate as you go through your batch (e.g. 23 cards).
Reference harness (auto-cloned into `harness/` by preflight):
@@ -9,36 +9,51 @@ Reference harness (auto-cloned into `harness/` by preflight):
## Requirements
- Linux x86-64, Python 3.8+
- `pciutils` (`lspci`, `setpci`) — auto-installed if a package manager is present
- Root (`sudo`) for: PCI bus rescan, link retrain, sysfs ROM read, `dmesg`, `verify.sh`
- NVIDIA driver with `nvidia-smi` (nvidia-open 610.xx+, see cmpunlocker) for unlock verification
- Linux x86-64 (tested target: **Ubuntu 26.04**), Python 3.8+
- **sudo privileges** — precondition for `--preflight` package installation and for privileged checks (PCI rescan, link retrain, sysfs ROM, `dmesg`, `verify.sh`)
- `pciutils` (`lspci`, `setpci`), `git` — installed automatically by preflight
- NVIDIA driver with `nvidia-smi` (nvidia-open 610.xx+, see cmpunlocker) for unlock verification — preflight can install it for you (asks first)
- `nvflash` (not packaged — download from NVIDIA or pass `--nvflash /path/to/nvflash`) for VBIOS backup and serial auto-read
- Optional: `vkmark` or `vulkan-tools` for the 5-minute VRAM stress test
Missing tools are reported by preflight; packages are auto-installed where possible, otherwise instructions are printed.
## Usage
## Preflight (setup step)
```bash
python3 check_cards.py # full run, 23 cards, guided
python3 check_cards.py --preflight # tool check / install / harness clone only
python3 check_cards.py --preflight
```
On Ubuntu 26.04 this:
1. **Checks the sudo precondition** — runs `sudo -v` if needed so credentials are cached; if sudo is unavailable it prints the fix and **does not install anything** (exit code 3 if blocking tools are still missing)
2. Installs required packages via `apt-get update && apt-get install`: `git`, `pciutils`, `vulkan-tools`, `vkmark`
3. Offers to install the **NVIDIA driver** (`ubuntu-drivers install`, falling back to the `nvidia-driver` metapackage) when `nvidia-smi` is missing — reboot afterwards
4. Clones the two harness repos into `harness/`
5. Prints a tool status table; `nvflash` is reported with manual-install instructions (not packaged)
Skip installation with `--no-install` (no sudo needed at all).
## Usage (one card per run)
```bash
python3 check_cards.py # check the connected card
python3 check_cards.py --preflight # setup: tools, packages, harness clone
python3 check_cards.py --demo # self-test with fake hardware (no GPU needed)
python3 check_cards.py --help # all flags
```
Normal run flow, repeated per card:
Flow of a normal run:
1. `Insert card N/23, then press Enter` (`s` = skip, `q` = quit)
2. GPU auto-detected on the bus (PCI rescan retry offered if absent)
3. Serial auto-read from nvflash UUID; falls back to a manual label prompt
4. VBIOS backup → `cards/<serial>/bios.rom` (nvflash, sysfs ROM fallback)
5. PCIe checks: link speed/width, AER counters, full config-space dump
6. Link retrain test + full bus rescan test (device must survive both)
7. Kernel log scrape (`dmesg`/`journalctl`) for this BDF: Xid / AER / NVRM lines
8. `nvidia-smi` snapshot + `harness/cmpunlocker/verify.sh` (read-only)
9. **Last step, optional**: `Run 5-min Vulkan VRAM stress test now? (y/N)` — refused by default, `--vulkan always|never` to override
10. Result + `report.json` written; progress saved to `progress.json` (resumable)
1. Waits for a CMP 170HX on the bus — prompts you to insert/reseat the card, Enter triggers a PCI rescan (`q` quits)
2. Serial auto-read from nvflash UUID; falls back to a manual label prompt
3. VBIOS backup → `cards/<serial>/bios.rom` (nvflash, sysfs ROM fallback)
4. PCIe checks: link speed/width, AER counters, full config-space dump
5. Link retrain test + full bus rescan test (device must survive both)
6. Kernel log scrape (`dmesg`/`journalctl`) for this BDF: Xid / AER / NVRM lines
7. `nvidia-smi` snapshot + `harness/cmpunlocker/verify.sh` (read-only)
8. **Last step, optional**: `Run 5-min Vulkan VRAM stress test now? (y/N)` — refused by default, `--vulkan always|never` to override
9. Result printed + `report.json` written into the card's folder
Remove the card, plug the next one, repeat — no queue, no indices, folders just pile up in `cards/`.
## Checks & scoring (lenient)
@@ -48,6 +63,8 @@ Normal run flow, repeated per card:
| **WARN** | link width ≠ `x16` (capacitor mod missing/incomplete), Gen1 only (Gen2 unlock patch not active), correctable AER errors, kernel errors / Xid, VBIOS backup failed, cmpunlocker verify not `unlocked-ok`, errors during VRAM stress |
| **PASS** | everything clean |
Exit codes: `0` PASS/WARN · `1` FAIL · `2` no card found · `3` preflight blocking failure.
## Output
```
@@ -61,22 +78,21 @@ cards/
├── config_space.hex # lspci -nnvvxxxx full hex dump
├── dmesg.log # kernel lines related to this card
└── verify_unlocker.log # cmpunlocker verify.sh output
progress.json # which card indices are done (resume support)
```
## Useful flags
## Flags
| Flag | Meaning |
|------|---------|
| `--cards N` / `--start N` | total cards (default 23) / first index |
| `--preflight` | setup only: sudo precondition + package install + harness clone, then exit |
| `--demo` | run the whole pipeline against fake hardware (self-test) |
| `--nvflash PATH` | explicit nvflash binary |
| `--serial XYZ` | override serial for the next card |
| `--serial XYZ` | override serial (skips nvflash auto-read) |
| `--vulkan ask\|always\|never` | VRAM test policy (default: ask, last step) |
| `--skip-bios` | skip VBIOS backup |
| `--no-install` / `--no-clone` | don't auto-install packages / don't clone harness |
| `--restart` | ignore `progress.json` and start over |
| `--no-pause` | don't wait for the insert prompt |
| `--no-install` | never install packages (skips the sudo precondition) |
| `--no-clone` | don't clone the harness repos |
## Safety
This tool only **reads** card state: `verify.sh` is run without installing anything, no modules are patched, no firmware is flashed. The only writes are local files, PCI link retrain/rescan sysfs triggers, and your own reports.
This tool only **reads** card state: `verify.sh` is run without installing anything, no modules are patched, no firmware is flashed. The only writes are local files, PCI link retrain/rescan sysfs triggers, package installation during `--preflight` (explicitly gated behind the sudo precondition), and your own reports.