Skip to content

services: Add the OCP Recovery Agent sequence - #982

Draft
chrysh wants to merge 2 commits into
OpenPRoT:ocp-streaming-recoveryfrom
9elements:ocp-agent-sequence
Draft

chrysh wants to merge 2 commits into
OpenPRoT:ocp-streaming-recoveryfrom
9elements:ocp-agent-sequence

Conversation

@chrysh

@chrysh chrysh commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Issue: #961

The Recovery Agent crate pushes 1 image through ImagePush, and no code runs the steps around the push: the capability check, the waits on the device, the RECOVERY_CTRL writes and the activation.

RecoverySequence runs these steps for 1 image, with 1 register access per step, as ImagePush does.

This PR stacks on the ImagePush PR, so the commit list shows the ImagePush commit below until that PR merges. Only the top commit is new.

Open questions:

  • OCP Recovery 1.2 section 7.4 requires the RECOVERY_CTRL write to select the CMS, so both writes carry the CMS in byte 0. Byte 1 holds 0x1 (the image in that CMS) in both writes. The BMC emulator in caliptra-mcu-sw writes [0, 0, 0], then [0, 0, 0xf], and Caliptra core reads only byte 2 and accepts that activation, while the OCP Recovery code on caliptra-mcu-sw main-2.1 refuses an activation with image selection 0x0 (OCP Recovery 1.2: questions for the OCP workgroup chipsalliance/Caliptra#787 row 5). Keep the fixed 0x1, write 0x0 in byte 1 as the emulator does, or take the image selection as a parameter of RecoverySequence::new?
  • After an activation, DEVICE_STATUS reading RecoveryModeReady returns the sequence to WaitForRecoveryStatus, and an AwaitingImage there ends the sequence with SequenceError::ImageNotHeld. In the Device design of docs: Add the OCP Recovery design proposal #680, the eRoT that refuses a streamed image writes RecoveryModeReady to DEVICE_STATUS and AwaitingImage to RECOVERY_STATUS without a reset, so the Recovery Agent reads the same states after a refused image and before the next image. How should the sequence tell a refusal from a request for the next image?
  • After DEVICE_STATUS returns the sequence to WaitForRecoveryStatus, the sequence reads only RECOVERY_STATUS, and Successful keeps the sequence waiting until the caller stops calling step, as in the agent state diagram in docs: Add the OCP Recovery design proposal #680. End the sequence with Recovered instead?

ImagePush pushes 1 image through the FIFO and reads DEVICE_STATUS after
each write. The device clears the protocol error on each DEVICE_STATUS
read, so after a failed read the Recovery Agent cannot tell whether the
device refused the write, and ImagePush ends the push.

ImagePush::step returns PushError, which wraps AgentError, so a caller
of read_prot_cap does not handle error variants that only a push
returns.

Signed-off-by: Christina Quast <christina.quast@9elements.com>
Assisted-by: Claude Opus 5.5
RecoverySequence runs the Recovery Agent steps around the push of 1
image through ImagePush. Both RECOVERY_CTRL writes carry the CMS of the
push in byte 0 and image selection 0x1 in byte 1, because the OCP
Recovery code on the caliptra-mcu-sw main-2.1 branch refuses an
activation with image selection 0x0. A failed RECOVERY_CTRL write with
the activation ends the sequence, because the device may have taken the
activation before the transport failed.

Signed-off-by: Christina Quast <christina.quast@9elements.com>
Assisted-by: Claude Fable 5.2
@chrysh
chrysh force-pushed the ocp-agent-sequence branch from b413b32 to 3255cd2 Compare December 4, 2026 11:18

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