[PR #224] firmware: accept NvU64-word bindata arrays (615.71 codegen) in extract_boot_assets #239

Open
opened 2026-10-30 04:55:59 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Zagitta/gpu-unlock/pull/224
Author: @rahul05ranjan
Created: 10/27/2026
Status: 🔄 Open

Base: main ← Head: extract-u64-codegen


📝 Commits (2)

  • cc48855 firmware: accept NvU64-word bindata arrays from 615.71 codegen
  • 6afd57c tests: cover both bindata codegen styles in extract_boot_assets

📊 Changes

2 files changed (+154 additions, -3 deletions)

View changed files

📝 firmware/extract_boot_assets.py (+18 -3)
➕ tests/firmware/test_extract_boot_assets.py (+136 -0)

📄 Description

Problem

firmware/extract_boot_assets.py only understands the bindata codegen of the pinned 610.43.03 tree: one 0xNN byte token per array element. As documented in #168, the generated sources of newer drivers (615.71.10) changed:

  1. arrays are emitted as NV_DECLARE_ALIGNED(NvU64, 8) with 0x........ULL word tokens, which the byte-token check rejects with non-byte token in generated array;
  2. the u64 expansion pads the array up to a whole number of 8-byte words, so even after decoding the words the array is longer than the COMPRESSED SIZE (bytes) / DATA SIZE (bytes) declared in the surrounding comment, and the exact-length check fails with compressed storage size mismatch.

So the same tool cannot rebuild the boot assets from a 615.71.10 tree without hand-editing.

Change

_array_bytes() now accepts both token styles:

  • all-byte tokens decode as before (610.43.03 trees are untouched);
  • all-NvU64 tokens (0x..ULL, 1..16 hex digits) decode with struct.pack("<Q", ...) as in #168;
  • after decoding, an array longer than the declared storage size is accepted only when the excess is all zero (the alignment padding), and truncated back to the declared size. A short array, a non-zero tail, mixed or oversized tokens are rejected exactly as before.

Nothing else in the extraction pipeline changed.

Verification

  • Real 610.43.03 inputs (the exact tarball make inputs fetches): extracted all 10 boot assets with both HEAD and this patch; SHA-256 of every output is identical (no regression).
  • New tests/firmware/test_extract_boot_assets.py (stdlib only, python3 tests/firmware/test_extract_boot_assets.py): byte-style and u64-style fixtures, compressed and uncompressed, padding truncated when zero and rejected when non-zero, mixed/oversized tokens and short arrays still rejected. It passes with this patch; on HEAD it fails at the first u64 case with non-byte token in generated array.
  • A 615.71.10 driver tree is not available on this host, so the u64 fixtures were generated to match the codegen description in #168; end-to-end extraction with a real 615 tree is still maintainer-verifiable with make firmware after repointing NV.

Fixes #168


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Zagitta/gpu-unlock/pull/224 **Author:** [@rahul05ranjan](https://github.com/rahul05ranjan) **Created:** 10/27/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `extract-u64-codegen` --- ### 📝 Commits (2) - [`cc48855`](https://github.com/Zagitta/gpu-unlock/commit/cc48855216e6b3b0849b75c259055726e4922c22) firmware: accept NvU64-word bindata arrays from 615.71 codegen - [`6afd57c`](https://github.com/Zagitta/gpu-unlock/commit/6afd57c8e808970a50c4771292150570fc2e1ce4) tests: cover both bindata codegen styles in extract_boot_assets ### 📊 Changes **2 files changed** (+154 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `firmware/extract_boot_assets.py` (+18 -3) ➕ `tests/firmware/test_extract_boot_assets.py` (+136 -0) </details> ### 📄 Description ## Problem `firmware/extract_boot_assets.py` only understands the bindata codegen of the pinned 610.43.03 tree: one `0xNN` byte token per array element. As documented in #168, the generated sources of newer drivers (615.71.10) changed: 1. arrays are emitted as `NV_DECLARE_ALIGNED(NvU64, 8)` with `0x........ULL` word tokens, which the byte-token check rejects with `non-byte token in generated array`; 2. the u64 expansion pads the array up to a whole number of 8-byte words, so even after decoding the words the array is longer than the `COMPRESSED SIZE (bytes)` / `DATA SIZE (bytes)` declared in the surrounding comment, and the exact-length check fails with `compressed storage size mismatch`. So the same tool cannot rebuild the boot assets from a 615.71.10 tree without hand-editing. ## Change `_array_bytes()` now accepts both token styles: - all-byte tokens decode as before (610.43.03 trees are untouched); - all-`NvU64` tokens (`0x..ULL`, 1..16 hex digits) decode with `struct.pack("<Q", ...)` as in #168; - after decoding, an array longer than the declared storage size is accepted only when the excess is all zero (the alignment padding), and truncated back to the declared size. A short array, a non-zero tail, mixed or oversized tokens are rejected exactly as before. Nothing else in the extraction pipeline changed. ## Verification - Real 610.43.03 inputs (the exact tarball `make inputs` fetches): extracted all 10 boot assets with both HEAD and this patch; SHA-256 of every output is identical (no regression). - New `tests/firmware/test_extract_boot_assets.py` (stdlib only, `python3 tests/firmware/test_extract_boot_assets.py`): byte-style and u64-style fixtures, compressed and uncompressed, padding truncated when zero and rejected when non-zero, mixed/oversized tokens and short arrays still rejected. It passes with this patch; on HEAD it fails at the first u64 case with `non-byte token in generated array`. - A 615.71.10 driver tree is not available on this host, so the u64 fixtures were generated to match the codegen description in #168; end-to-end extraction with a real 615 tree is still maintainer-verifiable with `make firmware` after repointing `NV`. Fixes #168 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Zagitta/gpu-unlock#239
No description provided.