Skip to content

feat(gui): Add an optional testkey bootloader step to Firmware Flash - #96

Merged
miner7222 merged 1 commit into
mainfrom
feat/flash-optional-abl-bootloader
Sep 4, 2026
Merged

feat(gui): Add an optional testkey bootloader step to Firmware Flash#96
miner7222 merged 1 commit into
mainfrom
feat/flash-optional-abl-bootloader

Conversation

@miner7222

@miner7222 miner7222 commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Why

Installing testkey-signed firmware on a device whose bootloader trusts the Lenovo key previously meant downgrading the entire firmware first, just to get back to a bootloader that would accept the re-signed chain. That is slow, risky, and throws away the newer build the user actually wanted.

This lets the user hand LTBox a bootloader that still trusts the existing key. The run then re-signs the required partitions and flashes the supplied abl.elf at the end, so the device boots the new firmware without a full-firmware downgrade.

What changed

Firmware identity moves to the folder step. Pressing Next on the firmware folder now inspects vbmeta_system.img once, reports the signing key and the model from the build fingerprint in a dialog, and caches the verdict. The flash worker consumes that cached result instead of classifying the same image a second time. A folder whose vbmeta_system.img cannot be read blocks Next rather than failing later mid-run.

New optional bootloader step. It appears only when the firmware is Lenovo-key signed and the fingerprint is not TB323FU / TB376FC / TB390FU. The step indicator grows to seven entries only in that case. Picking an .elf extracts the AVB public key embedded in the ABL and labels it Test key / Lenovo key / Unknown; Next unlocks only for a test key, or when nothing is selected at all. Skipping the step leaves the run byte-for-byte identical to today.

Worker. With a user-supplied ABL the run takes the testkey re-sign path unconditionally and no longer dumps the device's own bootloader. It still reads device vbmeta_system, because the rollback-index floors from that dump are what keep the re-signed images from being rejected. The supplied abl.elf is written to abl_a (LUN 4) last, after the rawprogram flash and the ARB overlays, in place of the device-ABL restore.

ltbox_patch::abl_key. A pure-Rust port of the reference extract_avbpublickey.py: LZMA-alone decode, PE scan, AVB key-blob validation (n0inv + Montgomery rr), AArch64 ADR/ADRP+ADD reference counting to pick the referenced key, then SHA-1 over the blob. Classification reuses the existing key_map. The only dependency change promotes lzma-rust2, already present transitively, to a direct dependency — no new crate enters the graph.

Verification

  • Verified on hardware.
  • cargo fmt --check, cargo clippy --workspace --all-targets -D warnings, cargo test --workspace all clean (the pre-push hook runs these).
  • New unit tests cover the visible step sequence in both configurations and the gate decision across key classes and gated models.
  • The ABL extractor reproduces the reference script's output on seven local ABL images (six test key, one Lenovo key) under LTBOX_TEST_ABL_DIR.

🤖 Generated with Claude Code

@miner7222
miner7222 force-pushed the feat/flash-optional-abl-bootloader branch from ab66302 to 6befdd5 Compare September 4, 2026 06:53
Lenovo-key firmware now resolves its signing key and model at the folder
step, and a supplied testkey abl.elf lets the run re-sign without probing
the device's own bootloader key.

Co-authored-by: Claude (claude-opus-5) <noreply@anthropic.com>
Co-authored-by: Codex (gpt-5.6-sol) <noreply@openai.com>
@miner7222
miner7222 force-pushed the feat/flash-optional-abl-bootloader branch from 6befdd5 to 224e0b1 Compare September 4, 2026 10:11
@miner7222
miner7222 merged commit f23c196 into main Sep 4, 2026
12 checks passed
@miner7222
miner7222 deleted the feat/flash-optional-abl-bootloader branch September 4, 2026 10:20
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