Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions EXAMPLES_ADVANCED.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,22 @@ Intel ME Status (SMBIOS Type 0xDB)
HFSTS6: 0x00000000
```

## EC System Info

Show which EC image is running, why the EC last reset and its locked state
(same as `ectool sysinfo`).

```
> framework_tool --sysinfo
EC System Info
Current Image: RO
Reset Flags: 0x00000048
PowerOn
Hibernate
Flags: 0x00000020
InManualRecovery
```

## Manually overriding tablet mode status

If you have a suspicion that the embedded controller does not control tablet
Expand Down
1 change: 1 addition & 0 deletions framework_lib/src/chromium_ec/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub enum EcCommands {
/// Erase section of EC flash
FlashErase = 0x13,
FlashProtect = 0x15,
Sysinfo = 0x1C,
PwmSetFanTargetRpm = 0x0021,
PwmGetKeyboardBacklight = 0x0022,
PwmSetKeyboardBacklight = 0x0023,
Expand Down
38 changes: 38 additions & 0 deletions framework_lib/src/chromium_ec/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,44 @@ impl EcRequest<EcResponseFlashProtect> for EcRequestFlashProtect {
}
}

#[repr(C, packed)]
pub struct EcRequestSysinfo {}

/// Bits of EcResponseSysinfo flags (enum sysinfo_flags)
#[repr(usize)]
#[derive(Debug, FromPrimitive)]
pub enum SysinfoFlag {
/// Write protect is asserted, debug features are disabled
Locked,
/// Locked even if write protect is deasserted
ForceLocked,
/// Jumping between images is enabled
JumpEnabled,
/// EC jumped directly to the current image at boot
JumpedToCurrentImage,
/// EC will reboot when the system shuts down
RebootAtShutdown,
/// System is in manual recovery mode
InManualRecovery,
Count,
}

#[repr(C, packed)]
pub struct EcResponseSysinfo {
/// Reset flags of the current boot. See enum EcResetFlag
pub reset_flags: u32,
/// Which EC image is currently in-use. See enum EcCurrentImage
pub current_image: u32,
/// See enum SysinfoFlag
pub flags: u32,
}

impl EcRequest<EcResponseSysinfo> for EcRequestSysinfo {
fn command_id() -> EcCommands {
EcCommands::Sysinfo
}
}

#[repr(C, packed)]
pub struct EcRequestPwmSetKeyboardBacklight {
pub percent: u8,
Expand Down
32 changes: 32 additions & 0 deletions framework_lib/src/chromium_ec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1902,6 +1902,38 @@ impl CrosEc {
}
}

pub fn get_sysinfo(&self) -> EcResult<()> {
let res = EcRequestSysinfo {}.send_command(self)?;
let current_image = match res.current_image {
1 => EcCurrentImage::RO,
2 => EcCurrentImage::RW,
_ => EcCurrentImage::Unknown,
};
println!("EC System Info");
println!(" Current Image: {:?}", current_image);
println!(" Reset Flags: {:#010X}", { res.reset_flags });
for flag in 0..(EcResetFlag::Count as usize) {
if ((1 << flag) & res.reset_flags) > 0 {
// Safe to unwrap unless coding mistake
println!(
" {:?}",
<EcResetFlag as FromPrimitive>::from_usize(flag).unwrap()
);
}
}
println!(" Flags: {:#010X}", { res.flags });
for flag in 0..(SysinfoFlag::Count as usize) {
if ((1 << flag) & res.flags) > 0 {
// Safe to unwrap unless coding mistake
println!(
" {:?}",
<SysinfoFlag as FromPrimitive>::from_usize(flag).unwrap()
);
}
}
Ok(())
}

pub fn get_uptime_info(&self) -> EcResult<()> {
let res = EcRequestGetUptimeInfo {}.send_command(self)?;
let t_since_boot = Duration::from_millis(res.time_since_ec_boot.into());
Expand Down
5 changes: 5 additions & 0 deletions framework_lib/src/commandline/clap_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ struct ClapCli {
#[arg(long)]
ec_hib_delay: Option<Option<u32>>,

/// Show system info (reset flags, current image, locked state)
#[arg(long)]
sysinfo: bool,

#[arg(long)]
uptimeinfo: bool,

Expand Down Expand Up @@ -575,6 +579,7 @@ pub fn parse(args: &[String]) -> Cli {
console: args.console,
reboot_ec: args.reboot_ec,
ec_hib_delay: args.ec_hib_delay,
sysinfo: args.sysinfo,
uptimeinfo: args.uptimeinfo,
s0ix_counter: args.s0ix_counter,
hash: args.hash.map(|x| x.into_os_string().into_string().unwrap()),
Expand Down
5 changes: 5 additions & 0 deletions framework_lib/src/commandline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ pub struct Cli {
pub console: Option<ConsoleArg>,
pub reboot_ec: Option<RebootEcArg>,
pub ec_hib_delay: Option<Option<u32>>,
pub sysinfo: bool,
pub uptimeinfo: bool,
pub s0ix_counter: bool,
pub hash: Option<String>,
Expand Down Expand Up @@ -334,6 +335,7 @@ pub fn parse(args: &[String]) -> Cli {
console: cli.console,
reboot_ec: cli.reboot_ec,
// ec_hib_delay
sysinfo: cli.sysinfo,
uptimeinfo: cli.uptimeinfo,
s0ix_counter: cli.s0ix_counter,
hash: cli.hash,
Expand Down Expand Up @@ -1573,6 +1575,8 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
print_err(ec.set_ec_hib_delay(*delay));
}
print_err(ec.get_ec_hib_delay());
} else if args.sysinfo {
print_err(ec.get_sysinfo());
} else if args.uptimeinfo {
print_err(ec.get_uptime_info());
} else if args.s0ix_counter {
Expand Down Expand Up @@ -1977,6 +1981,7 @@ Options:
--flash-rw-ec <FLASH_EC> Flash EC with new firmware from file
--reboot-ec Control EC RO/RW jump [possible values: reboot, jump-ro, jump-rw, cancel-jump, disable-jump]
--ec-hib-delay [<SECONDS>] Get or set EC hibernate delay (S5 to G3)
--sysinfo Show system info (reset flags, current image, locked state)
--uptimeinfo Show EC uptime information
--s0ix-counter Show S0ix counter
--intrusion Show status of intrusion switch
Expand Down
4 changes: 4 additions & 0 deletions framework_lib/src/commandline/uefi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pub fn parse(args: &[String]) -> Cli {
console: None,
reboot_ec: None,
ec_hib_delay: None,
sysinfo: false,
uptimeinfo: false,
s0ix_counter: false,
hash: None,
Expand Down Expand Up @@ -540,6 +541,9 @@ pub fn parse(args: &[String]) -> Cli {
Some(None)
};
found_an_option = true;
} else if arg == "--sysinfo" {
cli.sysinfo = true;
found_an_option = true;
} else if arg == "--uptimeinfo" {
cli.uptimeinfo = true;
found_an_option = true;
Expand Down
2 changes: 1 addition & 1 deletion framework_tool/completions/bash/framework_tool
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ _framework_tool() {

case "${cmd}" in
framework_tool)
opts="-v -q -t -f -h --flash-gpu-descriptor --verbose --quiet --versions --version --features --esrt --device --compare-version --power --smartbattery --smartbattery-auth --thermal --sensors --fansetduty --fansetrpm --autofanctrl --pdports --pdports-chromebook --info --meinfo --pd-info --pd-reset --pd-disable --pd-enable --dp-hdmi-info --dp-hdmi-update --audio-card-info --privacy --pd-bin --ec-bin --capsule --dump --h2o-capsule --dump-ec-flash --flash-full-ec --flash-ec --flash-ro-ec --flash-rw-ec --intrusion --inputdeck --inputdeck-mode --expansion-bay --charge-limit --charge-current-limit --charge-rate-limit --get-gpio --fp-led-level --fp-brightness --kblight --remap-key --rgbkbd --ps2-enable --tablet-mode --touchscreen-enable --haptic-intensity --click-force --stylus-battery --console --reboot-ec --ec-hib-delay --uptimeinfo --s0ix-counter --hash --driver --pd-addrs --pd-ports --test --test-retimer --boardid --force --dry-run --flash-gpu-descriptor-file --dump-gpu-descriptor-file --validate-gpu-descriptor-file --nvidia --host-command --generate-completions --help"
opts="-v -q -t -f -h --flash-gpu-descriptor --verbose --quiet --versions --version --features --esrt --device --compare-version --power --smartbattery --smartbattery-auth --thermal --sensors --fansetduty --fansetrpm --autofanctrl --pdports --pdports-chromebook --info --meinfo --pd-info --pd-reset --pd-disable --pd-enable --dp-hdmi-info --dp-hdmi-update --audio-card-info --privacy --pd-bin --ec-bin --capsule --dump --h2o-capsule --dump-ec-flash --flash-full-ec --flash-ec --flash-ro-ec --flash-rw-ec --intrusion --inputdeck --inputdeck-mode --expansion-bay --charge-limit --charge-current-limit --charge-rate-limit --get-gpio --fp-led-level --fp-brightness --kblight --remap-key --rgbkbd --ps2-enable --tablet-mode --touchscreen-enable --haptic-intensity --click-force --stylus-battery --console --reboot-ec --ec-hib-delay --sysinfo --uptimeinfo --s0ix-counter --hash --driver --pd-addrs --pd-ports --test --test-retimer --boardid --force --dry-run --flash-gpu-descriptor-file --dump-gpu-descriptor-file --validate-gpu-descriptor-file --nvidia --host-command --generate-completions --help"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand Down
1 change: 1 addition & 0 deletions framework_tool/completions/fish/framework_tool.fish
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ complete -c framework_tool -l intrusion -d 'Show status of intrusion switch'
complete -c framework_tool -l inputdeck -d 'Show status of the input modules'
complete -c framework_tool -l expansion-bay -d 'Show status of the expansion bay (Laptop 16 only)'
complete -c framework_tool -l stylus-battery -d 'Check stylus battery level (USI 2.0 stylus only)'
complete -c framework_tool -l sysinfo -d 'Show system info (reset flags, current image, locked state)'
complete -c framework_tool -l uptimeinfo
complete -c framework_tool -l s0ix-counter
complete -c framework_tool -s t -l test -d 'Run self-test to check if interaction with EC is possible'
Expand Down
1 change: 1 addition & 0 deletions framework_tool/completions/zsh/_framework_tool
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ _framework_tool() {
'--inputdeck[Show status of the input modules]' \
'--expansion-bay[Show status of the expansion bay (Laptop 16 only)]' \
'--stylus-battery[Check stylus battery level (USI 2.0 stylus only)]' \
'--sysinfo[Show system info (reset flags, current image, locked state)]' \
'--uptimeinfo[]' \
'--s0ix-counter[]' \
'-t[Run self-test to check if interaction with EC is possible]' \
Expand Down
Loading