Skip to content

updatemgr: Automatic External Firmware Update & Ownership Transfer - #362

Merged
anthonychen1251 merged 8 commits into
OpenPRoT:earlgrey-hwefrom
anthonychen1251:external-flash-fw-update-transport-with-dedicated-programmer
Jul 28, 2026
Merged

updatemgr: Automatic External Firmware Update & Ownership Transfer#362
anthonychen1251 merged 8 commits into
OpenPRoT:earlgrey-hwefrom
anthonychen1251:external-flash-fw-update-transport-with-dedicated-programmer

Conversation

@anthonychen1251

Copy link
Copy Markdown

This PR introduces the updatemgr service, enabling automatic background scanning of external SPI flash for new firmware images (ROM_EXT + APPLICATION) and Owner Transfer Blobs (OWTB), page-by-page internal eflash programming, owner page reprogramming, a dedicated eeprom_programmer firmware target, and end-to-end integration tests.

Note: this depends on #347 and #361 Only review the last 8 commits.

@anthonychen1251
anthonychen1251 force-pushed the external-flash-fw-update-transport-with-dedicated-programmer branch 8 times, most recently from 1d71ccc to dbc9bbb Compare July 27, 2026 18:05
@anthonychen1251
anthonychen1251 requested a review from cfrantz July 27, 2026 18:06
@anthonychen1251
anthonychen1251 force-pushed the external-flash-fw-update-transport-with-dedicated-programmer branch 2 times, most recently from a92bab5 to b356271 Compare July 27, 2026 20:53
Comment thread target/earlgrey/firmware/transport/flash_server.rs Outdated
Comment thread target/earlgrey/util/fw_update.rs Outdated
Comment thread target/earlgrey/util/fw_update.rs
Comment thread target/earlgrey/firmware/transport/updatemgr.rs Outdated
Comment thread target/earlgrey/firmware/transport/tests/dfu/host_usb_dfu_owner_transfer.rs Outdated
@anthonychen1251
anthonychen1251 force-pushed the external-flash-fw-update-transport-with-dedicated-programmer branch 2 times, most recently from a25fdc3 to 53c7196 Compare July 28, 2026 00:40
Comment thread target/earlgrey/firmware/transport/sysmgr.rs Outdated
Comment thread target/earlgrey/util/fw_update.rs Outdated
Comment thread target/earlgrey/firmware/transport/updatemgr.rs
Comment thread target/earlgrey/tests/eeprom_programmer/usbmgr.rs
Comment thread target/earlgrey/tests/eeprom_programmer/flash_server.rs Outdated
@anthonychen1251
anthonychen1251 force-pushed the external-flash-fw-update-transport-with-dedicated-programmer branch 2 times, most recently from e38259f to 32d3c69 Compare July 28, 2026 16:53
@anthonychen1251
anthonychen1251 marked this pull request as draft July 28, 2026 17:21
@anthonychen1251
anthonychen1251 force-pushed the external-flash-fw-update-transport-with-dedicated-programmer branch 2 times, most recently from 04d6103 to 8436df1 Compare July 28, 2026 18:45
@anthonychen1251
anthonychen1251 marked this pull request as ready for review July 28, 2026 18:47
@anthonychen1251

Copy link
Copy Markdown
Author

Rebased and added a new commit for enhancing the host_eeprom_{firmware_udapte, owner_transfer} test

@cfrantz

cfrantz commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Rebased and added a new commit for enhancing the host_eeprom_{firmware_udapte, owner_transfer} test

I think you'll need to rebase and resolve conflicts one more time before you can submit.

Move the DFU/A-B staging slot tracking helper `FwUpdate` from
`target/earlgrey/util/dfu.rs` to a standalone library target
`target/earlgrey/util/fw_update.rs`.

This decouples the firmware slot tracking logic from specific
sysmgr updater server implementations, allowing it to be reused
directly by other userspace processes (such as the new `updatemgr`
transport process).

