Skip to content

Commit

Permalink
fixup! Add command to reboot EC, optionally to RW section
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnAZoidberg committed Apr 28, 2024
1 parent 2235161 commit a43d3b3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion framework_lib/src/chromium_ec/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ impl EcRequest<()> for EcRequestRebootEc {
EcCommands::RebootEc
}
fn command_version() -> u8 {
1
0
}
}

Expand Down
15 changes: 11 additions & 4 deletions framework_lib/src/commandline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use crate::ccgx::{self, SiliconId::*};
use crate::chromium_ec;
use crate::chromium_ec::commands::DeckStateMode;
use crate::chromium_ec::commands::FpLedBrightnessLevel;
use crate::chromium_ec::commands::RebootEcCmd;
use crate::chromium_ec::{print_err, EcFlashType};
use crate::chromium_ec::{EcError, EcResult};
#[cfg(feature = "linux")]
Expand Down Expand Up @@ -65,8 +66,9 @@ pub enum ConsoleArg {
#[cfg_attr(not(feature = "uefi"), derive(clap::ValueEnum))]
#[derive(Clone, Debug, PartialEq)]
pub enum RebootEcArg {
Ro,
Rw,
Reboot,
JumpRo,
JumpRw,
CancelJump,
DisableJump,
}
Expand Down Expand Up @@ -553,11 +555,15 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
}
} else if let Some(reboot_arg) = &args.reboot_ec {
match reboot_arg {
RebootEcArg::Ro => match ec.jump_ro() {
RebootEcArg::Reboot => match ec.reboot_ec(RebootEcCmd::ColdReboot) {
Ok(_) => {}
Err(err) => println!("Failed: {:?}", err),
},
RebootEcArg::Rw => match ec.jump_rw() {
RebootEcArg::JumpRo => match ec.jump_ro() {
Ok(_) => {}
Err(err) => println!("Failed: {:?}", err),
},
RebootEcArg::JumpRw => match ec.jump_rw() {
Ok(_) => {}
Err(err) => println!("Failed: {:?}", err),
},
Expand Down Expand Up @@ -778,6 +784,7 @@ Options:
--fp-brightness [<VAL>]Get or set fingerprint LED brightness level [possible values: high, medium, low]
--kblight [<KBLIGHT>] Set keyboard backlight percentage or get, if no value provided
--console <CONSOLE> Get EC console, choose whether recent or to follow the output [possible values: recent, follow]
--reboot-ec Control EC RO/RW jump [possible values: reboot, jump-ro, jump-rw, cancel-jump, disable-jump]
--hash <HASH> Hash a file of arbitrary data
-t, --test Run self-test to check if interaction with EC is possible
-h, --help Print help information
Expand Down
12 changes: 7 additions & 5 deletions framework_lib/src/commandline/uefi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,12 @@ pub fn parse(args: &[String]) -> Cli {
} else if arg == "--reboot-ec" {
cli.reboot_ec = if args.len() > i + 1 {
let reboot_ec_arg = &args[i + 1];
if reboot_ec_arg == "ro" {
Some(RebootEcArg::Ro)
} else if reboot_ec_arg == "rw" {
Some(RebootEcArg::Rw)
if reboot_ec_arg == "reboot" {
Some(RebootEcArg::Reboot)
} else if reboot_ec_arg == "jump-ro" {
Some(RebootEcArg::JumpRo)
} else if reboot_ec_arg == "jump-rw" {
Some(RebootEcArg::JumpRw)
} else if reboot_ec_arg == "cancel-jump" {
Some(RebootEcArg::CancelJump)
} else if reboot_ec_arg == "disable-jump" {
Expand All @@ -238,7 +240,7 @@ pub fn parse(args: &[String]) -> Cli {
None
}
} else {
println!("Need to provide a value for --reboot-ec. Either `ro`, `rw`, `cancel-jump` or `disable-jump`");
println!("Need to provide a value for --reboot-ec. Either `reboot`, `jump-ro`, `jump-rw`, `cancel-jump` or `disable-jump`");
None
};
found_an_option = true;
Expand Down

0 comments on commit a43d3b3

Please sign in to comment.