tool: Add error for write locked
Add a new error for the case of trying to flash when security is enabled and it is still locked and update the related docs. Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
committed by
Tim Crawford
parent
54d795480c
commit
70c8678a5f
@ -29,6 +29,8 @@ pub enum Error {
|
||||
/// Encountered a hidapi::Error
|
||||
#[cfg(feature = "hidapi")]
|
||||
Hid(hidapi::HidError),
|
||||
/// Writing to flash is disabled
|
||||
WriteLocked,
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
|
@ -170,6 +170,12 @@ unsafe fn flash(ec: &mut Ec<Box<dyn Access>>, path: &str, target: SpiTarget) ->
|
||||
println!("ec version: {:?}", str::from_utf8(ec_version));
|
||||
}
|
||||
|
||||
if let Ok(security) = ec.security_get() {
|
||||
if security != SecurityState::Unlock {
|
||||
return Err(Error::WriteLocked);
|
||||
}
|
||||
}
|
||||
|
||||
if scratch {
|
||||
// Wait for any key releases
|
||||
eprintln!("Waiting 5 seconds for all keys to be released");
|
||||
@ -378,8 +384,6 @@ struct Args {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
//.subcommand(Command::new("security").arg(Arg::new("state").value_parser(["lock", "unlock"])))
|
||||
|
||||
let args = Args::parse();
|
||||
|
||||
let get_ec = || -> Result<_, Error> {
|
||||
|
Reference in New Issue
Block a user