Signed-off-by: Anthony Chen <antchen@google.com>
Introduce the new `updatemgr` process under
`target/earlgrey/firmware/transport/updatemgr.rs` to handle external
firmware update scanning.
- Implement the external firmware bundle scanner (`scan_firmware_bundle`
  and `try_read_bundle_at`) in `util/fw_update.rs`.
- Fixed 64KiB outer step size for scanning external flash.
- Support standalone Application manifests at 64KiB-aligned offsets
  without requiring a ROM_EXT image.
- Accept ROM_EXT sizes up to 128KiB (allowing ROM_EXT size upgrades).
- Dynamically start Application scanning at max(rom_ext_len, 64KiB)
  aligned to 8KiB step boundaries up to 128KiB.

Signed-off-by: Anthony Chen <antchen@google.com>
Implement EFLASH page-by-page erasing and programming logic
(`flash_write_partition`) in `updatemgr.rs` to flash valid ROM_EXT
and APPLICATION images from the external flash reader.

Signed-off-by: Anthony Chen <antchen@google.com>
Implement `flash_owner_block` helper in `updatemgr.rs` to write the
scanned Owner Block to Owner Info Page 1.

Signed-off-by: Anthony Chen <antchen@google.com>
…I flash tests

In the transport_firmware, `updatemgr` continuously scans the external
SPI flash for updates while `usbmgr` handles USB DFU read/write requests
. Operating both processes concurrently can cause interference and race
conditions on the external flash. To isolate DFU SPI EEPROM operations
during testing, add a dedicated `eeprom_programmer_firmware` target that
runs a subset of transport processes without `updatemgr`.

Signed-off-by: Anthony Chen <antchen@google.com>
…ore DFU tests

Set the default target in DFU owner transfer and firmware update tests
to `eeprom_programmer_firmware` to invalidate external EEPROM0 prior to
running the test payload.

Signed-off-by: Anthony Chen <antchen@google.com>
Add end-to-end tests for `updatemgr` covering both ownership transfer
and pure firmware update scenarios via external SPI flash.

The full end-to-end update flow:

1. Initial Setup: Target starts up running `eeprom_programmer_firmware`
2. Flash External EEPROM0: Host uses DFU Alt 4 (`DFU_ALT_SPI_EEPROM0`)
   exposed by the programmer firmware to flash the update payload
   (`ROM_EXT` + app) into external flash.
   - Non-standalone mode: Assembles ROM_EXT at offset 0 and Application
     at `manifest_base_address`.
   - Standalone mode: Flashes only the Application image at offset 0.
3. Bootstrap Transport FW: Host boostraps the device with the
   `transport_firmware`.
4. Telemetry Verification: `transport_firmware` boots up, detects the
   payload on external EEPROM0, processes owner transfer / firmware
   update, and outputs success telemetry over UART.

Signed-off-by: Anthony Chen <antchen@google.com>
To thoroughly verify firmware update behavior under different active slot
conditions, enhance `host_eeprom_owner_transfer` host test harness and Bazel
target generator to support assembling and bootstrapping `transport_firmware`
with all 4 slot combinations for ROM_EXT and Application (AA, AB, BA, BB).

Signed-off-by: Anthony Chen <antchen@google.com>
@anthonychen1251
anthonychen1251 force-pushed the external-flash-fw-update-transport-with-dedicated-programmer branch from 8436df1 to 6bde982 Compare July 28, 2026 20:22
@anthonychen1251

Copy link
Copy Markdown
Author

Rebased and added a new commit for enhancing the host_eeprom_{firmware_udapte, owner_transfer} test

I think you'll need to rebase and resolve conflicts one more time before you can submit.

Done

@anthonychen1251
anthonychen1251 merged commit 1d90962 into OpenPRoT:earlgrey-hwe Jul 28, 2026
5 checks passed
@anthonychen1251
anthonychen1251 deleted the external-flash-fw-update-transport-with-dedicated-programmer branch July 29, 2026 00:06
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.

2 participants