Skip to content

fix backup GPT partition entries offset to respect UEFI minimum array size#128

Open
andiradulescu wants to merge 1 commit intocommaai:masterfrom
andiradulescu:fix/backup-gpt-min-array-size
Open

fix backup GPT partition entries offset to respect UEFI minimum array size#128
andiradulescu wants to merge 1 commit intocommaai:masterfrom
andiradulescu:fix/backup-gpt-min-array-size

Conversation

@andiradulescu
Copy link
Copy Markdown
Contributor

Fixes [gpt] Partition entries CRC32 mismatch warnings seen after repairGpt.

asAlternate() computed the backup partEntriesStartLba using only the actual entry count (e.g. 64 entries = 2 sectors at 4096-byte sectors), but the UEFI spec and Qualcomm's fixgpt both reserve a minimum of 16,384 bytes (4 sectors). This placed the backup entries at the wrong offset, causing a stale partEntriesCrc32 in the backup header.

GPT images only contain the primary table. repairGpt creates the backup via asAlternate(), which now uses Math.max(numPartEntries * partEntrySize, 16384) to respect the UEFI minimum, matching ABL's MIN_PARTITION_ARRAY_SIZE = 0x4000.

Test plan

  • repairgpt on LUN 4 (64 entries), verified no CRC mismatch via getactiveslot
  • bun test passes
  • bun lint passes

@andiradulescu andiradulescu marked this pull request as ready for review March 25, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant