Skip to content

tools: Add the flash image builder - #533

Open
chrysh wants to merge 2 commits into
OpenPRoT:ocp-global-demo-wipfrom
9elements:flash-image-builder
Open

chrysh wants to merge 2 commits into
OpenPRoT:ocp-global-demo-wipfrom
9elements:flash-image-builder

Conversation

@chrysh

@chrysh chrysh commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Review the last commit only. The first is #532, which this builds on;
the fork cannot host a real stack.

Makes the file the harness change seeds a chip select from.

The layout arrives as arguments but is built with the same Region, Slot
and ImageLayout constructors the board tables use, so a layout this tool
accepts is one the orchestrator would accept: unique slot ids, no
overlap, no zero-length region, nothing past the end of the offset
space. Re-deriving those rules here would let a test image drift from
what the firmware believes about the same flash.

Everything no image covers stays 0xFF, and a payload too large for its
slot is an error rather than a truncation.

The flash_image rule wraps the tool, so a BUILD file hands the result
straight to cs0_contents or cs1_contents:

flash_image(
    name = "update_image",
    flash_size = 64 * 1024 * 1024,
    slots = {"0:0x0:0x100000": "payload.bin"},
)

Assisted-by: Claude

chrysh added 2 commits October 3, 2026 13:58
The QEMU runner filled each FMC backing image with one byte, so a test
could hand the device erased flash and nothing else. The integration
test needs the device to already hold a firmware image the update agent
can offer.

cs0_contents and cs1_contents name a file to copy in at offset 0; the
remainder stays 0xFF. Without them the fill byte behaves as before, so
every existing test is unchanged.

A contents file longer than flash_size is an error rather than a
truncation. A half-written image still parses far enough to fail
verification, which would make a verify-failure scenario pass for the
wrong reason.

Assisted-by: Claude
A QEMU test that offers a firmware image needs that image on flash
before the guest boots. The harness can now seed a chip select from a
file; this makes the file.

The layout arrives as arguments but is built with the same Region, Slot
and ImageLayout constructors the board tables use, so a layout this tool
accepts is one the orchestrator would accept: unique slot ids, no
overlap, no zero-length region, nothing past the end of the offset
space. Re-deriving those rules here would let a test image drift from
what the firmware believes about the same flash.

Everything no image covers stays 0xFF, and a payload too large for its
slot is an error rather than a truncation.

The flash_image rule wraps the tool so a BUILD file can hand the result
straight to cs0_contents or cs1_contents.

Assisted-by: Claude

This branch has not been deployed

No deployments
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