Skip to content

fwmanager: Add BootControl trait and HAL adapter#355

Open
chrysh wants to merge 3 commits into
OpenPRoT:mainfrom
9elements:add-boot-reset-control_v2
Open

fwmanager: Add BootControl trait and HAL adapter#355
chrysh wants to merge 3 commits into
OpenPRoT:mainfrom
9elements:add-boot-reset-control_v2

Conversation

@chrysh

@chrysh chrysh commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Introduce the Boot Orchestrator's actuation capability: the BootControl trait (hold_in_reset / release) and HalBootControl, which binds one HAL ResetControl line to a managed device. Includes a host unit test verifying that holding a device in reset asserts exactly its configured line.

Includes tests that release deasserts the device's configured line and that a controller error surfaces through BootControl unchanged. Extend the fake reset controller with opt-in failure injection to drive the error case.

Closes: 9elements#2

Assisted-by: Claude:claude-opus-4-8

@chrysh chrysh mentioned this pull request Jul 17, 2026
@chrysh
chrysh marked this pull request as ready for review July 17, 2026 10:23
@chrysh

chrysh commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@rusty1968 @leongross Can you have a look?

@chrysh
chrysh force-pushed the add-boot-reset-control_v2 branch from b6b55ae to d55e95f Compare July 17, 2026 13:54
/// ```
pub trait BootControl {
/// The error type reported by this device's boot control.
type Error: core::fmt::Debug;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only having Debug limits error handling downstream (in the orchestrator).
Requiring core::error::Error is more modern as it is available in core for a while now.
The openprot-hal implements its own Error trait, we might just require that or make the hal compatible with core::error::Error (so access to the ErrorKind could be acquired by downcasting).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, very good catch!

Comment thread services/fwmanager/api/src/boot_control.rs Outdated
Comment on lines +201 to +204
let err = bmc
.hold_in_reset()
.expect_err("expected the controller error to propagate");
assert_eq!(err.kind(), ErrorKind::InvalidResetId);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the bmc is a generic BootControl calling err.kind() won't work.
See the other comment about improving the BootControl::Error.
If we change BootControl to provide better means to access the error details add a test or change this test to validate it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! BootControl::Error now requires core::error::Error + system_control::Error, so a generic consumer can call err.kind() for categorization and gets Display/source() from core::error::Error. I also added compile and runtime checks. Does the current iteration make sense to you?

chrysh and others added 2 commits July 21, 2026 13:46
Introduce the Boot Orchestrator's actuation capability: the BootControl
trait (hold_in_reset / release) and HalBootControl, which binds one HAL
ResetControl line to a managed device. Includes a host unit test verifying
that holding a device in reset asserts exactly its configured line.

Includes tests that release deasserts the device's configured line and that a
controller error surfaces through BootControl unchanged. Extend the fake
reset controller with opt-in failure injection to drive the error case.

Closes: #2

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Christina Quast <christina.quast@9elements.com>
Co-authored-by: Marvin Gudel <marvin@gudel.org>
@chrysh
chrysh force-pushed the add-boot-reset-control_v2 branch from e10f4c6 to daa9aa7 Compare July 21, 2026 12:04
Tighten BootControl::Error from Debug-only to
`core::error::Error + system_control::Error` so the orchestrator gets
Display and a source() cause chain instead of just the Debug dump, and
so generic `BootControl` consumers can categorize failures via kind()
without downcasting to a concrete error type.

HAL reset controllers keep the existing Error/kind() pattern unchanged;
the new BootError adapter supplies the core::error::Error machinery over
any HAL error, so no per-implementation work is required.

Cover the combined bound with a compile-time fence and tests for Display
output, source(), dyn downcast, and kind() reached through a generic
BootControl.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Christina Quast <christina.quast@9elements.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.

Downstream device reset/boot control signaling

2 participants