Skip to content

Commit 47895b9

Browse files
vbendeb-langpamaury
authored andcommitted
]provisioning] Allow to mix in SKU specific success text
When wating for successful post personalization restart in some cases the text printed on the device console is not static and depends on data generted during personalization. Modify ft_ext() prototype to accept the response structure and to return a String Option which the host would mix in with the constant success string when defining the expected console output. Tested with an updated Cros image which generates dev seed report. Signed-off-by: Vadim Bendebury <[email protected]> (cherry picked from commit 0f19189)
1 parent b3d4ed5 commit 47895b9

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

sw/device/silicon_creator/manuf/extensions/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ rust_library(
2525
srcs = ["default_ft_ext_lib.rs"],
2626
crate_name = "ft_ext_lib",
2727
deps = [
28+
"@//sw/host/provisioning/util_lib",
2829
"@crate_index//:anyhow",
2930
"@crate_index//:arrayvec",
3031
],

sw/device/silicon_creator/manuf/extensions/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ respectively:
5050

5151
Additionally, the FT provisioning test harness provides an hook function to call
5252
during the certificate endorsement operation:
53-
`pub fn ft_ext(endorsed_cert_concat: ArrayVec<u8, 4096>) -> Result<ArrayVec<u8, 4096>>`
53+
`pub fn ft_ext(_response: &PersonalizeResponse) -> Result<Option<String>>`
5454

5555
The default functions provided in this example external Bazel repo do nothing.
5656
However, this provides a mechanism for SKU owners / customers to develop

sw/device/silicon_creator/manuf/extensions/default_ft_ext_lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// SPDX-License-Identifier: Apache-2.0
44

55
use anyhow::Result;
6-
use arrayvec::ArrayVec;
6+
use util_lib::response::PersonalizeResponse;
77

8-
pub fn ft_ext(endorsed_cert_concat: ArrayVec<u8, 5120>) -> Result<ArrayVec<u8, 5120>> {
9-
Ok(endorsed_cert_concat)
8+
pub fn ft_ext(_response: &PersonalizeResponse) -> Result<Option<String>> {
9+
Ok(None)
1010
}

sw/host/provisioning/ft_lib/src/lib.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,6 @@ fn provision_certificates(
491491

492492
// Execute extension hook.
493493
let t0 = Instant::now();
494-
endorsed_cert_concat = ft_ext(endorsed_cert_concat)?;
495494
response.stats.log_elapsed_time("perso-ft-ext", t0);
496495

497496
// Authenticate WAS HMAC.
@@ -673,13 +672,17 @@ pub fn check_slot_b_boot_up(
673672

674673
let error_code_msg = r"BFV:.*\r\n";
675674

676-
let anchor_text = if let Some(owner_anchor) = &owner_fw_success_string {
677-
format!(
678-
r"(?s)({}|{}|{})",
679-
rom_ext_failure_msg, error_code_msg, owner_anchor
680-
)
681-
} else {
682-
format!(r"(?s)({}|{})", rom_ext_failure_msg, error_code_msg)
675+
// Optional text requried by certain SKUs.
676+
let owner_ext_string = ft_ext(response)?;
677+
678+
// Compile the full regex anchor including possible error messages and
679+
// expected owner FW messages.
680+
let errors_text = format!(r"{}|{}", rom_ext_failure_msg, error_code_msg);
681+
let anchor_text = match (owner_ext_string.clone(), owner_fw_success_string.clone()) {
682+
(Some(x), Some(y)) => format!(r"(?s)({errors_text}|{x}.*{y})"),
683+
(Some(x), None) => format!(r"(?s)({errors_text}|{x})"),
684+
(None, Some(y)) => format!(r"(?s)({errors_text}|{y})"),
685+
(None, None) => format!(r"(?s)({errors_text})"),
683686
};
684687

685688
let result =
@@ -696,6 +699,7 @@ pub fn check_slot_b_boot_up(
696699
}
697700
Err(e) => {
698701
if owner_fw_success_string.is_none()
702+
&& owner_ext_string.is_none()
699703
&& matches!(
700704
e.downcast_ref::<ConsoleError>(),
701705
Some(ConsoleError::TimedOut)

0 commit comments

Comments
 (0)