Skip to content

Add FPGA bitstream signatures (Xilinx .bit/raw, Lattice iCE40); refs #829 - #981

Open
mfatgg wants to merge 1 commit into
ReFirmLabs:masterfrom
mfatgg:fpga-bitstream-signatures
Open

mfatgg wants to merge 1 commit into
ReFirmLabs:masterfrom
mfatgg:fpga-bitstream-signatures

Conversation

@mfatgg

@mfatgg mfatgg commented Nov 9, 2026

Copy link
Copy Markdown

Restores Xilinx bitstream detection from the Python version (listed in #829) and adds Lattice iCE40.

Xilinx

  • .bit files: parses the header fields (design, part, date/time, length) and checks for the sync word 0xAA995566 within the first 256 data bytes; reports design, part, date and the exact size.
  • Raw bitstreams: detects the bus-width auto-detect pattern 00 00 00 BB 11 22 00 44, followed only by 0xFF padding and the sync word within 64 bytes (size unknown, so medium confidence).

Lattice iCE40

  • Detects the 0x7EAA997E preamble and walks the command stream to the wakeup command to report the exact size (truncated streams get low confidence).

Tests

  • tests/fpga.rs, with two inputs: the iCE40 input is a real icepack UP5K image embedded at an offset; the Xilinx input is a minimal synthetic .bit (no Vivado here; happy to swap in a small real .bit, e.g. from openXC7).
  • The .bit test also checks that the raw bus-width pattern inside a .bit (at 0xE9) is not reported a second time.

Checked locally on 2671397 (Rust 1.96):

  • cargo test --test fpga passes.
  • The full cargo test passes, except integration_test_valid_arj, which fails the same way on unpatched master here (no arj binary installed).
  • cargo clippy --all-targets is clean, and cargo fmt --check is clean.
  • A real 104,090-byte HX icepack image is detected with the exact size.
  • 0 hits on 600 files from /usr/bin and /usr/lib.

No extractors yet; happy to add a carver if wanted.

🤖 Generated with Claude Code

Xilinx: parse the .bit header fields (design, part, date/time, length) and
require the 0xAA995566 sync word; raw bitstreams via the bus-width pattern,
0xFF padding and the sync word. Lattice iCE40: 0x7EAA997E preamble, then
walk the command stream to the wakeup command to report the exact size.
No extractors. Refs ReFirmLabs#829.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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